Limitless Led, sunrise-node

This node turns on my limitless led-lights in the morning. It starts with a red color on lowest brightness and ends with a yellow color and highest brightness and finally whitemode.

The node is based on Andrea Ghensis node, but no wake-up music... https://groups.google.com/forum/#!searchin/node-red/loop/node-red/OM12VwAAFAI/Fldh9y7RkcoJ

[{"id":"a1e6a9c6.5e1958","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"ba386057.845d3","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"9920bd25.66df4","type":"mqtt in","name":"","topic":"lights/scenes/sunrise","broker":"ba386057.845d3","x":231,"y":40,"z":"bd70c1cd.428f4","wires":[["6806363c.97f9c8"]]},{"id":"6806363c.97f9c8","type":"function","name":"Sunrise","func":"var lightsMsg = null;\ncontext.count = context.count || 0;    \n\nswitch (msg.payload) {\n\tcase \"start\":\n\t\t//initialize loop, switch on the lights at minimum brightness and start_hue\n\t\tcontext.stopped = 0;\n\t\tmsg.payload = 1;\n\t\tmsg.count = 176\n\t\tlightMsg = [{topic:\"lights/2/power\", payload:\"on\"},{topic:\"lights/2/brightness\", payload:1}, {topic:\"lights/2/hue\", payload:176}];\n\t\tbreak;\n\tcase \"stop\":\n\t\t//switch off the light and stops the music\n\t\tcontext.stopped = 1;\n\t\tmsg = null;\n\t\tlightMsg = {topic:\"lights/2/power\", payload:\"off\"};\n\t\tbreak;\n\tcase 101:\n\t\t//end of sunrise, turn on all lamps in bedrom to white\n\t\tlightMsg = [{topic:\"lights/2/whitemode\", payload:\"yes\"},{topic:\"lights/1/power\", payload:\"on\"},{topic:\"lights/1/whitemode\", payload:\"yes\"},  {topic:\"lights/1/brightness\", payload:100}];\n\t\tmsg.payload++;\n\t\tbreak;\n\tcase 102:\t\n\t\t//natural end of the loop\n\t\tmsg = null;\n\t\tbreak;\n\tdefault:\n\t\tif (context.stopped == 0) {\n\t\t\t//set the right brightness on the payload value and increments it\n\t\t\tlightMsg = [{topic:\"lights/2/brightness\", payload:msg.payload}, {topic:\"lights/2/hue\", payload:msg.count}];\n\t\t\tmsg.payload ++;\n\t\t\tif (msg.payload%2 == 1){\n\t\t\t\tmsg.count --;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tmsg = null;\n\t\t}\n\t\tbreak;\n}\nreturn [msg, lightMsg];","outputs":"2","x":415,"y":39,"z":"bd70c1cd.428f4","wires":[["78e842b3.8717bc"],["804e2a03.7fb1d8"]]},{"id":"78e842b3.8717bc","type":"delay","name":"","pauseType":"delay","timeout":"18","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":416,"y":96,"z":"bd70c1cd.428f4","wires":[["6806363c.97f9c8"]]},{"id":"804e2a03.7fb1d8","type":"mqtt out","name":"Lights MQTT","topic":"","qos":"","retain":"","broker":"a1e6a9c6.5e1958","x":615,"y":43,"z":"bd70c1cd.428f4","wires":[]}]

Flow Info

Created 9 years, 8 months ago
Updated 9 years, 3 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • delay (x1)
  • function (x1)
  • mqtt in (x1)
  • mqtt out (x1)
  • mqtt-broker (x2)

Tags

  • sunrise
  • limitlessLed
  • wakeUp
  • milight
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option