TP-Link KL125 hack

I recently acquired some TP-Link KL125 bulbs without realizing that they aren’t supported by Home-Assistant. After digging into the rabbit hole, I found they don’t work due to a divide by zero error caused by no definition existing for the color temperature.

  File "/usr/src/homeassistant/homeassistant/components/tplink/", line 248, in attempt_update
    self._light_features = self._get_light_features()
  File "/usr/src/homeassistant/homeassistant/components/tplink/", line 289, in _get_light_features
    min_mireds = kelvin_to_mired(min_range)
  File "/usr/src/homeassistant/homeassistant/util/", line 515, in color_temperature_kelvin_to_mired
    return math.floor(1000000 / kelvin_temperature)
ZeroDivisionError: division by zero

This is of course a bummer. Then I discovered there was actually a PR to fix it submitted here: It wasn’t merged however though because pyHS100 has been abandoned in favor of the python-kasa fork. Unfortunately though Home Assistant uses pyHS100 at this time, not python-kasa. With a one line change the bulbs work with pyHS100.
I’ve submitted a request to try to get a new release spun for pyHS100 here:

However in the interim, I wanted to share how someone else can use this.

  1. Clone HA repo somewhere
  2. Check out the tag matching the release you’re on.
  3. Copy the entire directory for homeassistant/components/tplink into custom_components
  4. Replace the requirements section for the manifest.json with the following content
  "requirements": ["git+"],

This will have it check out my branch I submitted the PR for and install it to use with the custom component. It isn’t pretty, but it at least works for now.

1 Like

I have been using modifications to my docker compose file (since that is how I run HA) in order to overwrite dependency folders, that way there is no custom integration to add, and when the dep does get upgraded, all I have to do is remove a single line of code before I update HA

like so:

      - /var/homeassistant:/config
      - /var/homeassistant/custom_deps/[Dependency]:/usr/local/lib/python3.8/site-packages/[Dependency]

That seems like a pretty good idea if you aren’t using Home Assistant operating system.

Anything change recently? This worked for me last week and I just did a Home Assistant update and its no longer working. I attempted to remove the custom component and retry but I am unable to get in contact with the KL125 bulbs anymore through Home Assistant. Tried several times.

Still working for me as is - but I have a cleaner way incoming.
Avoid divide by zero errors in tplink light integration by superm1 · Pull Request #48235 · home-assistant/core · GitHub

You can apply that instead to your custom component until you upgrade to a release it merges to.

My pull request was accepted and is part of 2021.4. so upgrade to that and you can drop the hacks.

1 Like

Thanks, I upgraded and was able to get it working again. I needed to factory/power reset the bulbs and then they showed up again. I could never get them to show up with python-kasa. Wanted to see if that did a better job of not turning the lights blue for a split second when you shut it off.

I’m having an issue where when I toggle the lightbulbs it says call service light turn on failed. But the lights turn on. This is an issue because when I try and use the lights turn on call service in an automation it doesn’t work. Do you have this issue?