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
74.19k stars 31.16k forks source link

tp-link fails on KL130 bulbs due to missing color temperature information #20994

Closed keassol closed 5 years ago

keassol commented 5 years ago

Home Assistant release with the issue: 0.87.1

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.): hassio on rPI b+ System HassOS 2.8 Deployment production Hass.io supervisor Version 143

Component/platform: https://www.home-assistant.io/components/light.tplink/

Description of problem: LB130 - no entity is created

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

light:
  - platform: tplink
    host: 192.168.0.xx
    name: Color Bulb

Traceback (if applicable):

tplink: Error on device update!

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/light/tplink.py", line 145, in update
    self.get_features()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/light/tplink.py", line 204, in get_features
    self.smartbulb.valid_temperature_range[1])
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/color.py", line 516, in color_temperature_kelvin_to_mired
    return math.floor(1000000 / kelvin_temperature)
ZeroDivisionError: division by zero

Additional information: Have 10 working tp-link switches working properly. This is the first tp-link light. First tried adding while at 0.87, didnt work. Upgraded to 0.87.1, still doesnt work. Firmware of the LB130 is up to date per Kasa app.

fabaff commented 5 years ago

Try to change the color mode or brightness/color of the bulb with the app and then with Home Assistant. I have seen the similar behavior of mystrom bulbs as they are switching to RGB from HSV.

keassol commented 5 years ago

This will not work as it never shows up in HA. No light entity is ever created. Works fine in Kasa App.

borsaid commented 5 years ago

I have an identical issue with TP-LINK KL130

tplink: Error on device update! Traceback (most recent call last): File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/app/homeassistant/helpers/entity.py", line 349, 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/src/app/homeassistant/components/light/tplink.py", line 145, in update self.get_features() File "/usr/src/app/homeassistant/components/light/tplink.py", line 204, in get_features self.smartbulb.valid_temperature_range[1]) File "/usr/src/app/homeassistant/util/color.py", line 516, in color_temperature_kelvin_to_mired return math.floor(1000000 / kelvin_temperature) ZeroDivisionError: division by zero

Using 0.88.0

rytilahti commented 5 years ago

KL130 requires a new pyhs100 release (which I'll try to prepare soonish, see https://github.com/GadgetReactor/pyHS100/pull/156 for the fix), but it is odd that the LB130 is not working as that information has been there for a long, long time.

@keassol can you try pyhs100 temperature in console to see if it reports the supported ranges correctly? What does is being reported as a model (if you execute pyhs100 it will print out the name and model in the first line)? The list of currently known values is shown here: https://github.com/GadgetReactor/pyHS100/blob/master/pyHS100/smartbulb.py#L5 and the property getter returns (0, 0) for unknown models.

keassol commented 5 years ago

Unfortunately I was unable to figure out how to run it from console. I have tried to both to ssh into the pi and also tried it from the pi HassOS console itself. Both say the pyhs100 command is not found. I was also unable to come up with the right search terms to find instructions on how to do it. If someone has a link to instructions, I will provide the output.

borsaid commented 5 years ago

Unfortunately this is way outside my skill-set but I'd be happy to loan my bulb out to anyone who thinks it would be helpful to get the issue resolved. Reminder my bulb is the newer KL130.

On Wed, Mar 6, 2019 at 10:43 AM keassol notifications@github.com wrote:

Unfortunately I was unable to figure out how to run it from console. I have tried to both to ssh into the pi and also tried it from the pi HassOS console itself. Both say the pyhs100 command is not found. I was also unable to come up with the right search terms to find instructions on how to do it. If someone has a link to instructions, I will provide the output.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/20994#issuecomment-470156812, or mute the thread https://github.com/notifications/unsubscribe-auth/Atr_t75XsT3tDThozRQ2xcLCduAaVdpKks5vT-IjgaJpZM4a0_Me .

rytilahti commented 5 years ago

@keassol I'm not that familiar with HassOS, but with some help from #hassio it should be possible to access the container running homeassistant by doing the following:

docker exec -it homeassistant /bin/bash

and then running the command. If that does not directly work, you may want to check the name of the container with docker ps and replace "homeassistant" with its ID.

@borsaid as I mentioned, that should be fixed when I'm able to release a new version, unfortunately that will not make it in to the next homeassistant release but likely the one after that.

keassol commented 5 years ago

Thank you rytilahti. I just learned two things. The first thing was from a hint here that if you follow the instructions here you can run docker commands on the pi.

The second thing I learned was that I dont pay enough attention to details... The light bulb I have is not in fact a LB130, but rather it is a KL130. I am sorry for wasting anyones time.

You can file this issue either as "resolved" or "OP is an idiot", which ever you prefer.

rytilahti commented 5 years ago

@keassol good to know and happy to help! I'll update the title accordingly.