Title - Elgato Key Light control
Summary - This flow links the Elgato Key Light and Elgato Key Light Air to Hubitat, enabling me to control my lights via Alexa, Apple Homekit, and a button controller under my desk. Bliss!
Setup:
- On your router / DHCP server: create a static IP address for your Elgato light
- In Hubitat: create a Virtual Color Temperature Light, accessible via Maker API
- In Node-RED:
a) Set the Elgato light's IP address in the "set IP address" and "poll device's API every 5s" nodes
b) Select the virtual light in the two green Hubitat nodes
Advanced users: You can also control the Elgato light from your own flows by sending commands to this flow's link node. The link is lower latency that sending commands via a Hubitat node.
Picture
**Flow**
This flow requires the node-red-contrib-simple-gate and no-op nodes. You can install both of these directly from within Node-RED by visiting the 'Manage Palette' menu.
[{"id":"53317764.a2d868","type":"inject","z":"b09ee1db.07242","name":"poll device's API every 5s","props":[{"p":"IP_address","v":"192.168.0.9","vt":"str"}],"repeat":"5","crontab":"","once":true,"onceDelay":"2","topic":"","payloadType":"str","x":200,"y":340,"wires":[["470bef3e.2003f"]]},{"id":"8baa3909.667a28","type":"change","z":"b09ee1db.07242","name":"set IP address","rules":[{"t":"set","p":"IP_address","pt":"msg","to":"192.168.0.9","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1580,"y":160,"wires":[["bd2b535f.5699b"]]},{"id":"d0b2d0da.8428","type":"comment","z":"b09ee1db.07242","name":"Left Light","info":"","x":80,"y":60,"wires":[]},{"id":"4b4ef25f.a9357c","type":"inject","z":"b09ee1db.07242","name":"Initialize","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":140,"wires":[["4a706ebb.a6e76"]]},{"id":"b7add235.f359","type":"hubitat command","z":"b09ee1db.07242","deviceLabel":"Left VC","name":"","server":"f0222da5.5a5e7","deviceId":"2385","command":"","commandArgs":"","x":1800,"y":340,"wires":[[]]},{"id":"4a706ebb.a6e76","type":"hubitat device","z":"b09ee1db.07242","deviceLabel":"Left VC","name":"","server":"f0222da5.5a5e7","deviceId":"2385","attribute":"","sendEvent":true,"x":280,"y":140,"wires":[["d610c795.73d208"]]},{"id":"470bef3e.2003f","type":"http request","z":"b09ee1db.07242","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{IP_address}}:9123/elgato/lights","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":340,"wires":[["cbadbe1d.2978c"]]},{"id":"bd2b535f.5699b","type":"http request","z":"b09ee1db.07242","name":"Send to Elgato light","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://{{IP_address}}:9123/elgato/lights","tls":"","persist":false,"proxy":"","authType":"","x":1770,"y":160,"wires":[[]]},{"id":"38162faa.2ed8b","type":"json","z":"b09ee1db.07242","name":"","property":"payload","action":"","pretty":false,"x":1430,"y":160,"wires":[["8baa3909.667a28"]]},{"id":"696ff7d9.3c2378","type":"switch","z":"b09ee1db.07242","name":"Which attribute changed?","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"switch","vt":"str"},{"t":"eq","v":"colorTemperature","vt":"str"},{"t":"eq","v":"level","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":630,"y":140,"wires":[["718f005f.58adb"],["90a1f46f.7a8858"],["ce4bc53e.962008"]]},{"id":"ce4bc53e.962008","type":"change","z":"b09ee1db.07242","name":"level","rules":[{"t":"set","p":"level","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":200,"wires":[["172444c9.311cdb"]]},{"id":"90a1f46f.7a8858","type":"change","z":"b09ee1db.07242","name":"temperature","rules":[{"t":"set","p":"colorTemperature","pt":"msg","to":"$round(1000000 / \t payload.value,\t 0)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":160,"wires":[["8fd07e5c.1ccaf"]]},{"id":"718f005f.58adb","type":"switch","z":"b09ee1db.07242","name":"on/off","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":850,"y":120,"wires":[["b4852859.2e3838"],["5ed64180.92b54"]]},{"id":"5ed64180.92b54","type":"change","z":"b09ee1db.07242","name":"off","rules":[{"t":"set","p":"on_state","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":140,"wires":[["fcd023a7.161a5"]]},{"id":"fcd023a7.161a5","type":"change","z":"b09ee1db.07242","name":"Elgato on/off","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.numberOfLights","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"payload.lights[0].on","pt":"msg","to":"on_state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":120,"wires":[["38162faa.2ed8b"]]},{"id":"8fd07e5c.1ccaf","type":"change","z":"b09ee1db.07242","name":"Elgato color temperature","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.numberOfLights","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"payload.lights[0].temperature","pt":"msg","to":"colorTemperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":160,"wires":[["38162faa.2ed8b"]]},{"id":"172444c9.311cdb","type":"change","z":"b09ee1db.07242","name":"Elgato brightness (min 2)","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.numberOfLights","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"payload.lights[0].brightness","pt":"msg","to":"$max([2,msg.level])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":200,"wires":[["38162faa.2ed8b"]]},{"id":"b4852859.2e3838","type":"change","z":"b09ee1db.07242","name":"on","rules":[{"t":"set","p":"on_state","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":100,"wires":[["fcd023a7.161a5"]]},{"id":"6b1d1975.5977f8","type":"link in","z":"b09ee1db.07242","name":"command injector for left VC light","links":["74eb1dea.81dfd4"],"x":315,"y":80,"wires":[["d610c795.73d208"]]},{"id":"d610c795.73d208","type":"no-op","z":"b09ee1db.07242","name":"","x":430,"y":140,"wires":[["696ff7d9.3c2378","74b4b7c2.f94bc8"]]},{"id":"b163f868.b841a8","type":"change","z":"b09ee1db.07242","name":"topic = control","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":260,"wires":[["cbadbe1d.2978c"]]},{"id":"74b4b7c2.f94bc8","type":"trigger","z":"b09ee1db.07242","name":"Pause polling for 5s to prevent race condition","op1":"close","op2":"open","op1type":"str","op2type":"str","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":740,"y":260,"wires":[["b163f868.b841a8"]]},{"id":"cbadbe1d.2978c","type":"gate","z":"b09ee1db.07242","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"x":910,"y":340,"wires":[["f2ab6827.73a878"]]},{"id":"f6f76a93.e58278","type":"json","z":"b09ee1db.07242","name":"","property":"payload","action":"","pretty":false,"x":1190,"y":340,"wires":[["bcc4e21d.8ad46"]]},{"id":"bc098f02.ea80a","type":"change","z":"b09ee1db.07242","name":"level (min 2)","rules":[{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"payload.lights[0].brightness","tot":"msg"},{"t":"set","p":"arguments","pt":"msg","to":"$max([2,msg.arguments])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1550,"y":320,"wires":[["b7add235.f359"]]},{"id":"e6ef88a.1201978","type":"change","z":"b09ee1db.07242","name":"temperature","rules":[{"t":"set","p":"command","pt":"msg","to":"setColorTemperature","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"$round(\t$round(2000000 * \t $power(payload.lights[0].temperature,-1),\t -2),\t 0)/2","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1550,"y":360,"wires":[["b7add235.f359"]]},{"id":"bcc4e21d.8ad46","type":"switch","z":"b09ee1db.07242","name":"on/off","property":"payload.lights[0].on","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1330,"y":340,"wires":[["dddbd0df.054a9","bc098f02.ea80a","e6ef88a.1201978"],["f01ab922.1b5bf8"]]},{"id":"dddbd0df.054a9","type":"change","z":"b09ee1db.07242","name":"on","rules":[{"t":"set","p":"command","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1530,"y":280,"wires":[["b7add235.f359"]]},{"id":"f01ab922.1b5bf8","type":"change","z":"b09ee1db.07242","name":"off","rules":[{"t":"set","p":"command","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1530,"y":400,"wires":[["b7add235.f359"]]},{"id":"1102887a.76ec28","type":"comment","z":"b09ee1db.07242","name":"Note on pre-staging","info":"Hubitat's virtual light doesn't support pre-staging, so we don't send color temperature or level messages to Elgato lights when off or else it'll turn on","x":1570,"y":440,"wires":[]},{"id":"f2ab6827.73a878","type":"rbe","z":"b09ee1db.07242","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1050,"y":340,"wires":[["f6f76a93.e58278"]]},{"id":"f0222da5.5a5e7","type":"hubitat config","name":"Hubitat","usetls":false,"host":"192.168.0.2","port":"80","appId":"2781","nodeRedServer":"http://192.168.0.4:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false}]