home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.49k stars 30.7k forks source link

TP-Link Omada integration broken after upgrade to 5.12.7 #101140

Closed TommySharpNZ closed 1 month ago

TommySharpNZ commented 1 year ago

The problem

Upgrading the TP-Link Omada controller to version 5.12.7 seem to break the integration?

What version of Home Assistant Core has the issue?

core-2023.9.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

TP-Link Omada

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tplink_omada

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.tplink_omada.config_flow
Source: components/tplink_omada/config_flow.py:86
Integration: TP-Link Omada (documentation, issues)
First occurred: 11:56:32 (1 occurrences)
Last logged: 11:56:32

Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/tplink_omada/config_flow.py", line 203, in _test_login
    info = await _validate_input(self.hass, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tplink_omada/config_flow.py", line 86, in _validate_input
    controller_id = await client.login()
                    ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/tplink_omada_client/omadaclient.py", line 58, in login
    return await self._api.login()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/tplink_omada_client/omadaapiconnection.py", line 106, in login
    response = await self._do_request(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/tplink_omada_client/omadaapiconnection.py", line 204, in _do_request
    self._check_application_errors(content)
  File "/usr/local/lib/python3.11/site-packages/tplink_omada_client/omadaapiconnection.py", line 230, in _check_application_errors
    if response["errorCode"] == 0:
       ~~~~~~~~^^^^^^^^^^^^^
KeyError: 'errorCode'

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @markgodwin, mind taking a look at this issue as it has been labeled with an integration (tplink_omada) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tplink_omada` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tplink_omada` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


tplink_omada documentation tplink_omada source (message by IssueLinks)

MarkGodwin commented 1 year ago

It looks like TP-Link have had a bit of an overhaul of their API in the latest update, and added OpenAPI specs at the same time. I need to do a bit of investigation to see if we can update without breaking backward compatibility with older controllers.

MarkGodwin commented 1 year ago

I've upgraded to 5.12.9 on my OC200 (firmware 2.11.3 Build 20230906 Rel.36272), and the login and API seems to be working fine, and the HA integration is still working. I may still want to switch to the new API at some stage, but it doesn't as urgent now.

Are you using a software or hardware controller?

TommySharpNZ commented 1 year ago

I will do some more detailed investigation.... I am running a software controller.

securebitsorg commented 1 year ago

First of all, thank you for the initial integration of Omada!

After updating Omada Software Controller under Ubuntu to version 5.12.7, the connection from HA to Omada Controller no longer works. There is always a 500 error message. Even if I create an API user and use these credentials, no connection is possible.

MarkGodwin commented 1 year ago

It's possible that the software controller no longer supports the old API. Ideally we need to get a log of the login messages sent between the web page and the back-end to confirm what has changed. If you could collect these with something like fiddler, that would be great.

I looked into the new OpenAPI API a bit this weekend. The oauth interactive login isn't appropriate for HA because the tokens only last for 14 days, however, there is a client_secret auth flow that would work. Unfortunately, the API looks significantly different to the old one, so switching over won't be trivial. It also seems they rate limit calls to 1,000 a day, which could be a big problem with polling each list for updates. I don't understand why they would do that unless all the calls get routed via the cloud, which I hope is not the case.

On Mon, Oct 2, 2023 at 7:44 AM securebits @.***> wrote:

First of all, thank you for the initial integration of Omada!

After updating Omada Software Controller under Ubuntu to version 5.12.7, the connection from HA to Omada Controller no longer works. There is always a 500 error message. Even if I create an API user and use these credentials, no connection is possible.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/101140#issuecomment-1742477486, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRD6DEC2GQPF4YG7MGUOZ3X5JPGLANCNFSM6AAAAAA5NC3N7I . You are receiving this because you were mentioned.Message ID: @.***>

securebitsorg commented 1 year ago

Thanks for the quick reply!

I have attached you a transcript of the login process as WCAP output (formatted as TXT, otherwise I could not have uploaded it). I hope that helps!

If not, please tell me a way how I can send you the Fiddler archive.

Greetings Marcel

Omada Login 2023-10-2.txt

andyjenkinson commented 1 year ago

@MarkGodwin where are the OpenAPI specs? The docs page hosted within the controller (doc.html) doesn't seem to load correctly.

TommySharpNZ commented 1 year ago

@andyjenkinson the docs link in my control looked like it wasn't working but eventually loaded up after about 30 seconds.

@MarkGodwin is there anything I can do to help troubleshoot this issue? Skills are a bit limited but I can follow instructions :-)

MarkGodwin commented 1 year ago

Sorry, I have been buried deep in another project. That is now finished, so I will look at this as soon as I have some spare time. Hopefully next weekend.I will probably try to fix the old api first, as there is more chance of a quick fix there, and less worries on API call limits. If that won’t fly, I will look into switching to the new API, which will probably have to happen eventually.On 29 Oct 2023, at 21:48, Tommy @.***> wrote: @andyjenkinson the docs link in my control looked like it wasn't working but eventually loaded up after about 30 seconds. @MarkGodwin is there anything I can do to help troubleshoot this issue? Skills are a bit limited but I can follow instructions :-)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

TommySharpNZ commented 1 year ago

Awesome, appreciate the work :-)

Chef-de-IT commented 1 year ago

@MarkGodwin this is a very useful and promising integration! Is there a roadmap to enable Device Trackers - per doc https://www.home-assistant.io/integrations/tplink_omada/ they're not yet supported. Device Trackers are vital for user presence detection in HA, and Omada even identifies to which AP the user is connected.

Sorry to use this issue# thread for the question - not sure a one-off question is worth its own thread and unclear in which forum to even open it to be seen. Thanks!

MarkGodwin commented 1 year ago

This is confusing. I've installed the software controller 5.12.7, and the tplink-omada-api python package is still able to connect to it without issue. Please can you try using the omada command line in your environment, and see if that will work?

I did see something in the release notes about a change in cookie name in the new controller version. The authentication session information is stored in a cookie, so I wonder if this is the problem. It may be possible to clear cookies in HA, or wait for the cookie to expire?

TommySharpNZ commented 1 year ago

Okay, I'll have to do some reading to work out how to use the command lind.... but I will have a go...

jamie-dit commented 11 months ago

Hey, is there a fix for this? I've tried downgrading which doesn't seem to help at all.

lowclearance commented 9 months ago

Hi all, has this been repaired yet? I have an OC200 on 5.12.9 and now I am unable to see data from the controller. You all mentioned to "clear cookies in HA" but I am unable to locate where that functionality is. Thanks for whatever you can do with this.

CAP-Team commented 9 months ago

Yes, the integration works with Omada 5.13.22

lowclearance commented 9 months ago

Yes, the integration works with Omada 5.13.22

The OC200 does not yet have an upgrade past 5.12.9 as of today. Is there something else I can try to remedy this issue? It's not earth shattering but I want to avoid deleting and re-adding the host if I can. Thanks.

dmelideo commented 9 months ago

I landed here with what looks like the same issue. Running HA and have lost Omada integration. Can't achieve functionality. My OC200 has controller version 5.12.9. Appears latest.

MarkGodwin commented 9 months ago

This is very confusing to me. I have:

I'm not having any problems with the integration, so I don't think it's anything to do with the controller version.

There do seem to be occasional problems with the cookie based authentication of the controller, but I have never experienced any of them, so I can't advise you of the solution.

fohlsso2 commented 8 months ago

Not being that much of help, but i have Omada_SDN_Controller_v5.13.23_linux_x64.deb, recently upgraded from 12.7 running on debian 11.9 and it works with HA 2024.2.1 Had to remove and re-add the integration a few weeks ago after getting an error 'failed setup, will retry' but else it has been working without issues.

(PS. I have not enabled the verify SSL box as Im running with own generated certs). (PS2 I actually came here to add a feature request and got curious when I saw the bug report).

lowclearance commented 8 months ago

Looks like TP-Link just pushed out an new firmware version for the OC200. Last night I updated to:

This new version is working again, albeit I did have to delete and reenter the OC200 but it was easy and it rediscovered everything. Hope this helps.

mrwkbrdr commented 8 months ago

So this is what I can gather. Something has definitely changed? My OC200 has always been on a different lan than my HA. It used to connect just fine even though it was on a different lan. But now it will no longer connect on different lan. No ACL denying access between lans. It used to work ? Bummer!

Fonsohome commented 8 months ago

I also solved the problem with the new update but now there is a new problem. If you activate two-factor verification, the integration does not start.

MarkGodwin commented 7 months ago

I also solved the problem with the new update but now there is a new problem. If you activate two-factor verification, the integration does not start.

Yeah, if you think about it, two factor authentication is definitely not going to work. The whole point of 2FA is a second authentication mechanism. Is the integration going to check your SMS or email for a security code when it tries to log into the controller? Pretty obviously, it can't do that.

You'll need to do without 2FA, at least until the integration switches over to the new Open API, which will use a client_credentials oauth flow. The problem is, the new API doesn't support many of the features that the integration already relies on, so I don't think we can switch over any time soon.

issue-triage-workflows[bot] commented 4 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

dmelideo commented 4 months ago

Within the last month, the HA TP-Link Omada functionality has started to work. Only change has been HA updates and a few Omada firmware updates. I could not get a connection thru various attempts to fix. Unfortunately, due to my work travel schedule, I can't pinpoint what corrected the issue. My firmware was updated thru Omada app, HA thru rolling updates.

issue-triage-workflows[bot] commented 1 month ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.