HomeKit for Any Smart Device
Sure, they’re not as premium as LIFX; the colors aren’t as vibrant, and they emit an audible buzz in the bathroom, but for $10 a pop, they’re a pretty unbeatable value.
The main issue, though, is that they don’t have HomeKit support. They’re not entirely dumb—they work with Google Home, Alexa, IFTTT, and the manufacturer’s app. They’re fine for someone who only has TECKIN smart bulbs.
However, because you can’t access them from HomeKit, you can’t control them from the Home app, the widget in Control Center, or Siri. You also can’t include them in scenes with bulbs from other brands or use them in Automations. If you’ve already invested in HomeKit, this is most likely a dealbreaker.
Meet Homebridge
Luckily, there’s a hack that makes these particular bulbs much more useful. The HomeKit API allows devices called bridges, like this one from Philips Hue, to connect child devices that operate on other protocols. You simply add the bridge as a device in HomeKit, and it registers each light connected to it in HomeKit. Whenever you make a request to update a light, your phone talks to the bridge, and the bridge talks to the light.
So, a bridge just relays information from one API to another. Because you can control the TECKIN light bulbs over the internet, it’s entirely possible to connect them to HomeKit with just software—no proprietary hardware is required.
If you’ve got a Raspberry Pi laying around (a $5 Pi Zero is fine), you can set it up as a bridge with a framework called Homebridge. This lightweight, NodeJS application emulates the HomeKit API and forwards requests to your non-HomeKit smart devices.
Basically, you run it on the Pi, and it adds each ‘dumb’ device to the Home app. When you try to control the bulb through the Home app or Siri, Homebridge talks to the devices for you. After you set it up, it’s just like the device had HomeKit support in the first place.
This requires that the device runs Homebridge at all times, so this isn’t something you would install on your laptop. A Raspberry Pi is ideal, but if you’ve got an old device you can repurpose as a server or desktop that’s always running, you can install it on there.
Homebridge is a framework, and you can extend it with plug-ins. It has a fairly large community backing, so there’s a good chance any given smart device probably has a Homebridge plug-in to add support for it. If your device doesn’t have a plug-in, but your smart device has an API, and you’re tech-savvy, you can write one yourself.
For most people, though, the setup is just installing Homebridge and the brand plug-in for the device, along with a bit of configuration. If you can use the command line and have a bit of time, it’s fairly easy.
Installing and Configuring Homebridge
Homebridge is a NodeJS app, so you have to install node and npm to use it. If your machine runs Linux, you can probably get it from your package manager.
On Ubuntu, you have to type the following to set up the Node repo manually, and then install nodejs:
Otherwise, you can consult Node’s download page for information on how to install it for your particular OS.
If you’re on Linux, you also need to install some dependencies, as shown below:
Afterward, you can install Homebridge globally through npm, as shown below:
You also want to install the brand plug-ins you need, as Homebridge is just a framework. For the TECKIN bulbs, for example, the plug-in is homebridge-tuya-web, which also installs globally.
You would type the following:
After everything’s installed, you can actually use the thing! Type the following to run Homebridge once and initialize everything:
It will complain about a lack of configuration, which you have to create. The default directory is ~/.homebridge/, but you can use the -U parameter if you want to move it.
Type the following to create a new JSON configuration file in this folder:
Regardless of the plug-ins you use, you need the following basic configuration:
This configures Homebridge with a default port, name, PIN, and port range available to allocate to other devices.
Inside the empty platforms array, you place the configuration for each plug-in. You should be able to find instructions and examples of this on each plug-in’s GitHub page.
In the example below, the homebridge-tuya-web plug-in for the TECKIN bulbs wants to know my username and password to connect to the API for the bulb’s app, and a few other things:
Once that’s all configured, Homebridge should be ready to go. Run it again, and your terminal should display a giant QR code that might force you to zoom out. Scan this with the Home app to add it and all connected devices to HomeKit.
Homebridge loads your plug-ins and should log a message to the screen for each device it finds. You should see them all in HomeKit after they’re added, and they should be fully functional.
I did notice a slight delay compared to my LIFX bulbs. This is probably because the bulbs are controlled over an API rather than directly. At first, the bulbs also didn’t display some whites and warm whites correctly, but after a bit of tweaking, I was able to set up proper scenes.
You can always configure the devices in their own apps, wait for the Home app to update, and then set the scene in HomeKit with the premade configuration.
If you need to re-add Homebridge, you’ll want to delete the persist/ folder in the config directory, and then remove the bridge from HomeKit from the settings of any connected bulb under the “Bridge” tab.
Adding Homebridge as a Service
If you want Homebridge to run all the time, you’ll probably want to configure it to restart if it crashes or if your Raspberry Pi restarts. You can do this via a Unix service. Set this up after you’ve verified Homebridge is working as intended.
First, add a new service user, called homebridge:
Set a password:
Next, you’ll have to move the homebridgeconfiguration outside your personal home directory. /var/lib/homebridge/ should be fine:
Make sure the person using homebridge has ownership of that directory and all subfolders:
Once that’s done, you can create the service. To do so, create a new file called homebridge.service in /etc/systemd/system/:
And then paste the following configuration:
Reload the services daemon to update it with your changes:
Now, you should be able to enable your service (setting it to run at boot):
And start it:
If you need to debug errors that arise from the service configuration, you can view the logs for the service by typing: