Philips Hue Light to turn on/off as a slave to a master Hue light controlled by a switch

If you have Hue light that you turn off at the light switch, this flow will enable you to have an always powered Hue light to turn on and off following the switched lights.

Dependancies

node-red-contrib-hue

Key Nodes to update

  • 'Hue Light 1' is the switched light that will be the Master
  • 'Hue Light 2' is the slave light that will always be powered but turn on/off with the switched. This still allows for the slave light to be turned on via the app when Light 1 is off and vice-versa.
  • 'On' This function node sets the initial colour (rgb) and brightness (bri) when it turns on. if these fields are removed it will return to the state it was in before being automatically turned off.

Delay

There is a short delay from Light 1 being turned on/off until Light 2 does the same. There is ~10sec delay to turn off and ~30sec delay turning off. This is because the Hue base takes some time to recognise that the Hue Light 1 has become unreachable and a few seconds to recognise it has come back on-line once turned on.

[{"id":"170a12c9.e8f5ed","type":"Hue Pull","deviceid":"8","serverid":"001788fffe09d8cb","name":"Read Hue 1","x":266,"y":261,"z":"57b6b7bd.a84948","wires":[["570bc28.fa8f43c","da93fc46.256c"],[]]},{"id":"d14fe440.2eb018","type":"Hue Set","deviceid":"10","serverid":"001788fffe09d8cb","name":"Set Hue 2","x":1086,"y":229,"z":"57b6b7bd.a84948","wires":[[],[]]},{"id":"f1a1ca6.f0e5e38","type":"function","name":"on","func":"msg.payload={\n\t\"on\":[true],\n\t\"bri\":[255],\n\t\"rgb\":[255,0,0]\n};\nreturn msg;","outputs":1,"noerr":0,"x":930,"y":204,"z":"57b6b7bd.a84948","wires":[["d14fe440.2eb018"]]},{"id":"1242ad63.edbd53","type":"inject","name":"Manually Turn On?","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":749,"y":122,"z":"57b6b7bd.a84948","wires":[["f1a1ca6.f0e5e38"]]},{"id":"b5425dee.4abda","type":"function","name":"off","func":"msg.payload={\n\t\"on\":[false],\n\n};\nreturn msg;","outputs":1,"noerr":0,"x":930,"y":258,"z":"57b6b7bd.a84948","wires":[["d14fe440.2eb018"]]},{"id":"570bc28.fa8f43c","type":"function","name":"Is Reachable?","func":"if (msg.payload.state.reachable === true ) {\n\n    return [msg,null];\n}\n\nif (msg.payload.state.reachable === false) {\n    \n    return [null,msg];\n\n}","outputs":"2","noerr":0,"x":426,"y":250,"z":"57b6b7bd.a84948","wires":[["d5bf43ca.2a40c"],["24fb22c3.db04de"]]},{"id":"608bd351.9f742c","type":"inject","name":"Manually Turn Off?","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":757,"y":357,"z":"57b6b7bd.a84948","wires":[["b5425dee.4abda"]]},{"id":"4a6d1fc7.b592e","type":"inject","name":"Start every 2 sec","topic":"","payload":"","payloadType":"date","repeat":"2","crontab":"","once":false,"x":101,"y":260,"z":"57b6b7bd.a84948","wires":[["170a12c9.e8f5ed"]]},{"id":"da93fc46.256c","type":"debug","name":"Debugging","active":true,"console":"false","complete":"payload","x":430,"y":199,"z":"57b6b7bd.a84948","wires":[]},{"id":"d5bf43ca.2a40c","type":"Hue Pull","deviceid":"10","serverid":"001788fffe09d8cb","name":"Read Hue 2","x":589,"y":199,"z":"57b6b7bd.a84948","wires":[["f30282c0.0cfd8"],[]]},{"id":"f30282c0.0cfd8","type":"function","name":"Is Already On?","func":"if (msg.payload.state.on === true ) {\n\n    return [msg,null];\n}\n\nif (msg.payload.state.on === false) {\n    \n    return [null,msg];\n\n}","outputs":"2","noerr":0,"x":761,"y":183,"z":"57b6b7bd.a84948","wires":[[],["f1a1ca6.f0e5e38"]]},{"id":"24fb22c3.db04de","type":"Hue Pull","deviceid":"10","serverid":"001788fffe09d8cb","name":"Read Hue 2","x":588,"y":303,"z":"57b6b7bd.a84948","wires":[["e9f8777f.160788"],[]]},{"id":"e9f8777f.160788","type":"function","name":"Is Already On?","func":"if (msg.payload.state.on === true ) {\n\n    return [msg,null];\n}\n\nif (msg.payload.state.on === false) {\n    \n    return [null,msg];\n\n}","outputs":"2","noerr":0,"x":763,"y":286,"z":"57b6b7bd.a84948","wires":[["b5425dee.4abda"],[]]}]
ant2221

Flow Info

created 1 year, 3 months ago

Node Types

Core
  • debug (x1)
  • function (x5)
  • inject (x3)
Other

Tags

  • Philips
  • Hue
  • lights
  • automation
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option