Lifx nodes for Node-Red
An solution to control Lifx lights over local network using Node-Red, uses node-lifx library for communicating with the lights.
This module provides input and output nodes for communicating with Lifx lights, the input node accepts multiple color format and automatically converts the values to the right format.
- Convert input arguments to light specific arguments
- Trigger events for light changes
- Self syncing, uses background polling to detect external changes to light
- Displays current state for light in Node-Red ui
Dashboard example config:
This is an example of how to control the light using the node-red-dashboard
The split node is used to get the
bri payload from the light status message, and the join is used to combine the topic and value to an JSON object.
Wakeup example config:
Simple example of using an inject node to trigger an wakeup light behavior every workday, the light transitions from off to on with 75% brightness over an duration of 30s.
The light is controlled by sending message with an payload containing the new state
Simplified control by sending the following values as payload
||Turn light on|
||Turn light off|
|numeric value||Turn light on and set brightness (0-100%)|
More advanced way to control the light is to send an object payload with one or more of the following properties set
||Set light state (true/false)|
||Set one or more color changel for light (0-255)|
||Set color (#f49242)|
||Set color hue (0-360)|
||Set color saturation (0-100)|
||Set light brightness (0-100%)|
||Set Mired color temperature (153 - 500)|
||Set kelvin color temperature (2200-6500)|
||Transition time (ms)|
Notice: to get the same behavioras the Lifx app when modifying the color temperature you will need to manually set the saturation to zero. This is because the Lifx light can adjust temperature and color independent of each other and I didn't want to limit the choices for the user.
Example: Sending the following to the light will turn it on and dim it upp to 77% over 10 seconds
Example output from change event
Using withouth Node-RED
The MQTT topic
lights will contain an list of all currently detected lights.
Specific light can be controlled by sending an message to the topics
lights/<id>/on (boolean) or
lights/<id>/brightness (number) with the new state.