Physical control of LIFX lights using a local Python server and an Arduino.
- Install python 2.7
pip install -r requirements.txt
python lifxlancontrol.py
With the default configuration, head to YOURSERVER:7990/lights
in a browser to poll for lights on your LAN and save them in a cached dict.
Also displays current label, IP, mac and color settings for any lights found.
POST form_data
to the same address with either mac=aa:bb:cc:dd:ee:ff&ip=192.168.x.x
or light=LIGHT_NAME
-
No other flags: toggle the light on and off
-
on/off:
level=on/off
- turn the light on or offlevel=full
- turn on the light at 100% brightness
-
Brightness:
dim=up/down
- increase/reduce brightness by 10%dim=true
- continue previous dim up/down (best guess if no previous found)
-
Light temperature:
white=warm/cool
- lower/raise light temperature by 500kwhite=nnnn
- set light temperature tonnnn
Edit LANSwitch.ino to set:
-
Your Wifi credentials (lines 8 and 9)
-
IP address, gateway and subnet of your arduino (lines 34 to 36)
-
Python server IP and port (lines 13 and 14)
-
Name of light to control (line 16)
Please Note: the server values are not currently used in the http calls. Find/replace all references to YOURHOSTIP
(lines 79, 93, 115) and LIGHT_NAME
(lines 81, 95, 118)
Thanks to salsaman for the multi-function button code
- Flash code onto the arduino
- Connect a momentary button between
buttonPin
and ground
- single click toggles light
- double click (tricky to get) sets light to 100%
- hold dims
Optional additional steps:
- Remove an existing light switch
- Wire the fitting to permanent live (if permissible by building regulations where you live)
- Wire in a 5V USB port behind the switch (if permissible by building regulations where you live)
- Shave the edges off your arduino board to fit it in the back box (so close to the perfect size)
- Connect a nice looking momentary switch
- Screw it all back together