There has been some discussion about keeping a Node Red Dashboard UI sync'd with HomeSeer. The below flow will create a single Toggle for an On/Off light switch and keep it in sync with HomeSeer. If your Node Red server goes off line and comes back on and your switch has changed, this will keep it sync'd as well.
Requirements
This flow requires the installation of node-red-dashboard as well as the HomeSeer contrib in Node Red.
Flow Image 
Explanation
From left to right, this flow works as follows:
JSON to Import
- Using the Node Red Dashboard UI you can turn the light on and off
- Using HomeSeer you can turn the light on and off
- Provided local control is reported back to HomeSeer, yo can use local control to turn the light on and off
Requirements
This flow requires the installation of node-red-dashboard as well as the HomeSeer contrib in Node Red.
Flow Image
Explanation
From left to right, this flow works as follows:
- The Light Status is a Status node set to report on a Select Node, which is the HomeSeer Patio Light node. Any time the HomeSeer Patio Light node's Status changes, this node will report the status in msg.status.text with a value matching the Status shown by the HomeSeer device. In the above case this is a string of "On"
- The Switch node receives the status message and directs output based on the text string of On or Off. On goes to the first output and Off to the second.
- The two Change nodes Delete the incoming payload and send out a JSON payload of either {"status":"On"} for the top instance or {"status":"Off"} for the bottom.
- The Patio Light UI Switch is a dashboard UI Switch node (not to be confused with the standard Node-Red switch node type used earlier). This is set as shown below with the key setting being the Pass through and Indicator settings. This will only send the value of the switch to the remainder of the flow if the value changes. So it will not send a value through is the switch itself does not change.
- The On and Off below the Patio Light Switch are Injection Nodes for control from in the flow display.
- The Patio Light is a HomeSeer device with On/Off capabilities. In this case a light switch.
JSON to Import
Code:
[{"id":"1acd31e7.da334e","type":"tab","label":"GUI Test","disabled":false,"info":""},{"id":"743ba26e.0a346c","type":"ui_switch","z":"1acd31e7.da334e","name":"","label":"Patio Light UI Switch","tooltip":"","group":"4f7a86f3.bd5eb8","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"control","style":"","onvalue":"{\"status\":\"On\"}","onvalueType":"json","onicon":"","oncolor":"","offvalue":"{\"status\":\"Off\"}","offvalueType":"json","officon":"","offcolor":"","x":660,"y":40,"wires":[["c2762a12.273798"]]},{"id":"c2762a12.273798","type":"hs-device","z":"1acd31e7.da334e","name":"Patio Light","device":"12","server":"fd5a6a5c.dc9868","feature":0,"x":870,"y":80,"wires":[[]]},{"id":"7bf48779.f066c8","type":"status","z":"1acd31e7.da334e","name":"Light Status","scope":["c2762a12.273798"],"x":90,"y":80,"wires":[["f1130c78.ec183"]]},{"id":"41851d20.1395c4","type":"inject","z":"1acd31e7.da334e","name":"On","props":[{"p":"payload.status","v":"On","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","x":650,"y":100,"wires":[["c2762a12.273798"]]},{"id":"3b2843f.7bb4dbc","type":"inject","z":"1acd31e7.da334e","name":"Off","props":[{"p":"payload.status","v":"Off","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","x":650,"y":140,"wires":[["c2762a12.273798"]]},{"id":"5631bec.c1af84","type":"change","z":"1acd31e7.da334e","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{\"status\":\"On\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":40,"wires":[["743ba26e.0a346c"]]},{"id":"f1130c78.ec183","type":"switch","z":"1acd31e7.da334e","name":"","property":"status.text","propertyType":"msg","rules":[{"t":"eq","v":"On","vt":"str"},{"t":"eq","v":"Off","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":250,"y":80,"wires":[["5631bec.c1af84"],["ac92619.c43cea"]]},{"id":"ac92619.c43cea","type":"change","z":"1acd31e7.da334e","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{\"status\":\"Off\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":421.59576416015625,"y":106.14030456542969,"wires":[["743ba26e.0a346c"]]},{"id":"4f7a86f3.bd5eb8","type":"ui_group","z":"","name":"Default","tab":"42fec237.9be69c","order":1,"disp":true,"width":"6","collapse":false},{"id":"fd5a6a5c.dc9868","type":"hs-server","z":"","name":"House","host":"192.168.1.10","port":"8008"},{"id":"42fec237.9be69c","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
Comment