Cheap HomeKit LED Strips

Cheap HomeKit LED Strips

After my success with Homebridge and LIFX I wanted to get some more HomeKit compatible lights for my house. LED strips provide an easy way to hide versatile and flexible lights away and make the perfect mood lighting. Philips Hue already offer LED strips with LIFX's "Z" strip coming in November but there was no way I was gonna drop £70 a few LEDs.

Philips Hue LED Strip

Granted that's for a 2m strip but I'd guess most people don't have a 2m surface to tuck one of these behind. In my case I wanted to stick it to the back of the TV which for 42 incher is around a metre.

When you compare that to 5m of generic RGB strip from eBay it really doesn't feel like a good deal for the Hue or LIFX strips.

Cheap eBay Strip

LED Controllers

It turns out there are a ridiculous amount of Wi-Fi and Bluetooth controllers floating around for LED strip lights. In order to interface with Homebridge the controller needed to be Wi-Fi. Amazon has a lot of these things but I went for one of the cheapest at £13.99 with some great reviews — the aptly named XCSOURCE DC 12-24V iOS Android WIFI Remote 5 Channels Controller For RGB LED Strip LD686.

My controller supported 12 and 24v strips, red, green, blue, cool white and warm white (though that did cause me some headache in the HomeKit integration but we'll get to that later). Other controllers only support RGB or RGBW so it's worth checking what your strip has/requires. Most seem to either be RGB, a single colour or white.

It's a tidy little thing that can easily be tucked away neatly. I didn't realise that it doesn't come with a power supply so ended up paying over the odds for one at Maplin. If you're buying your controller on Amazon chuck something like this adaptor into your cart too.

Magic Home Wi-Fi

The controller (like most of the other rebranded generic ones on Amazon) connects to an app called "Magic Home Wi-Fi" (or other identical apps with different names by the same developer).

To setup the device you first connect to the Wi-Fi network that the LED controller broadcasts and the app will walk you through setup. It turns out though that my controller also has a web server that probably should have been disabled. The username/password is admin / nimda and within the panel settings for the SSID that's broadcast as well as the router its connected to can be changed without using the Magic Home app.

Shhh Secret

Another secret screen

The app itself is okay… It does a job but I wouldn't want to use it regularly. It's pretty slow to load and searches the network for devices every time rather than store the MAC address like LIFX. There is a remote web service that enables the lights to be controlled by the Amazon Echo out of the box but everything is sent over plaintext (including your password) to some outdated IIS server in China… So trust that at your peril.

Wiring Up

Before I started on the HomeKit integration I wanted to ensure everything worked. I'd picked up a metre of LEDs from Maplin for about £8 — not the cheapest but I didn't have to wait for it along with some thin wire.

I first soldered up the wires to the RGB and 12V contacts on the LED strip. Don't laugh at my shoddy workmanship here, it's the first time I've touched an iron in 5+ years and I still ended up cooking part of my hand.

Soldered up

@djekl actually pointed me in the direction of some connectors that require no soldier so I'll be picking some of those up from eBay for the next time.

Then it was just a case of screwing the wire in to the controller at the other end.

Wired up

At this point I had to go out and buy an overpriced power adaptor and snip the end off. If you don't know which wire is positive/negative look for one with a solid white strip or dashed like that will be positive. Or to be extra safe use a multimeter.

Everything working

HomeKit Integration

By using a combination of Charles and Wireshark I'd been able to figure out that communication with the controller over a local network is done via port 5577 over TCP. The Magic Home app sends a combination of hexadecimal commands to get the status, power on/off or change colours/modes.

I managed to send a power on/off command by sniffing the command sent by Magic Home and replicating that via a node.js net socket. After doing a bit more I found a couple of libraries on Github and a couple of other people had done some hard research and figured out the majority of the API. It looks like all of those generic LED controllers as well as several generic LED lightbulbs are made by a company called Zengge who flood Alibaba with the devices. You can see the devices the Magic Home app uses in its help section.

Compatible devices

The two packages I tried were:

Both of them could successfully power on/off the device and retrieve a status but neither successfully changed the devices colour. The reason is because the controller I bought is the only one created by Zengge to support cool white (CW) and warm white (ww). All other devices only support a single white.

Once I'd modded the flux_led.py to send a secondary blank white byte everything worked perfectly. I'd already started on my Homebridge plugin and had got the LED strip registered with hue, saturation, and brightness characteristics. I contemplated keeping everything in node but decided against spending the extra few hours and instead just spawned a fork and executed commands via the modded flux_led.py script.

If you want to give the plugin I made a go I've put it up on GitHub. If I get a chance I might add an option to enable/disable the extra white value so it works with all Zengge devices.

The last thing I needed to do was hook this new plugin into my Pi Zero Homebridge and check everything worked. I added a new accessory to my config.json file and rebooted the server:

"accessories": [
       {
           "accessory": "MagicHome",
           "name": "LED Strip",
           "ip" : "192.168.1.111"
       }
]

Finally, to stop that IP changing I assigned it at my router to the MAC address. Alternatively I could have done it via that secret web server but I don't know how much I trust it.

Demo

And here's what it looks like and how you control it! I'm over the moon with how it turned out and being able to automate this so it turns on when I walk it, set scenes for movies etc. is just magic.



And here's what it looks like tucked away behind my TV. Not the neatest but nobody looks behind there 😉

Tucked away behind the TV

Shopping List

Okay, if you want to make one of these here is what I'd recommend you buy:

  • LED Strips - These are pre-wired and come with a power adaptor. Chop the end of the adaptor and the connector for the LED strips off and you can wire them into your controller.
  • LED Controller - This is the controller I bought and it works perfectly with the Homebridge plugin. Alternatively go for another Magic Home controller and use the original flux_led.py script instead of my modded version.
  • LED Strip Connectors - These will enable you to cut the LED strip to wrap easily around corners without (burning yourself) soldering.
  • 0.2mm Equipment Wire - If you want to buy 1 LED 5mm strip and connect to multiple controllers then you'll need some of this to attach into your LED strip connectors.

Total cost: ~£22 - Far cheaper than the £70 Philips wanted for just 2m of LEDs.