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
71.13k stars 29.81k forks source link

TP-Link Omada Integration fails to find all switches #89051

Closed jpettitt closed 1 year ago

jpettitt commented 1 year ago

The problem

The Omada integration only finds two of the three switches on my network.

It finds: TL-SG2428P v1.0 and TL-SG2210P v5.0

It fails to find: TL-SG3428 v2.0

What version of Home Assistant Core has the issue?

core-2023.3.0

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?

No response

Additional information

No relevant log entries found

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)

jpettitt commented 1 year ago

Worth noting that the two switches it found are POE and the one it didn't find is not POE

MarkGodwin commented 1 year ago

Currently, only switches with PoE will be returned, because the only thing the integration does at this stage is allows you to enable/disable PoE on these ports. More features will be added over the coming weeks/months. Please discuss feature requests in the community forum.

stsch83 commented 1 year ago

Hi, i have two PoE Switches in my network. Both are the same type with different revisions. But only on switch is shown by the integration. Any idea?

MarkGodwin commented 1 year ago

Ok, that sounds like a different problem to the others. Would you be able to collect the payload information from your web browser's development tools when using the Omada portal to help diagnose the problem?

You should see the Omada console load the list of devices with a URL like: https://x.x.x.x/<some_long_id>/api/v2/sites/Default/devices?_=1678553653705 The response to that should be a long string of json data listing all your Omada device details.

Secondly, when you get information about one of the switches, it should make a request like https://x.x.x.x/<some_long_id>/api/v2/sites/Default/switches/[xx_xx_xx_xx_xx]?_=1678553653705 That should have information about the switch, including port data.

stsch83 commented 1 year ago

Ok, that sounds like a different problem to the others. Would you be able to collect the payload information from your web browser's development tools when using the Omada portal to help diagnose the problem?

You should see the Omada console load the list of devices with a URL like: https://x.x.x.x/<some_long_id>/api/v2/sites/Default/devices?_=1678553653705 The response to that should be a long string of json data listing all your Omada device details.

Secondly, when you get information about one of the switches, it should make a request like https://x.x.x.x/<some_long_id>/api/v2/sites/Default/switches/[xx_xx_xx_xx_xx]?_=1678553653705 That should have information about the switch, including port data.

if i type this: https://192.168.0.10/364b28bb43f8863839ef640eb6b77e15/api/v2/sites/Default/devices?_=1678553653705 i automatically ump to the login page.

stsch83 commented 1 year ago

Ok, that sounds like a different problem to the others. Would you be able to collect the payload information from your web browser's development tools when using the Omada portal to help diagnose the problem? You should see the Omada console load the list of devices with a URL like: https://x.x.x.x/<some_long_id>/api/v2/sites/Default/devices?_=1678553653705 The response to that should be a long string of json data listing all your Omada device details. Secondly, when you get information about one of the switches, it should make a request like https://x.x.x.x/<some_long_id>/api/v2/sites/Default/switches/[xx_xx_xx_xx_xx]?_=1678553653705 That should have information about the switch, including port data.

if i type this: https://192.168.0.10/364b28bb43f8863839ef640eb6b77e15/api/v2/sites/Default/devices?_=1678553653705 i automatically ump to the login page.

what is the last number ??? 1678553653705 ???

MarkGodwin commented 1 year ago

The number on the end isn't important, it's just to avoid any browser caching. However, if you just use the URL and try and open the page, your browser won't add the correct login headers to the request, so the controller will redirect you to the login page. To see the results, you need to use the developer tools (F12, usually) in the browser. You can see the Response Payload as a tab on the Network tab.

stsch83 commented 1 year ago

Sorry, i will help your with my informations. But i'm not able to find the data in the dev tools of safari or chrome. I dont see an json date. I only see a timeline witch starts with login. This is an redirect and so, i see no data. Do you have any idea to collect the data?

stsch83 commented 1 year ago

@MarkGodwin do you have new ideas for me to provide you same data?

MarkGodwin commented 1 year ago

@MarkGodwin do you have new ideas for me to provide you same data?

Sorry, I won’t be able to look at this before Monday. I’ll find some step-by-step instructions then.

MarkGodwin commented 1 year ago

Ok, please try the following to get more diagnostic information. You'll need Python 3.9 or later installed. If you're using Windows, I find it easiest to use wsl2 to run these commands in debian, but YMMV.

pip install tplink-omada-client

You should see something like Successfully installed tplink-omada-client-1.2.2

mark@OfficePC:~$ omada
usage: omada [-h] [-t TARGET] command ...

optional arguments:
  -h, --help            show this help message and exit
  -t TARGET, --target TARGET
                        The target Omada controller

Available commands:
  command
    devices (d)         Lists devices managed by Omada Controller
    switch              Shows details about the specified switch
    switches (s)        Lists switches managed by Omada Controller
    target              Add Omada Controller to list of targets
    targets (t)         Lists the configured targets
    default             Sets the default target

mark@OfficePC:~$ omada -t OC200 target --url https://<your controller address> --username admin --password <pwd> --set-default
Set target OC200 to controller OC200 and site Default

mark@OfficePC:~$ omada devices
<should give you a nice list of omada devices>

If that works, then run the command omada switches --dump > switches.txt.

This will output a lot of data into a file switches.txt. Redact any personal information you don't want to share from the file, and then attach it to this issue. Hopefully we'll be able to work out the difference between the switches which is causing the problem.

stsch83 commented 1 year ago

Ok, please try the following to get more diagnostic information. You'll need Python 3.9 or later installed. If you're using Windows, I find it easiest to use wsl2 to run these commands in debian, but YMMV.

pip install tplink-omada-client

You should see something like Successfully installed tplink-omada-client-1.2.2

mark@OfficePC:~$ omada
usage: omada [-h] [-t TARGET] command ...

optional arguments:
  -h, --help            show this help message and exit
  -t TARGET, --target TARGET
                        The target Omada controller

Available commands:
  command
    devices (d)         Lists devices managed by Omada Controller
    switch              Shows details about the specified switch
    switches (s)        Lists switches managed by Omada Controller
    target              Add Omada Controller to list of targets
    targets (t)         Lists the configured targets
    default             Sets the default target

mark@OfficePC:~$ omada -t OC200 target --url https://<your controller address> --username admin --password <pwd> --set-default
Set target OC200 to controller OC200 and site Default

mark@OfficePC:~$ omada devices
<should give you a nice list of omada devices>

If that works, then run the command omada switches --dump > switches.txt.

This will output a lot of data into a file switches.txt. Redact any personal information you don't want to share from the file, and then attach it to this issue. Hopefully we'll be able to work out the difference between the switches which is causing the problem.

I try to create a target and get this error message. I'm on linux. Python version is 3.10.xxx.

root@tplink-omada-client:~# omada -t OC200 target --url https://192.168.0.10 --user admin --site Home --set-default
Password: 
Set target OC200 to controller SDN Router and site Home
Traceback (most recent call last):
  File "/usr/local/bin/omada", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/tplink_omada_client/cli/__init__.py", line 44, in main
    return asyncio.run(args.func(vars(args)))
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.10/dist-packages/tplink_omada_client/cli/command_target.py", line 30, in command_target
    set_target_config(target, config, args['set_default'])
  File "/usr/local/lib/python3.10/dist-packages/tplink_omada_client/cli/config.py", line 59, in set_target_config
    if not config_parser[_CLI_SECTION]:
  File "/usr/lib/python3.10/configparser.py", line 964, in __getitem__
    raise KeyError(key)
KeyError: 'cli'
root@tplink-omada-client:~# 
MarkGodwin commented 1 year ago

My mistake. it looks like --set-default is broken. Try without --set-default, and then run omada -t Home default to set the default target instead.

stsch83 commented 1 year ago

My mistake. it looks like --set-default is broken. Try without --set-default, and then run omada -t Home default to set the default target instead.

switches.txt

stsch83 commented 1 year ago

My mistake. it looks like --set-default is broken. Try without --set-default, and then run omada -t Home default to set the default target instead.

I think i have an idea why one of my two poe switches is not shown. In one name is an german letter 'ü'.

stsch83 commented 1 year ago

Hi, i have two PoE Switches in my network. Both are the same type with different revisions. But only on switch is shown by the integration. Any idea?

Hi, this was my mistake. I have only one PoE Switch. I would say everything works fine. Sorry for that.

MarkGodwin commented 1 year ago

Ok, sorry for not responding sooner. You're right, the dump shows that one of the switches doesn't support PoE. However, in the current version, it should be detected as it supports firmware updates.

@home-assistant close

issue-triage-workflows[bot] commented 1 year 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.