Tp-link bulbs LB100, LB110, and LB120

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.

1 Like

I’m looking to do the same and can’t seem to get it to work with HASS. Like you said, I have it working with the Amazon Echo, Alexa.

Does anyone know how to get this working?

I have a PR up against pyHS100 at https://github.com/GadgetReactor/pyHS100/pull/30 that adds support. It should be pretty easy to add a light component that makes use of that.

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.

Hey @mjg59 did you get this working? I ended up getting a bulb to mess around with and would love to get it added into HASS. Cheers!

Didn’t have time, I’m afraid - I’ll try to get to this in the near future, but anyone else should feel free to as well.

@mjg59 Thanks for the info! I’d love to do it myself but I know just enough Python to be dangerous and absolutely jack about HASS development.

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!

Hey all, any update on this?

I made some progress on a TPLink light component:

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?

1 Like

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.

Here are the steps to get the component running:

  1. copy tplink.py to components/light/
  2. Add a config entry. Here is an example entry:
light 4:
  - platform: tplink
    name: tplinkroom1
    host: 192.168.1.234
2 Likes

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):

cd ~
git clone https://github.com/GadgetReactor/pyHS100
pip3 install --upgrade ./pyHS100/ --target ~/.homeassistant/deps

Then aa755’s latest steps work.

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.

Any hints?

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.

Ok. Here is 100% fix:

First use the code from @aa755 (thanks):

Put it underneath components/light/ then config it as you would a light (IP, Name, and Platform)

Next, as @buzzeddesign said (thanks):

cd ~
git clone https://github.com/GadgetReactor/pyHS100
pip3 install --upgrade ./pyHS100/ --target ~/.homeassistant/deps 

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.

1 Like

Thanks Nate,

just went through the painful process and figured it out myself - couldn’t you have posted 2h earlier :wink:

Still, the last change

def color_temperature_kelvin_to_mired(kelvin_temperature):
    """Convert degrees kelvin to mired shift."""
    if kelvin_temperature!=0:
    return 1000000 / kelvin_temperature

doesn’t make lights show up.
Any other trick you applied?

Nope, are there any errors you see when starting HASS?

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.