Interactive controller for Broadlink smart bulbs
Super Bulb is a personal project that lets you control a Broadlink smart bulb.
Currently it supports on/off, brightness, transition durations, color mode and interactive mode (integration with microphone in the browser).
Super Bulb has 2 main parts:
- The controller - a client side built with React.
- The server - a websocket server built with Python.
The controller passes commands to the server through a websocket connection and then the server processes and passes the commands to the smart device via the Broadlink Python package.
In order for Super Bulb to work you need to make sure that the controller can communicate with the websocket server, and that the websocket server is hosted in the same network of the smart device.
In other words, it means that you can host the controller anywhere you want (on your computer, on a Raspberry Pi or even on the internet) - as long as the contoller <-> server <-> bulb
communication is properly set.
Personally I host the websocket server on my Raspberry Pi and I use Twingate
zero trust network - this setup lets me use the controller from anywhere I want in the world - even outside of my home Wi-Fi.
In order for the interactive mode (microphone integration) to work from your phone the setup is a bit more complex. Since the browser allows microphone access only from localhost or a secure connection (HTTPS).
You can deploy the controller on the internet (with HTTPS) but then you cannot access the websocket server since the browser will not allow you to access an unsecure websocket server from a secure connection.
In order to bypass this you need to setup a secure connection in both the client and the server.
This video explains how to set it up.
Basically you'll have to:
- Register a domain via a domain registrar and add DNS records.
- Setup
Nginx Proxy Manager
.
Simply add the following DNS records:
Record Type | Name | Content |
---|---|---|
A | pi | your internal IP |
CNAME | *.pi | pi.yourdomain.com |
Follow these steps:
- Set up Nginx Proxy Manager via docker (quick setup guide) and open the browser on the host machine on port 81.
- Add SSL certificate:
- Go to
SSL Certificates
=>Add SSL Certificate
. - Add
pi.yourdomain.com
and*.pi.yourdomain.com
as your domain names. - Toggle on
Use a DNS Challenge
. - Add your DNS provider and provide a relevant API token.
- Agree to Let's Encrpyt terms.
- Go to
- Add controller proxy host:
-
Go to
Hosts
=>Proxy Hosts
=>Add Proxy Host
. -
Add Domain name
bulb.pi.yourdomain.com
with the following properties:Scheme NameForwar Hostname / IP Forward Port http host ip (192.168...) 8080 -
Go to
SSL
tab and add the certificate we created at step number 2. -
Toggle on
Force SSL
andHTTP/2 Support
. -
Save.
-
- Add websocket server proxy host (almost the same as the previous step):
-
Go to
Hosts
=>Proxy Hosts
=>Add Proxy Host
. -
Add Domain name
bulb-server.pi.yourdomain.com
with the following properties:Scheme NameForwar Hostname / IP Forward Port http host ip (192.168...) 6543 -
Toggle on
Websockets Support
. -
Go to
SSL
tab and add the certificate we created at step number 2. -
Toggle on
Force SSL
andHTTP/2 Support
. -
Save.
-
This setup will let you access the controller and the server through the subdomains you defined in the Nginx Proxy Manager
with SSL
.
The easiest way to get Super Bulb up and running is with docker.
First you'll have to clone the repo:
git clone https://github.com/NivEz/super-bulb
Simply execute:
docker compose up -d
You can run it directly without docker as well:
- Run the controller:
cd client
yarn dev
- Run the websocket server:
cd server
python websocket.py