core: TP-Link light & switch communication errors in Hassio 0.91.x
Home Assistant release with the issue:
Since 0.91
Last working Home Assistant release (if known): 0.90 but im not sure. It’s right after the integration.
Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io
Component/platform:
TP-Link Smart Home
Description of problem:
Frequent errors communicating with tp-link switch hs110 and tp-link light lb100
For the switch and light in 2 seperate errors:
Could not read state for 192.168.xx.xx: Communication error
For the switch templates, bellow is one but its the same for every template entry:
Could not render template Daily Energy: UndefinedError: ‘mappingproxy object’ has no attribute ‘today_energy_kwh’
Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):
tplink:
light:
- host: 192.168.xx.xx
switch:
- host: 192.168.xx.xx
Traceback (if applicable):
File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
await self.async_device_update()
File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 379, in async_device_update
await self.hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/tplink/light.py", line 176, in update
self.smartbulb.brightness)
File "/usr/local/lib/python3.7/site-packages/pyHS100/smartbulb.py", line 218, in brightness
return int(light_state['dft_on_state']['brightness'])
KeyError: 'dft_on_state'
Additional information:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 52 (13 by maintainers)
@TheGardenMonkey would you be able to put a PR in for this with your fix?
@DarwinData - We have several pull requests in that will fix this issue. I have been running the modified tplink component for the past 5 months and it works perfect. Our pull requests have not been approved due to them being work-arounds and there is other work being done to the back end library. I still don’t understand why the fix/work-around can’t be added for the time being. In the meantime, feel free to copy switch.py and light.py from my repository. Copy them over the release version and you will be fine. The other option is to run it as a custom component. Here is the link: https://github.com/MarkHofmann11/core/tree/dev/homeassistant/components/tplink
Having the same communication error. Running two instances, one docker, version 0.88.2 non hassio without any errors on the TPLink component. One hassio on NUC running 0.93.2 which gives communication errors and an unknown state as result. Tried both manual config as well as using UI.
Running 2 TPLink HS110 switches. One working fine without issues or losing connectivity, one giving issues. Both are in the same room, with the one failing even closer to the Wifi Access Point (3 meters with concrete ceiling to pass through) then the non-failing one (same room, approx 4 meters).
I was on 109.6 when I got the errors but I have now updated to 110.2 and the log errors are gone. thanks!
fyi, this error still exists in 110.1 I have 7 switches and I get the following many times a day. Could not read state for 192.168.1.110: Communication error thanks
I use lots of tp-link devices (lights, switches, plugs, etc). I can confirm 100% that @TheGardenMonkey modifications fix the problem. Since there has never been an official pull request that I’m aware of, I just keep copying his versions over each latest release of HA to keep things working properly. You need the light.py and switch.py from his repo and the problem with unavailable status will go away. It is the best we can do right now short of a pull request that gets approved.
I hope your changes get approved. Even if there are other long term plans for addressing this, I see no reason not to apply this fix now. Very glad I can just keep re-copying your updated TPlink files over to my install as necessary - they work perfectly over here. The TPLink integration has never works as good as it does right now, as your changes keep consistent connectivity with no “unavailable”. I have lots of TPLink devices over here including, switches, lights, and strip, All work perfectly.