This is a repository for my holiday light string. Utilizing a Raspberry Pi and a ws281x RGB Light string, we are able to create a voice controlled set of lights.
- Create an Alexa Skill in the Alexa Dashboard.
- For the skill endpoint, point to an address for the Raspberry Pi
- I did this using cloudflared tunnel as it allows free DNS tunneling
- ngrok is much faster and easier for development
- Install the required libraries
sudo pip install -r requirements.txt
- Requirements must be installed as sudo as the service wil run as sudo
- On the Raspberry Pi, install PM2 to daemonize the alexa service
- You will need to install Node JS prior to pm2
- You can daemonize it anyway you like, if you don't though the service will be lost on reboot
- Set and forget the service
- Set the service to run a boot.
- Make sure the service runs as sudo, otherwise it will error out as it won't have hardware level access
If doing this you should understand your network security. I recommend putting the hardware in a VLAN thats firewalled off from the rest of your network or isolating the hardware in your routers DMZ.
Invocation Phrases | Intent in Alexa Dash | Loop Function | Function Called / kwargs |
---|---|---|---|
turn off lights | turnOffIntent | No | light_string.setSolid, {"color": LedColor.black} |
Start Rainbow Chase | setRainbowChaseIntent | Yes | light_string.rainbowCycle |
start slow color changing | slowRandomTransitionIntent | Yes | light_string.transition_to_random_color, {"wait_after_transition_ms": 1} |
solid random colors | solidRandomIntent | No | light_string.random_colors |
Current hardware is a Raspberry Pi 4 running off an NVMe SSD on USB3.0 for rapid prototyping. However once development is complete it will be moved onto a Raspberry Pi Zero 2.
This code will work with any ws281x RGB lighting strip thats a single line of LEDs.
The RBG signal string is connected to pin12 (GPIO 18) to use the PWM Channel for control. If not using a Raspberry Pi 4, you will need to check for a signal channel available on the device you are using.
Image source https://pinout.xyz/