zachcheatham / ha-omada

Home Assistant TP-Link Omada Integration
189 stars 26 forks source link

Cannot not connect during setup #12

Open philhumber opened 2 years ago

philhumber commented 2 years ago

Upgraded OC200 HW controller to patch 5.0.29 (embedded https://community.tp-link.com/en/business/forum/topic/515912 and for Windows https://community.tp-link.com/en/business/forum/topic/515232) and cannot connect.

Error "Unable to connect to service." when adding new integration in HA.

GHRRGH commented 2 years ago

Just to be sure. Did you update custom integration files to the latest ones ? (That was my mistake)

I've just confirmed it works on 5.0.29 (Using the software controller though)

You can test the API functionality by entering this in the browser: https://IP:PORT/api/info PORT is only needed if you deviate from the standard HTTPS port.

philhumber commented 2 years ago

Yep - fresh DL.

API functionality is there at ip/api/info.

This is the HW controller. I get the following output - could it be an issue with v3 as I see references to api v2 in the codebase?

{"errorCode":0,"msg":"Success.","result":{"controllerVer":"5.0.29","apiVer":"3","configured":true,"type":10,"supportApp":true,"omadacId":"abcdefghijklmnopqrstuvwxyz1234567890"}}

GHRRGH commented 2 years ago

That should be fine, I also have v3:

{"errorCode":0,"msg":"Success.","result":{"controllerVer":"5.0.29","apiVer":"3","configured":true,"type":1,"supportApp":true,"omadacId":"xxx"}}

Did you check the HA logs after your connection attempts ?

philhumber commented 2 years ago

Not much there to go on. Two attempts just now - one with http and the other with https (just incase I was being dopey).

FWIW I haven't got SSL set up and I keep the validate SSL box unticked.

On Sun, 9 Jan 2022, 14:08 GHRRGH, @.***> wrote:

That should be fine, I also have v3:

{"errorCode":0,"msg":"Success.","result":{"controllerVer":"5.0.29","apiVer":"3","configured":true,"type":1,"supportApp":true,"omadacId":"xxx"}}

Did you check the HA logs after your connection attempts ?

— Reply to this email directly, view it on GitHub https://github.com/zachcheatham/ha-omada/issues/12#issuecomment-1008267570, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWWQM7Y7RWPOPVYF2TTMMDDUVFNBNANCNFSM5LO5M2OQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

zachcheatham commented 2 years ago

I was able to update my own controller to 5.0.29 with no issues related to the integration.

With the latest API changes, the integration requires the Site Name instead of the Site ID. I recall some people had renamed Default to something else but still needed to enter "Default" as the site during setup. I imagine those same people would need to use their custom name now.

GHRRGH commented 2 years ago

Indeed, that's the case. However, at that point you get a nice and clear error pointing you to that fact :)

image

Btw, if the URL has a trailing slash, the connection will throw an error as well.

philhumber commented 2 years ago

Very odd.

I did a little more digging, the integration is definitely talking to the Omada controller using the following path:

http://IP/OmadaID/API/v2/login

Omada is then returning the following result :

{"errorCode":-1600,"msg":"Unsupported request path."}

On Sun, 9 Jan 2022, 19:44 Zach Cheatham, @.***> wrote:

I was able to update my own controller to 5.0.29 with no issues related to the integration.

With the latest API changes, the integration requires the Site Name instead of the Site ID. I recall some people had renamed Default to something else but still needed to enter "Default" as the site during setup. I imagine those same people would need to use their custom name now.

— Reply to this email directly, view it on GitHub https://github.com/zachcheatham/ha-omada/issues/12#issuecomment-1008321824, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWWQM7Z32OLUW4F4KQMCB4LUVGUODANCNFSM5LO5M2OQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

GHRRGH commented 2 years ago

Have you tried it from the browser ? Btw, it should be HTTPS right ?

greendog99 commented 2 years ago

Since upgrading to Omada v5 my integration has also stopped working. I deleted the integration and tried to re-add it. HA log says:

custom_components.omada.api.errors.OmadaApiException: Call to https://XX.XX.XX.XX:8043/api/v2/login received status code 404.

When I go to https://XX.XX.XX.XX:8043/api/info in my browser it works fine, and returns:

{"errorCode":0,"msg":"Success.","result":{"controllerVer":"5.0.29","apiVer":"3","configured":true,"type":1,"supportApp":true,"omadacId":"XXX"}}

When I try to manually connect to the URL that the integration is calling (/api/v2/login), I do indeed get a 404:

$ curl -k https://XX.XX.XX.XX:8043/api/v2/login
{"timestamp":1642017145277,"status":404,"error":"Not Found","message":"","path":"/api/v2/login

Thanks for any suggestions to get it going again!

_[edit: looks like my copy of the integration is still the old code... trying to update it now...]

greendog99 commented 2 years ago

Ignore my reply above -- my ha-omada integration was way out of date... apparently HACS hasn't been updating it at all (it doesn't show up in my integration list under HACS either). I removed all the ha-omada files and restarted HA but HACS won't let me add a custom integration (the option is greyed out). Sounds like this isn't an ha-omada problem, so I'll keep digging.

lvibe commented 2 years ago

I am having similar issues when trying to connect and I think it may have to do with the url. When i try to connect with url: https:// ip address : port i get unknown error.

However when i try to connect with url: https:// ip address : port/ (the trailing slash is the difference) I get API error has occured check logs. Here is the output from the logs:

Logger: custom_components.omada.controller Source: custom_components/omada/controller.py:184 Integration: TP-Link Omada (documentation) First occurred: 8:36:25 AM (2 occurrences) Last logged: 8:44:08 AM

Unable to connect to Omada at https://xxx.xxx.x.xxx:8043/: Call to https://xxx.xxx.x.xxx:8043//api/v2/sites/Default/setting/ssids received status code -1001: Invalid request parameters

I believe the call to omada is in error due to the trailing slash as you see // in the url just above.

lvibe commented 2 years ago

Here is the log I receive for https:// ip address : port

Logger: aiohttp.server Source: custom_components/omada/api/controller.py:114 Integration: TP-Link Omada (documentation) First occurred: 8:50:14 AM (1 occurrences) Last logged: 8:50:14 AM

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper result = await method(view, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure result = await self._async_handle_step(flow, cur_step["step_id"], user_input) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/omada/config_flow.py", line 63, in async_step_user controller = await get_api_controller( File "/config/custom_components/omada/controller.py", line 171, in get_api_controller await controller.update_ssids() File "/config/custom_components/omada/api/controller.py", line 114, in update_ssids for ssid in response["ssids"][0]["ssidList"]: IndexError: list index out of range

zachcheatham commented 2 years ago

Here is the log I receive for https:// ip address : port

Do you have any wireless networks configured yet on this controller?

lvibe commented 2 years ago

I have a ubiquit AP set up on this network but the controller just covers the wired router

zachcheatham commented 2 years ago

Unfortunately, this integration only supports wireless device tracking. See #13

KruseLuds commented 2 years ago

Indeed, that's the case. However, at that point you get a nice and clear error pointing you to that fact :)

image

Btw, if the URL has a trailing slash, the connection will throw an error as well.

How do you even get to that dialog box? In HA the only thing I can add as an integration is "TP-Link Kasa Smart", not "TP-Link Omada", and even so, it asks only for a URL. Please advise?

KruseLuds commented 2 years ago

I was able to update my own controller to 5.0.29 with no issues related to the integration.

With the latest API changes, the integration requires the Site Name instead of the Site ID. I recall some people had renamed Default to something else but still needed to enter "Default" as the site during setup. I imagine those same people would need to use their custom name now.

How do I install this in Home Assistant? What is the url for the custom repository? What code needs to be installed manually and where, and what files - in GitHub there are a bunch of them and no instructions for which ones - ?

KruseLuds commented 2 years ago

See my comment in #23 for those who have trouble adding the custom repository