# Christmas light or flashing

**URL:** <https://discourse.nodered.org/t/christmas-light-or-flashing/83390>\
**Category:** General\
**Created:** [2 December 2023 20:42 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390 "2023-12-02T20:42:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![droneman83](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/droneman83/32/85519_2.png) [@droneman83](https://discourse.nodered.org/u/droneman83)\
**Post date:** [2 December 2023 20:42 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390/1 "2023-12-02T20:42:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [2 December 2023 21:51 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390/2 "2023-12-02T21:51:25Z")

</div>

I’m afraid we need more information.

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

---

<div class="post-metadata">

**Author:** ![droneman83](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/droneman83/32/85519_2.png) [@droneman83](https://discourse.nodered.org/u/droneman83)\
**Post date:** [3 December 2023 08:23 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390/3 "2023-12-03T08:23:03Z")

</div>

? 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

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [3 December 2023 09:21 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390/4 "2023-12-03T09:21:25Z")

</div>

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

```js
const Colors = [
    [255,255,255],
    [0,255,0],
    [0,0,255],
    [255,0,0]
]

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

const Message = {
    payload:{
        rgb_color:Colors[Index]
    }
}
Index++;
if(Index > Colors.length-1){
    Index = 0;
}

context.set("index",Index)

return Message

```

 ![Screenshot 2023-12-03 at 09.21.09](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3edf6c31451abb8a11d6d6be51ae3ecd7a65942e.png)

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [3 December 2023 09:38 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390/5 "2023-12-03T09:38:45Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/87617fa0cf7879bfe4ff6d233b77a2fde6819922.png)

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

**Author:** ![droneman83](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/droneman83/32/85519_2.png) [@droneman83](https://discourse.nodered.org/u/droneman83)\
**Post date:** [3 December 2023 23:42 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390/6 "2023-12-03T23:42:53Z")

</div>

nice thanks alot 🙂 🤟  
where can i instert the light i like to use 🙂

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [4 December 2023 08:50 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390/7 "2023-12-04T08:50:41Z")

</div>

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

Either

- 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)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/8/f8ae43cb7353972adb64f2be98159b2fb8da7571.png)

Example

```js
const Message = {
    payload:{
        rgb_color:Colors[Index],
        targetLight: 2
    }
}

```

---

<div class="post-metadata">

**Author:** ![droneman83](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/droneman83/32/85519_2.png) [@droneman83](https://discourse.nodered.org/u/droneman83)\
**Post date:** [4 December 2023 09:49 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390/8 "2023-12-04T09:49:07Z")

</div>

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) 🫣

 ![Skærmbillede 2023-12-04 104630](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d9b70488a4ea91eec0479c1514cc81d562a4079.jpeg)

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [4 December 2023 09:54 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390/9 "2023-12-04T09:54:22Z")

</div>

> [@droneman83](#):
>
> I just use the nonmale call service or other standard HA websocket nodes

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 February 2024 09:54 UTC](https://discourse.nodered.org/t/christmas-light-or-flashing/83390/10 "2024-02-02T09:54:55Z")

</div>

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