Skip to content
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

TP-Link Component: Failure to find one switch results in entire component failing #21725

Closed
stbenjam opened this issue Mar 7, 2019 · 7 comments

Comments

@stbenjam
Copy link
Contributor

stbenjam commented Mar 7, 2019

Home Assistant release with the issue:

0.89

Last working Home Assistant release (if known):

0.87

Operating environment (Hass.io/Docker/Windows/etc.):

Docker on RHEL7

Component/platform:

TPLink

https://www.home-assistant.io/components/tplink/

Description of problem:

I have a number of TP-link switches, some of which are only used part of the year. For example, I keep one for my Christmas tree. They have static IP addresses, and I don't want to use discovery (I have a complex network configuration, HA is on a different network than the IoT stuff). If one switch is unavailable, then the entire component doesn't load.

I can comment them out, but I'd prefer not to.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

# IP addresses are masked
tplink:
  discovery: false
  switch:
    - host: 192.168.XX.XX
    - host: 192.168.XX.XX
    - host: 192.168.XX.XX
    - host: 192.168.XX.XX
    - host: 192.168.XX.XX
    - host: 192.168.XX.XX
    - host: 192.168.XX.XX

Traceback (if applicable):

2019-03-07 01:08:44 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry TP-Link Smart Home for tplink
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pyHS100/smartdevice.py", line 116, in _query_helper
    request=request,
  File "/usr/local/lib/python3.7/site-packages/pyHS100/protocol.py", line 47, in query
    sock = socket.create_connection((host, port), timeout)
  File "/usr/local/lib/python3.7/socket.py", line 727, in create_connection
    raise err
  File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
OSError: [Errno 113] No route to host
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/config_entries.py", line 283, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/app/homeassistant/components/tplink/__init__.py", line 120, in async_setup_entry
    await hass.async_add_executor_job(_fill_device_lists)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/tplink/__init__.py", line 110, in _fill_device_lists
    if dev.is_dimmable:  # Dimmers act as lights
  File "/usr/local/lib/python3.7/site-packages/pyHS100/smartplug.py", line 131, in is_dimmable
    return "brightness" in self.sys_info
  File "/usr/local/lib/python3.7/site-packages/pyHS100/smartdevice.py", line 185, in sys_info
    return defaultdict(lambda: None, self.get_sysinfo())
  File "/usr/local/lib/python3.7/site-packages/pyHS100/smartdevice.py", line 195, in get_sysinfo
    return self._query_helper("system", "get_sysinfo")
  File "/usr/local/lib/python3.7/site-packages/pyHS100/smartdevice.py", line 119, in _query_helper
    raise SmartDeviceException('Communication error') from ex
pyHS100.smartdevice.SmartDeviceException: Communication error

Additional information:

@ljmerza
Copy link
Contributor

ljmerza commented Mar 7, 2019

according to the pyHS100 library, dev.is_dimmable calls get_sysinfo which raises SmartDeviceException.

I've submitted a pull request as I had this issue as well

#21726

@xirixiz
Copy link

xirixiz commented Mar 7, 2019

I have the exact same setup and issue 😄

@rytilahti
Copy link
Member

Fixed now in dev branch, thanks to @ljmerza!

@stbenjam
Copy link
Contributor Author

stbenjam commented Mar 7, 2019

Thanks 🙏 That was fast!

@henrikhjelm
Copy link

any news about this ?

@xirixiz
Copy link

xirixiz commented Mar 14, 2019

Merged in dev but not in 89.1 or 89.2 unfortunately....

@mifrendjim
Copy link

mifrendjim commented Mar 14, 2019

Just pulled dev(0.90.0b1) and I'm getting this:

Mar 14 23:51:50 hassbian hass[675]: TypeError: 'NoneType' object is not subscriptable
Mar 14 23:51:50 hassbian hass[675]: 2019-03-14 23:51:50 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Mar 14 23:51:50 hassbian hass[675]: Traceback (most recent call last):
Mar 14 23:51:50 hassbian hass[675]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
Mar 14 23:51:50 hassbian hass[675]:     result = coro.send(None)
Mar 14 23:51:50 hassbian hass[675]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 257, in _async_add_entity
Mar 14 23:51:50 hassbian hass[675]:     if entity.unique_id is not None:
Mar 14 23:51:50 hassbian hass[675]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/tplink/switch.py", line 62, in unique_id
Mar 14 23:51:50 hassbian hass[675]:     return self._sysinfo["mac"]
Mar 14 23:51:50 hassbian hass[675]: TypeError: 'NoneType' object is not subscriptable

Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants