sagacious-solutions / alexa-holiday-lights

An Flask Ask server to control a set of RGB Holiday Lights with a Raspberry Pi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alexa Holiday Lights

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.

To Get Running

  1. Create an Alexa Skill in the Alexa Dashboard.
  2. 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
  3. Install the required libraries sudo pip install -r requirements.txt
    • Requirements must be installed as sudo as the service wil run as sudo
  4. 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
  5. 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

A note about security

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.

Current Skills

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

Hardware

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.

RGB Lights

This code will work with any ws281x RGB lighting strip thats a single line of LEDs.

Pinout

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/

About

An Flask Ask server to control a set of RGB Holiday Lights with a Raspberry Pi


Languages

Language:Python 99.4%Language:Shell 0.6%