❗ This software is in alpha so please be EXTRA cautious about exposing endpoints to public. At minimum use Ngrok. We will be providing better instructions soon.
Welcome! Going Light is meant to be used as a status indicator through light, receiving a message with a keyword from a service and triggering a Smart Bulb to notify you...one less message to read and dashboard/screen to context switch to.
The meanings of the lights can be changed to represent different events and statuses. Essentially, the project is used to facilitate communication through light. This means that the devices need to have the ability to change colors and be dimmable.
This projects initial purpose was to indicate stages of code deployments by triggering different light bulb colors through a Kasa TP-Link SmartBulb. The deployment system sent status updates to a Slack channel and a custom slack app was set up to relay the request to an always on Raspberry Pi 2 W running a copy of "Going Light". The Application then maps the message/status to a pre-defined color and performs an API call to the registered lightbulb causing it to display the color for a certain duration.
Created with Flask on a Raspberry Pi 2 W (Or any SBC with Wifi connectivity) to control a TP-Link Smart Bulb via Python Kasa library. Ngrok is used to make the pi available publicly to receive incoming API requests. The application is meant to be running 24/7 so the Pi 2 W was my choice due to the low power consumption when idle and under load.
- "In Progress" triggers a blinking Yellow Light for 25 seconds
- "Fail" triggers a Red Light for 30 seconds
- "success" triggers a Green Light for 35 seconds
- "green" triggers a solid green light
- "laughing" triggers a solid gold "FFD700"
- "on" and "off" will toggle the light
- View more here
- Raspberry Pi Zero 2 W with Raspbian OS with SSH enabled and connected to local network. Other SBCs or Laptop will do.
- Python 3 and pip installed
- Python VirtualEnv
- tmux to run app and ngrok in background
- Already configured TP-Link Kasa smart bulb
- Or a device that can change colors and is dimmable
- A Slack workspace and app
- Phase 2: abstract class for other Communication Apps
- Ngrok
- Sign up, install and set up a static domain to make it easier
- It's important to secure your endpoint
You will be able to select a device connected to your local network. The app will let inform you of any compatible and incompatible devices. Right now it only supports TP-Link Kasa Smart Bulbs. There are plans to support multiple brands.
Install latest raspbian on SD card using Raspberry Imager.
sudo apt update
sudo apt upgrade
sudo apt install python3 python3-pip
sudo apt-get install tmux
- git clone going-light repo:
git clone git@github.com:its-leofisher/going-light.git
cd going-light
pip3 install virtualenv
source venv/bin/activate
pip install -r requirements.txt
This script will create necessary files and perform device discovery. Ensure your device is set up and connected to your network prior to running.
python3 setup.py
gunicorn -w 2 -b 127.0.0.1:8000 app:app
Open a new terminal and start Ngrok to expose your Flask application:
ngrok http 5000
- Follow steps in here
curl -X POST https://your_ngrok_url_here.app/v1/events \
-H "Content-Type: application/json" \
-d '{
"event": {
"type": "message",
"text": "success",
"channel": "CHANNEL_IDS"
},
"type": "event_callback"
}'
When you're ready to leave the application running in the background permanently we will use GUNICORN to serve the app. SSH into the Pi and run these TMUX commands:
SSH into Pi. Start App with tmux command below to run app through gunicorn in background
tmux new-session -d -s appsession "source <path_to_project>/venv/bin/activate && cd <path_to_project> && gunicorn -w 2 -b 127.0.0.1:8000 app:app"
Run Ngrok then Detach Automatically
tmux new-session -d -s ngroksession "ngrok http 8000 --domain=YOUR-DOMAIN.ngrok-free.app
Any events going into v1/events
endpoint will be verified and processed!
Message in payload: Color Mapping
{
'fail': ('#FF0000', True, 30),
'in progress': ('#FFFF00', True, 25),
'in process': ('#FFFF00', True, 25),
'processing': ('#FFFF00', True, 25),
'success': ('#5C214A', False, 35),
'off': ('', None, None),
'on': ('', None, None),
'orange': ('#FFA500', False, None),
'royal purple': ('#5C214A', False, None),
'matcha green': ('#94A796', False, None),
'blue': ('#0000FF', False, None),
'green': ('#008000', False, None),
'yellow': ('#FFFF00', False, None),
'red': ('#FF0000', False, None),
'purple': ('#800080', False, None),
'black': ('#000000', False, None),
'dark green': ('#006400', False, None),
'dark blue': ('#00008B', False, None),
'happy': ('#FFFF00', False, None),
'sad': ('#0000FF', False, None),
'laughing': ('#FFD700', False, None),
'fun': ('#FF69B4', False, None)
}
- Client: OctoPrint Plugin
- Client: Zoom Plugin
- Client: Going Light Slack App
- Source: Philips Hue and LED Strips
- Source: Kasa Switches and LED Strips
- Source: Homeassistant
Open to code contributions, bug reports, and new ideas
To report a bug:
- Make sure that it can be replicated at least 65% of the time
- Open a new issue and add as much detail as possible
For New Ideas:
- Start a discussion here
To contribute code:
- First make a ticket with a description of contribution OR pick up a ticket already open
- Make a fork of
Main
branch - Create a new branch and start committing
- Important to adhere to Zen of Python "PEP20" and PEP8
- When you're ready, make a PR against
dev
branch - Tag @its-leofisher as reviewer and update the ticket for visibility
Remember not all contributions will be accepted, it depends on the scope of the project, there will be some back and forth as with all contributions.