I got a TP-Link LB120 for Christmas and like it well enough that I am planning n getting a couple more. Right now I can control them through Alexa but only directly through Kasa and not via HASS.
Simple on/off would be a good start but ultimately I’d like to be able to control the temperature and brightness via automations throughout the day.
TP Link also has a multi color bulb (LB130) that would also be great to have support for. These bulbs seem like a quality WiFi light bulb that is not that expensive. But I am waiting for home assistant support before purchasing.
Support for the LB130 is now present in pyHS100, so adding support to Home Assistant would be pretty easy. I’ve a few other things to do this weekend, but I’ll take a shot if I have time.
I’m also very interested in getting the light bulbs to work in HA - anything I can hep with?
BUT: I’m unfortunately not a developer, just a very interested user. With the right instructions (where to put py-files in my install and the necessary yaml-code) I could run some tests, though.
Thanks to everybody who’s putting in all this work!
However, there is an error on loading the new platform. I have no clue why: 17-03-12 18:00:34 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step result = coro.send(None) File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py", line 341, in _async_process_entity new_entity, self, update_before_add=update_before_add File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py", line 209, in async_add_entity yield from entity.async_update_ha_state() AttributeError: 'TPLinkSmartBulb' object has no attribute 'async_update_ha_state'
The component needs the github version of pyHS100 (I think the latest release doesn’t have the code for controlling lights): git clone https://github.com/GadgetReactor/pyHS100 sudo pip3 install ./pyHS100/
Nice to see someone working to getting the light support included too! For that error, for some reason homeassistant thinks that the component is an asynchronous one even when it doesn’t define async_update(). Have you been able to locate the problem?
After looking at the flux_led component, I was able to fix that error.
The component works for me now. Brightness, color temp and on/off work on my LB120.
The code needs some work before it can be submitted as a PR. Unfortunately, I don’t have time to do that.
Thanks for this! I was having a hard time getting this working - from pyHS100 failed to import SmartBulb. I’m already using TP-Link switches and didn’t realize that pyHS100 is already installed as a dependency (but it’s version 0.2.3 without support for the bulbs). For anyone else stuck like me… download the latest pyHS100 (0.2.4.1) from git and install into the home assistant deps folder as an upgrade (I’m running on a RPi3 using the virtualenv configuration):
Unfortunately, that doesn’t work for me.
On pyHS100 my config is working fine, as soon as I upgrade to 0.2.4.1, though, I’m getting this error message: ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform tplink
And my TPLink switches disappear from the UI
I haven’t even made any changes to the config yet.
As soon as I downgrade/upgrade my HASS install (pip3 install homeassistant==0.XX.X) - which is the only way I know how to downgrade pyHS100 again - it all works fine again.
The recent updates to pyHS100 may have broken the switch component of HA. Looking at the git log of the pyHS100 repo may help understand what changed. I don’t have a tplink switch and thus I have no incentive to look into this.
Then I figured out that in the same directory that you run your hass command you must do
pip install future
Finally, you must edit /srv/homeassistant/lib/python3.4/site-packages/homeassistant/util/color.py
At the bottom of file it was originally:
“”“Convert degrees to kelvin to mired shift.”""
if kelvin_temperature!=0:
return 1000000 / kelvin_termperature
Simply add one line:
"""Convert degrees to kelvin to mired shift."""
if kelvin_temperature != None and kelvin_temperature != 0:
return 1000000 / kelvin_termperature
And boom, all my old TPLink plugs are there, PLUS my bulbs!
Brightness works, but sadly color does not. But it is better then before.
The backend module doesn’t work if “future” module is not installed, which may be causing initialization problems to some users. Note that this is not directly related to the custom component for bulbs shared in here, just something to note (0.2.4.2 of pyhs100 should fix this).
It would be great to have this directly integrated instead of having it just here, if authors of the code want to push for it I’ll be there to help with reviewing the pull request and helping where I can.