Christmas RGB LED Rainbow Control

It's time for Christmas!

If you have RGB LED Stripes or whatever type of lightning, which has red, green and blue colors which can be controlled via 0-100 brightness levels, this flow is for you.

grafik

[{"id":"6477e197.e86a7","type":"tab","label":"Rainbow"},{"id":"9f2137e8.67dbd8","type":"inject","z":"6477e197.e86a7","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"x":119.7857666015625,"y":356.2119445800781,"wires":[["92e1033e.09625"]]},{"id":"959a93d7.af68a8","type":"switch","z":"6477e197.e86a7","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"Speed","vt":"flow"},{"t":"else"}],"checkall":"true","outputs":2,"x":1200.1446533203125,"y":342.168212890625,"wires":[["f47d3096.04377"],["81b180de.dd7558"]]},{"id":"ed819b53.0f27d","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Speed","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":435.4287109375,"y":157.0284423828125,"wires":[[]]},{"id":"f47d3096.04377","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Counter","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1399.888916015625,"y":334.5682373046875,"wires":[["36a93ed6.0ca1fa"]]},{"id":"f6e8cb7a.bc9a5","type":"function","z":"6477e197.e86a7","name":"+ 1","func":"var temp_offset = parseInt(msg.payload,10) + 1;\nmsg.payload = temp_offset;\n\nreturn msg;","outputs":1,"noerr":0,"x":1043.477783203125,"y":343.3904724121094,"wires":[["959a93d7.af68a8"]]},{"id":"81b180de.dd7558","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Counter","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1400.694580078125,"y":383.0015563964844,"wires":[[]]},{"id":"36a93ed6.0ca1fa","type":"function","z":"6477e197.e86a7","name":"RGB Sequencing","func":"var Red = context.get('Red')||0; //read \nvar Green = context.get('Green')||0; //read \nvar Blue = context.get('Blue')||0; //read \nvar Sequence = context.get('Sequence')||0; //read\nvar Brightness = flow.get('Brightness')||0; //read\n\nswitch(Sequence) {\n    case 0 :\n\n        if (Green < 100) {\n            Green = Green + 1;\n        } \n        if (Red>0) {\n            Red = Red - 1;\n        }\n        if (Green == 100 && Red === 0) {\n            Sequence =1;\n        }\n        break;\n    case 1 :\n        if (Blue < 100) {\n            Blue = Blue + 1;\n        }\n        if (Green>0) {\n            Green = Green - 1;\n        }\n        if (Blue == 100 && Green === 0) {\n            Sequence =2;\n        }\n        break;\n    case 2 :\n        if (Red < 100) {\n            Red = Red + 1;\n        }\n        if (Blue>0) {\n            Blue = Blue - 1;\n        }\n        if (Red == 100 && Blue === 0) {\n            Sequence = 0;\n        }\n        break;\n}\nnode.status({text:Red.toString()+' '+Green.toString()+' '+Blue.toString()});\n\ncontext.set('Red',Red);\ncontext.set('Green',Green);\ncontext.set('Blue',Blue);\ncontext.set('Sequence',Sequence);\n\n\nvar msg1 = { payload:Math.round(Red*Brightness/100) };\nvar msg2 = { payload:Math.round(Green*Brightness/100) };\nvar msg3 = { payload:Math.round(Blue*Brightness/100) };\nreturn [msg1,msg2,msg3];","outputs":"3","noerr":0,"x":1616.9444580078125,"y":336.0848693847656,"wires":[["1c83cbce.7b1ee4"],["6e69c6b9.4ac0e8"],["699caa78.52dc6c"]]},{"id":"e505c1de.82a68","type":"debug","z":"6477e197.e86a7","name":"","active":true,"console":"false","complete":"false","x":2190.5514526367188,"y":213.42617797851562,"wires":[]},{"id":"92581d76.9d251","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Brightness","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":445.250244140625,"y":71.949951171875,"wires":[[]]},{"id":"9e1564ad.ab9578","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Rainbow","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":452.357177734375,"y":267.3428955078125,"wires":[[]]},{"id":"f579c2d4.5853c8","type":"rbe","z":"6477e197.e86a7","name":"","func":"rbe","gap":"","start":"","inout":"out","x":2000.5633544921875,"y":291.6285400390625,"wires":[["e505c1de.82a68","2ae16fa1.a81a08"]]},{"id":"24d1ac2e.8e1dfc","type":"rbe","z":"6477e197.e86a7","name":"","func":"rbe","gap":"","start":"","inout":"out","x":2000.5634155273438,"y":338.2951965332031,"wires":[["e505c1de.82a68","cbba7755.a1d86"]]},{"id":"dbff555c.069218","type":"rbe","z":"6477e197.e86a7","name":"","func":"rbe","gap":"","start":"","inout":"out","x":1999.4523315429688,"y":380.5174255371094,"wires":[["e505c1de.82a68","97a7ff45.4e06"]]},{"id":"9e20f31d.e7281","type":"mqtt in","z":"6477e197.e86a7","name":"","topic":"/myhome/in/Rainbow_Bright","qos":"2","broker":"76384a52.7084c4","x":149.57138061523438,"y":72.9998779296875,"wires":[["92581d76.9d251"]]},{"id":"7ea81347.b8d16c","type":"mqtt in","z":"6477e197.e86a7","name":"","topic":"/myhome/in/Rainbow_Speed","qos":"2","broker":"76384a52.7084c4","x":147,"y":156.5714111328125,"wires":[["ed819b53.0f27d"]]},{"id":"768e93dc.1781b4","type":"mqtt in","z":"6477e197.e86a7","name":"","topic":"/myhome/in/LED_Terasse_Rainbow","qos":"2","broker":"76384a52.7084c4","x":169.00003051757812,"y":269.42840576171875,"wires":[["9e1564ad.ab9578"]]},{"id":"882d57f.8d2b928","type":"debug","z":"6477e197.e86a7","name":"","active":false,"console":"false","complete":"false","x":1330.1112060546875,"y":552.4445190429688,"wires":[]},{"id":"84472794.cda978","type":"inject","z":"6477e197.e86a7","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":true,"x":100,"y":215,"wires":[["fab857ef.1f746"]]},{"id":"d704a458.9769a8","type":"mqtt out","z":"6477e197.e86a7","name":"","topic":"/myhome/command/LED_Terasse_G/state","qos":"0","retain":"true","broker":"76384a52.7084c4","x":2449.9208984375,"y":346.4602966308594,"wires":[]},{"id":"2ae16fa1.a81a08","type":"mqtt out","z":"6477e197.e86a7","name":"","topic":"/myhome/command/LED_Terasse_R/state","qos":"0","retain":"true","broker":"76384a52.7084c4","x":2454.2064819335938,"y":287.8888244628906,"wires":[]},{"id":"6a22b9e9.180ab","type":"mqtt out","z":"6477e197.e86a7","name":"","topic":"/myhome/command/LED_Terasse_B/state","qos":"0","retain":"true","broker":"76384a52.7084c4","x":2438.4921875,"y":402.1745300292969,"wires":[]},{"id":"cbba7755.a1d86","type":"delay","z":"6477e197.e86a7","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2192.77783203125,"y":345.0317687988281,"wires":[["d704a458.9769a8"]]},{"id":"97a7ff45.4e06","type":"delay","z":"6477e197.e86a7","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2184.2064208984375,"y":393.6031799316406,"wires":[["6a22b9e9.180ab"]]},{"id":"fab857ef.1f746","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Counter","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":259.75,"y":214.75,"wires":[[]]},{"id":"69def6a3.2b7708","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":885.8500366210938,"y":470.09442138671875,"wires":[["882d57f.8d2b928","97119b1d.b4e188"]]},{"id":"e256e2bf.ff367","type":"mqtt in","z":"6477e197.e86a7","name":"","topic":"/myhome/in/Rainbow_Time_ON","qos":"2","broker":"76384a52.7084c4","x":726.11669921875,"y":66.11663818359375,"wires":[["b2ce6277.9559c8"]]},{"id":"7d6b4776.136aa8","type":"mqtt in","z":"6477e197.e86a7","name":"","topic":"/myhome/in/Rainbow_Time_OFF","qos":"2","broker":"76384a52.7084c4","x":725.11669921875,"y":154.11663818359375,"wires":[["6a9a9e09.20021"]]},{"id":"2f68b7be.b5744","type":"debug","z":"6477e197.e86a7","name":"output","active":false,"console":"false","complete":"true","x":777.11669921875,"y":264.3333740234375,"wires":[]},{"id":"dfe86395.ca5948","type":"function","z":"6477e197.e86a7","name":"timeConvert","func":"if ( !msg.timestamp ) msg.timestamp = Math.round(+new Date());\n\nvar dt = new Date(msg.timestamp);\nvar msg = {\n\tpayload:\tdt.getHours(),\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":463.89453125,"y":349.7777099609375,"wires":[["2f68b7be.b5744","9b0cf6a.e340508"]]},{"id":"b2ce6277.9559c8","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Time_ON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040.11669921875,"y":64.38330078125,"wires":[[]]},{"id":"6a9a9e09.20021","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Time_OFF","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040.11669921875,"y":155.38330078125,"wires":[[]]},{"id":"9b0cf6a.e340508","type":"switch","z":"6477e197.e86a7","name":"","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"Time_ON","vt":"flow","v2":"Time_OFF","v2t":"flow"},{"t":"else"}],"checkall":"false","outputs":2,"x":643.3389282226562,"y":349.494384765625,"wires":[["7a9902c6.19992c"],["69def6a3.2b7708"]]},{"id":"92e1033e.09625","type":"switch","z":"6477e197.e86a7","name":"","property":"Rainbow","propertyType":"flow","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"else"}],"checkall":"true","outputs":2,"x":283.5740661621094,"y":357.4815979003906,"wires":[["dfe86395.ca5948"],["69def6a3.2b7708"]]},{"id":"7a9902c6.19992c","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Counter","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":840.7499389648438,"y":342.3055725097656,"wires":[["8212eddf.7380c","f6e8cb7a.bc9a5"]]},{"id":"8212eddf.7380c","type":"debug","z":"6477e197.e86a7","name":"","active":false,"console":"false","complete":"false","x":1261.944580078125,"y":215.2777557373047,"wires":[]},{"id":"1c83cbce.7b1ee4","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Topic","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1814.1668701171875,"y":291.9444274902344,"wires":[["f579c2d4.5853c8"]]},{"id":"6e69c6b9.4ac0e8","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Topic","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1815.3890380859375,"y":337.8333435058594,"wires":[["24d1ac2e.8e1dfc"]]},{"id":"699caa78.52dc6c","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Topic","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1818.6112060546875,"y":380.27777099609375,"wires":[["dbff555c.069218"]]},{"id":"97119b1d.b4e188","type":"change","z":"6477e197.e86a7","name":"","rules":[{"t":"set","p":"Topic","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1810.8333129882812,"y":466.388916015625,"wires":[["f579c2d4.5853c8","24d1ac2e.8e1dfc","dbff555c.069218"]]},{"id":"76384a52.7084c4","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""}]

Flow Info

Created 8 years ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x14)
  • debug (x4)
  • delay (x2)
  • function (x3)
  • inject (x2)
  • mqtt in (x5)
  • mqtt out (x3)
  • mqtt-broker (x1)
  • rbe (x3)
  • switch (x3)
Other
  • tab (x1)

Tags

  • Christmas
  • RGB
  • LED
  • Rainbow
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option