I wrote a script so HA can automate provisioning tp-link Kasa/Tapo bulbs and plugs

Title says it all, but basically, I got annoyed that I had to either get the app, connect wifi and tap a bunch of buttons or run a bunch of commands on a laptop and connect to wifi networks to provision the bulbs, set the presets, the wifi, the name, the soft and hard power on behaviors, etc.

So I wrote a script you can paste and run in the SSH addon to HassOS, and it creates a venv, installs the necessary python deps, scans for and connects to the requisite wifi network (assuming you’re using ethernet or have an unused wifi adapter) and does all the provisioning actions for you, including setting up the WiFi network.

It really is a single line execution: flick the light switch 5 times and run ./provision_bulb.sh "Office Lamp" and it does the rest and spits out the new IP for you to drop into HA.

Just wanted to share that it’s very possible, and if other people are interested I could clean it up and share it, and make it a little more configurable.

I’d considered making an add-on for this, and you still could, the supervisor api has all the necessary control surfaces to do the wifi scanning, but this was a PoC, and frankly a dedicated always installed add-on felt like overkill for what is really an occasional need.

People have also written blueprints to do this.

If you don’t share this in some way it is odd to post this here, however.

That’s why it says specifically:

The implication is it’s not in a state to be shared as-is, (embedded secrets, hacks, not extensible, etc) and if there’s not interest, as you say since there are apparently blueprints available, I won’t put in the effort to do so. I wasn’t aware of the blueprints for it, but thanks, I’ll take a look at them.

That said, I’m doing some searching for those blueprints and not finding them on the community or reddit, if you have a recollection of any specific terms to search or posts, or which platform you remember seeing them on I’d be interested in taking a look.

Put this into a search engine:

site:community.home-assistant.io blueprint zigbee reset

Or refine it as you like…

I’m guessing you’re talking about the WiFi bulbs, eg KL125/KL135?

I quit using Kasa/Tapo because they’re a pain with being blocked from the internet. Although they do have a firmware they’ll push to your device to fix it, that took literally months to get them to admit it and follow through with the push.

That said I think the script is a nice idea. It is quite a few steps to muddle through if you’re not doing it often. If you get it to the point where you’d share it, I’d encourage you to do so. It’ll help someone.

Ah, I see the misunderstanding. Tplink kasa and tapo don’t make zigbee or Bluetooth bulbs. These are their wifi bulbs that require finding and connecting to their custom access point, and installing using either their app, or locally with a python library or CLI to interface with their local API to set them up (name, presets, wifi network etc), I haven’t seen any automation of that kind so I don’t think this is duplicative.

1 Like

Yep the wifi kasa/tapo bulbs. I haven’t disconnected mine from the internet explicitly just run them on the isolated IoT vlan, I’ve been slowly working through devices to fully de-cloud them and they’re on the list somewhere, but my main priority is that they work when my Internet is down, and I’ve never had any issues with mine during various internet outages over the years, but never anything protracted. The rest of the de-clouding for me is ideological and who has time for that with kids :joy:

I’ve got some KL125 and a few KL135.

For 125s were the problematic ones. They worked great for local control, but if you block them from the internet they reset every 10 minutes and are down for 30-60 seconds. They required the firmware update. Here’s the story on that, and there’s a link to the uplink forum where I learned about the firmware that they finally gave me.

So far, I believe the 135 are still on the firmware they came with and don’t seem to be presenting the same issue being blocked.

I also have a Kasa power strip that seems to be working being blocked. However the plug I have started self assigning an IP on a different subnet range after months of seemingly working fine. It would fix it I unplugged it, but I got tired of it and replaced it with one I’d flashed with ESPHome.

For the cost, they are the best smartbulb I’ve found, I’d just prefer something that I can lock down without the negative side effects.

1 Like