Tp-link bulbs LB100, LB110, and LB120

Has anyone tackled the issue of the brightness slider not working properly? I’m using LB100 lights and if the brightness slider is moved at all, it drops to zero and the the light’s brightness cannot be increased above about 1% without going to the mobile app (Kasa) or having Alexa change the brightness back to 100%.

Am I the only one experiencing an issue with the brightness slider or is it a known issue?

[EDIT] I found that the bulb in question that wouldn’t reset to full after toggling off & on was due to the fact that I had deleted it and re-added it to Kasa and forgot to change it to power on at 100%. The brightness slider is just not working properly. I also noticed the post just before mine, posted by anndrewww, reported the same issue.

1 Like

I just upgraded to 0.48.0 and have been working ALL DAY to try to get my TPLink bulbs working again. They worked with 0.47.1 with pyHS100 0.2.4.1 but now the best I can install is pyHS100 0.2.4.2 (don’t know how to get the 2.4.1) and the lights/tplink.py file crashed with 2.4.1 dependency. I changed the requirement in the file to 2.4.2 instead and it’s still crashing.

Now I get the following:

2017-07-02 21:02:12 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=4 from 2017-07-03 01:22:22.389183)
2017-07-02 21:02:24 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 233, in _step
result = coro.throw(exc)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 212, in async_add_entity
yield from self.hass.async_add_job(entity.update)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/light/tplink.py”, line 97, in update
from pyHS100 import (SmartBulb, SmartPlugException)
ImportError: cannot import name ‘SmartPlugException’
2017-07-02 21:02:24 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 233, in _step
result = coro.throw(exc)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 212, in async_add_entity
yield from self.hass.async_add_job(entity.update)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/light/tplink.py”, line 97, in update
from pyHS100 import (SmartBulb, SmartPlugException)
ImportError: cannot import name ‘SmartPlugException’
2017-07-02 21:02:24 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 233, in _step
result = coro.throw(exc)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 212, in async_add_entity
yield from self.hass.async_add_job(entity.update)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/light/tplink.py”, line 97, in update
from pyHS100 import (SmartBulb, SmartPlugException)
ImportError: cannot import name ‘SmartPlugException’
2017-07-02 21:02:25 WARNING (MainThread) [homeassistant.setup] Setup of climate is taking over 10 seconds.
2017-07-02 21:02:25 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 233, in _step
result = coro.throw(exc)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 212, in async_add_entity
yield from self.hass.async_add_job(entity.update)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/light/tplink.py”, line 97, in update
from pyHS100 import (SmartBulb, SmartPlugException)
ImportError: cannot import name ‘SmartPlugException’

Edit tplink.py and change line 97 and 103: Replace from SmartPlugException to SmartDeviceException

So the block should now read as:

def update(self):
    from pyHS100 import (SmartBulb, SmartDeviceException)
    """Update the TP-Link switch's state."""
    try:
        self._state = self.smartbulb.state == \
            self.smartbulb.BULB_STATE_ON
    except (SmartDeviceException, OSError) as ex:
        _LOGGER.warning('Could not read state for %s: %s', self.name, ex)

Looks like SmartPlugException was removed and replaced with SmartDeviceException in pyHS100. See here: Merge pull request #61 from rytilahti/master · GadgetReactor/pyHS100@b7a7fdb · GitHub

2 Likes

Thanks, I remoted into my home PC while at lunch today at work and made the above changes and confirmed after restart that the lights now show up in the browser and I successfully toggled one of the lights on.

Now to remark out the “Upgrade:” in my config so I don’t get the upgrade popup anymore!

Well, that halfway fixed it but there’s still an issue with color.py that the original kelvin to mired fix doesn’t work now.

Adding the IF statement to the last routine on color.py (in /srv/homeassistant/lib/python3.4/site-packages/homeassistant/util) now gives an error about indenting and I’ve played with the indent and can’t get it right.

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

I get a ^ under the colon on the if statement and the error says:

File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/util/color.py”, line 400
if kelvin_temperature != None and kelvin_temperature != 0:
^
TabError: inconsistent use of tabs and spaces in indentation

I got it finally. Just took the changes completely out and added it in carefully, paying precise attention to the spaces and it works now.

This is what I use for color.py and yes spacing matters.

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

Hi!

So I was about to dive in, but at this point I’m not sure where to start? What should I clone from which repo? Where do I put the files I clone? Who am I? Where am I? :slight_smile:

Thanks!
-Chad

Getting homeassistant.loader] Unable to find component light.tplink

I was mistaken, you do still need to update the /light/tplink.py file with the changes mentioned above.

I have a version of tplink.py based TheRealNate’s git version, which had a bug for me around the color_temp stuff. I put the above suggested fix for null/non-zero color temp in tplink.py itself (which was where the bug was) so as not to have to change color.py (which could impact lots of other light components). I have also made the code pass tox/lint tests, updated requitements_all.txt appropriately and done the documentation for it. This works for me testing my LB110 so I can’t test colour. I’m keen to just get this pull request into HA proper and further bugs we can address from there. Any concerns, suggestions or additions to the version from TheRealNate’s?

2 Likes

@gollo Thanks for doing that, it’s great to get it also integrated properly!

I wanted to give you a heads-up that I have been doing some ground work to get both plugs and bulbs detected automatically from the backend library. My hope is to make a full component with autodetection for both types of devices currently supported when I find some time for it.

2 Likes

Ok cool, that sounds good. I’ve raised https://github.com/home-assistant/home-assistant/pull/8643 so hopefully we’ll get this version in 0,50 and it will be easier to fix/move forward with.

3 Likes

This has been merged so look out for it in 0.50.

3 Likes

On/Off appears to be working great! Thanks! But I’m not able to “tune” white to any other color, and dimming also appears to not be working. Similarly I cannot control any color on the LB130 bulbs.

I have 2 LB130, and 1 LB120.

I’m not sure what logs to post, so any help in where to look would be great.

Thanks!
-Chad

Edit - I’m running HA 0.50.1 (according to .HA_VERSION)

I’m also having issues with dimming: changing the brightness results in the bulbs going to their dimmest setting no matter what you do with the brightness slider in HA.

I installed the TPlink component before 0.50.1, not sure if I’m using the version packaged in that or the old one.

Are you seeing any errors in the log?

No errors, other than
2017-08-01 20:38:55 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting

I’m not sure why you’re seeing that behavior. Have you tried using the tplink component included in 0.50? I installed it and then made the update to replace “SmartPlugException” with “SmartDeviceException” as instructed earlier in this thread.

Has anyone had any success attempting to implement color with this component yet?