Christmas light or flashing

Hi I have been searching for some way of having light connected in NR to pulse or flash in various color like red green blue white to imagine christmas,
if it's possible how to start and stop it from 16:30 to 23:00

I’m afraid we need more information.

How are you controlling the lights in Node RED currently? Do they support RGB?

? Atm Im just controlling them by manually set color in j-son {“rgb_color” : [255, 255, 255] and in other colors so I guess that they do supports rgb color but I have only figured out to set one color at the time not how the have it change color one by one, I tried have a random number change but it was very random and not smooth, connected to a switch node with numbers from 0-4 to a node on output with a specific color. I managed to start it up but not a solution to stop it again

Something like this, will cycle through your chosen colours in the order you add them to a collection, every 2s, with a start and stop.

If your lights support a transition, you can add it to the payload that gets sent

const Colors = [

let Index = context.get("index") || 0;

const Message = {
if(Index > Colors.length-1){
    Index = 0;


return Message

[{"id":"af508611c961c887","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"c57f9443833ae442","type":"inject","z":"af508611c961c887","name":"Start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":125,"y":140,"wires":[["0772bf75c5ed3c10"]]},{"id":"0772bf75c5ed3c10","type":"trigger","z":"af508611c961c887","name":"","op1":"","op2":"0","op1type":"date","op2type":"str","duration":"-2","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":325,"y":175,"wires":[["dba25e07c2d53fcf"]]},{"id":"e8e86597066eb1eb","type":"inject","z":"af508611c961c887","name":"Stop","props":[{"p":"reset","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":125,"y":175,"wires":[["0772bf75c5ed3c10"]]},{"id":"dba25e07c2d53fcf","type":"function","z":"af508611c961c887","name":"Colors","func":"const Colors = [\n    [255,255,255],\n    [0,255,0],\n    [0,0,255],\n    [255,0,0]\n]\n\nlet Index = context.get(\"index\") || 0;\n\nconst Message = {\n    payload:{\n        rgb_color:Colors[Index]\n        \n    }\n}\n\nIndex++;\nif(Index > Colors.length-1){\n    Index = 0;\n}\ncontext.set(\"index\",Index)\n\nreturn Message","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":175,"wires":[["dba4e4e1c0b17abb"]]},{"id":"dba4e4e1c0b17abb","type":"debug","z":"af508611c961c887","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":685,"y":175,"wires":[]}]
1 Like

What are these LED lights? A URL to the product would be useful. We can't help much without knowing what control inputs they accept.

If the leds do not support a transition you can enforce it with a flow like this.

[{"id":"43d176af8c955621","type":"inject","z":"aac203369ad93ef4","name":"Start & end points","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"start\":[255,0,0],\"end\":[65,105,225],\"steps\":20}","payloadType":"json","x":130,"y":100,"wires":[["ed8dc01650fe6f9d"]]},{"id":"e385097a04b43a52","type":"debug","z":"aac203369ad93ef4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":100,"wires":[]},{"id":"ed8dc01650fe6f9d","type":"function","z":"aac203369ad93ef4","name":"Intermediate steps","func":"const startred = msg.payload.start[0]\nconst startgreen = msg.payload.start[1]\nconst startblue = msg.payload.start[2]\n\nconst endred = msg.payload.end[0]\nconst endgreen = msg.payload.end[1]\nconst endblue = msg.payload.end[2]\n\nconst steps = msg.payload.steps // This many intermediate steps in the colour transition\nlet newmsg = {}\n\nfor (let i = 1; i <= steps; i++) {\n   let rgb = []\n    rgb[0] = startred + (i * (endred - startred)/steps)\n    rgb[1] = startgreen + (i * (endgreen - startgreen)/steps)\n    rgb[2] = startblue + (i * (endblue - startblue)/steps)\n\n    newmsg.payload = {\"rgb_color\": rgb}\n    node.send(newmsg)\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":100,"wires":[["1995f807de42452b"]]},{"id":"1995f807de42452b","type":"delay","z":"aac203369ad93ef4","name":"Control rate of change","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"2","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":540,"y":100,"wires":[["e385097a04b43a52"]]}]
1 Like

nice thanks alot :slight_smile: :love_you_gesture:
where can i instert the light i like to use :slight_smile:

As we have no idea what lights/system you are using,


  • Connect the output of the function to the Node that represents your light.
  • Set the target lights in the payload (you need to refer to documentation for the node)


const Message = {
        targetLight: 2

one of the light is a tuya device I just now have found out that there is a palate for tuya in NR i maybe need to setup other wise I just use the nonmale call service or other standard HA websocket nodes (rookie setup) :face_with_peeking_eye:

Hardly anyone here uses HA, so to target the correct light/resource - will be better answered by the HA community.

or skip HA all together and connect to the lights directly from Node RED, with Nodes for your hardware.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.