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. It also alows you to manually change the slave Hue to any colour or on/off indipendantly of the master light, it will then follow the master light once the mains switch is used.

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":"5","serverid":"001788fffe09d8cb","name":"Read Hue 1","x":595,"y":166,"z":"57b6b7bd.a84948","wires":[["570bc28.fa8f43c"],[]]},{"id":"d14fe440.2eb018","type":"Hue Set","deviceid":"10","serverid":"001788fffe09d8cb","name":"Set Hue 2","x":1136,"y":172,"z":"57b6b7bd.a84948","wires":[["b4802ce3.4b7fd"],[]]},{"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":1006,"y":489,"z":"57b6b7bd.a84948","wires":[["dbdcd8e1.242328"]]},{"id":"b5425dee.4abda","type":"function","name":"off","func":"msg.payload={\n\t\"on\":[false],\n\n};\nreturn msg;","outputs":1,"noerr":0,"x":1008,"y":172,"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":762,"y":166,"z":"57b6b7bd.a84948","wires":[["1c912d5e.e36ed3"],["b5425dee.4abda"]]},{"id":"d5bf43ca.2a40c","type":"Hue Pull","deviceid":"10","serverid":"001788fffe09d8cb","name":"Read Hue 2","x":256,"y":325,"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":422,"y":325,"z":"57b6b7bd.a84948","wires":[["170a12c9.e8f5ed"],["2b869633.d4796a"]]},{"id":"3d02aa98.c2fd56","type":"comment","name":"Repeat until Hue 1 switched on ","info":"","x":678,"y":531,"z":"57b6b7bd.a84948","wires":[]},{"id":"b4802ce3.4b7fd","type":"delay","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1272,"y":171,"z":"57b6b7bd.a84948","wires":[["2b869633.d4796a"]]},{"id":"220b1454.ddf4ec","type":"inject","name":"","topic":"Auto start once","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":100,"y":325,"z":"57b6b7bd.a84948","wires":[["d5bf43ca.2a40c"]]},{"id":"2b869633.d4796a","type":"Hue Pull","deviceid":"5","serverid":"001788fffe09d8cb","name":"Read Hue 1","x":598,"y":497,"z":"57b6b7bd.a84948","wires":[["d8ec35e1.2713c8"],[]]},{"id":"d8ec35e1.2713c8","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":764,"y":497,"z":"57b6b7bd.a84948","wires":[["f1a1ca6.f0e5e38"],["9e6c8aa3.619378"]]},{"id":"51871928.ae78e8","type":"delay","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1271,"y":491,"z":"57b6b7bd.a84948","wires":[["170a12c9.e8f5ed"]]},{"id":"9e6c8aa3.619378","type":"delay","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":678,"y":591,"z":"57b6b7bd.a84948","wires":[["2b869633.d4796a"]]},{"id":"1c912d5e.e36ed3","type":"delay","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":696,"y":89,"z":"57b6b7bd.a84948","wires":[["170a12c9.e8f5ed"]]},{"id":"dbdcd8e1.242328","type":"Hue Set","deviceid":"10","serverid":"001788fffe09d8cb","name":"Set Hue 2","x":1135,"y":490,"z":"57b6b7bd.a84948","wires":[["51871928.ae78e8"],[]]},{"id":"633d710d.9cc29","type":"comment","name":"Yes","info":"","x":502,"y":235,"z":"57b6b7bd.a84948","wires":[]},{"id":"5ea6697b.a15998","type":"comment","name":"No","info":"","x":498,"y":419,"z":"57b6b7bd.a84948","wires":[]},{"id":"b5bace5f.4a453","type":"comment","name":"Repeat until Hue 1 switched off","info":"","x":690,"y":132,"z":"57b6b7bd.a84948","wires":[]},{"id":"d059f3d2.2fa61","type":"comment","name":"Hue 1 off","info":"","x":898,"y":191,"z":"57b6b7bd.a84948","wires":[]},{"id":"c6270243.39d9","type":"comment","name":"Hue 1 on","info":"","x":894,"y":469,"z":"57b6b7bd.a84948","wires":[]},{"id":"9abefa54.654108","type":"comment","name":"Once Hue 2 set, go back to read opposite line","info":"Top side will wait for Hue 1 to switch off before making any changes\n\nBottom side will wait for Hue 1 to switch on before making any changes\n","x":1155,"y":331,"z":"57b6b7bd.a84948","wires":[]},{"id":"2d8ec93f.d27136","type":"comment","name":"Wait to turn off Hue 2","info":"Wait for hue 1 to change, \nif nothing changes and Hue 1 is still unreachable\nthen repeat back to wait for change\n\nif changed to off position\nthen change Hue 2 and \nthen start checking if if Hue 1 is on","x":410,"y":101,"z":"57b6b7bd.a84948","wires":[]},{"id":"2a08254e.d5f7da","type":"comment","name":"Wait to turn on Hue 2","info":"Wait for hue 1 to change, \nif nothing changes and Hue 1 is still reachable\nthen repeat back to wait for change\n\nif changed to on position\nthen change Hue 2 and \nthen start checking if if Hue 1 is off","x":407,"y":556,"z":"57b6b7bd.a84948","wires":[]},{"id":"b01f4716.4fe0b8","type":"comment","name":"Decide which side to start on?","info":"","x":329,"y":289,"z":"57b6b7bd.a84948","wires":[]}]

Flow Info

Created 8 years, 8 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • comment (x10)
  • delay (x4)
  • function (x5)
  • inject (x1)
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