-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TpLink Device Tracker Error #15918
TpLink Device Tracker Error #15918
Conversation
…n if another scanner would succeed
Thanks for the contribution, please change your PR description following our template. |
@awarecan Updated the PR description and fixed the build issues... |
scanner = cls(config[DOMAIN]) | ||
if scanner.success_init: | ||
return scanner | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This try/catch should move into TplinkDevice[*]Scanner._update_info()
, wrapping self.tplink_client.get_connected_devices()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only TplinkDeviceScanner uses self.tplink_client.get_connected_devices()
the others use requests.get
or requests.session
You want me to wrap each individual call in a try except?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since scanner use a flag success_init
to indicate whether initialize success, the try/catch should be done in scanner.__init__
if need.
if scanner.success_init: | ||
return scanner | ||
except ConnectionError: | ||
_LOGGER.warning("ConnectionError in scanner %s", cls.__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_LOGGER.debug()
is enough, this exception was expecting since some device only be able to init as specific type of scanner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then remove this, but use _LOGGER.debug()
in these individual except blocks?
@TimBailey-pnk it would be awesome if you can work together with @JackNova and add support for your router in the tplink library: |
@awarecan Pushed some changes based on your comments. Pls review |
@awarecan Any thoughts? |
@awarecan Sorry to hassle, anything more you want me to do on this? |
Description:
I am a Software developer (C#/NodeJS) and this is my first ever fix for Python code.
I have a TPLink EAP245 Access Point which when I configured the device_tracker was causing a Error setting up platform tplink log entry. On further investigation it seems that the code tries a number of scanners in order to try to get the user list. In my case the scanner that works is the second in the list but it never gets there due to an exception in the first.
My fix is to log any errors but just pass so that the next scanner can have a try.
I've run the tests and they all pass locally.
Related issue (if applicable): fixes #
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: