Contents

Syncing A Smart Bulb with a Looping Video

The Call with Problem Statement

I got a call over my lunch hour one Thursday from my daughter:

I have an art project. I need a part of it to light up, in purple, on a timer, in sync with a video. The lighting has to fit in a space that’s 24" x 10" x 3". I need it for Monday.

Having seen installations everywhere, and many projects online, I’d been wanting to play around with programmable lighting, but had never found an application, and I just got the call. There are a ton of colour LED systems out there. Seemingly all of them driven are driven by phone apps or smart home ecosystems. My expectation was that most of these apps would have pre-programmed effects, and wouldn’t be able to run a timed pattern - it was hard to tell without buying them and testing their capabilities.

LED Strips

I started with a ws2812b strip and power supply, knowing that there was lots of code out there. I started out trying to control it with a Pi Pico - I’d read that the ws2812b LEDs can work with the 3.3V data signals used by the Pico, but I wasn’t able to make it work - I’ll have to try another time with a level shifter. I dug a little bit deeper into my project boxes, and found a classic Arduino UNO. Using the FastLED library, the sample code was up and running in no time.

Smart Bulbs

I then started looking at smart bulb options - what a mess. There are wifi controlled bulbs and Zigbee bulbs. For my use case, wifi was sufficient, and saved me the cost of a Zigbee hub. I’d start with an Amazon search for coloured smart bulb, followed by Google searches of: ‘bulb brandname’ python reddit. All these people, posting about their smart bulb reverse engineering experience: “I’ve been running wireshark between the app and the bulb, I can’t figure it out”, and no one reporting “I got it working”.

EXCEPT Philips’ (now Signify) WiZ Connected.

The WiZ system is so awesome - there is no need for a phone app or cloud connectivity to control these bulbs. They can be controlled from a command prompt using netcat - Sean McNally has created a great web tool where you define what you want the WiZ bulb to do with a few clicks, and it spits out it spits out a netcat command to do the thing. For example, to turn on the bulb green:

1
echo -n "{"id":1,"method":"setPilot","params":{"r":0,"g":255,"b":0,"dimming": 75}}" | nc -u -w 1 192.168.2.126 38899

And because it’s a standard consumer product, you can pick them up at at Home Depot - beside all the other offerings that seem to require phone apps and cloud connectivity.

The Solution

We created some code to control both the ws2812b LED strip and the WiZ bulb. My daughter preferred the effect provided by the bulb. I ordered a cord with an E26 light socket, which allowed her to mount the light within her project and provide power to the bulb.

Solution Components

We used a Raspberry Pi 4 to control the bulb and playback the accompanying video on a projector. The bulb would connect to the Pi 4, which we configured as a wifi hotspot.

A python script would start the video, playing it back with the VLC media player, which was controlled with the python-vlc library. The bulb’s colour was set, and faded on and off, using the pywizlight library. I’ll post the script here in a subsequent update - for now, it resides on the Pi 4 in the gallery.

I was very pleased with the result. You can see a video of the installation on YouTube.

Completed Art Installation with Smart Bulb