This node takes in a starting color and brightness and slowly changes them to meet an ending color and brightness.
This project is based on node-red-contrib-looptimer-advanced and some extra code to slowly change the brightness and color of a light over a programmable time.
This node was created to help with lights in Home Assistant that don't work with the built in transition command. The node will output a msg.payload
containing:
{
"brightness_pct": <1-100>,
"brightness": <1-255>,
"rgb_color": [<0-255>,<0-255>,<0-255>],
"color_temp": <Integer>
}
that can be used with a call service node to incrementally change the color and brightness of the light.
npm install node-red-contrib-light-transition
This node can be configured manually or by passing it a specific payload. The manual settings are:
The node can also be configured by sending it a specific msg.transition
object:
{
"duration": 15, //Total Time
"units": "Minute", //Can be "Second", "Minute", or "Hour"
"steps": 30, //# of steps
"startRGB": '#ff0000', //RGB color to start from
"transitionRGB": '#ffff00', //RGB color to transition through
"endRGB": '#ffffff', //RGB color to end at
"startMired": 160, //Mired value to begin at
"endMired": 600, //Mired value to end at
"startBright": 1, //Starting brightness
"endBright": 100, //Ending brightness
"brightnessType": "Percent", //Brightness values selector. Can be "Percent" or "Integer"
"transitionType": "Linear", //Can be "Linear" or "Exponential"
"colorTransitionType" : "Weighted" //Can be "Weighted", "Half", or "None"
}
Any time a msg.transition
is sent to the node, the settings are changed and the loop is started from the beginning again.
This node will stop running when it has reached the last step. It will send a msg.payload
of complete
out of the second output on the node.
You can also manually stop the node by sending a msg.payload
of stop
or STOP
. The node will end its loop and send a msg.payload
of stopped
out of the second output.
If you would like to help with translating, please see the locales folder for examples of what needs to be translated.
msg.transition
object:rgbw_color
value to it.
The "Complete" switch node only passes a message when the msg.payload
= complete
. This ensures that the second node won't get started when a stop command is sent to the first node since the nodes will send a stopped
message when forced to stop.
The second transition node changes the mireds from 525 (warm) to 160 (cool). The Brightness changes from 100 to 0% with an exponential transision.