ZOOZ - ZEN32 State Lights - Subflow
Summary
I created this subflow to aid in controlling the LED's associated with each button on the ZEN32 scene controller. I'm currently using this subflow to collect inputs from my scene buttons, but the default behavior of the lights on the buttons doesn't work when it's not the only device controlling the state, they quickly can get out of sync.
This subflow gives direct control of the LED on each button within nodered, making it simple to attach to an event state source and link the light to the device.
Usage
The subflow is expecting 4 things:
Field | Description |
---|---|
device | This is the device string that gets passed into the call service node. |
button | 1-4 for the small buttons, 0 if you want to control the relay button's light. |
color | white, blue, green, red |
state | boolean |
State and color can send both, or just one (if color already set for example). At least one is required or nothing will happen.
[{"id":"ab729eda43dcc3f4","type":"subflow","name":"ZEN32 State Lights","info":"","category":"","in":[{"x":50,"y":30,"wires":[{"id":"a97995d56450ba30"}]}],"out":[],"env":[{"name":"DEVICE","type":"str","value":""}],"meta":{},"color":"#DDAA99"},{"id":"3b2d756216464775","type":"api-call-service","z":"ab729eda43dcc3f4","name":"Send Color Message","server":"711466b6fc712a78","version":5,"debugenabled":false,"domain":"zwave_js","service":"set_config_parameter","areaId":[],"deviceId":["{{flow.var_device}}"],"entityId":[],"data":"{\"parameter\":msg.button,\"value\":msg.state}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"action","propertyType":"msg","value":"set_color","valueType":"str"}],"queue":"none","x":960,"y":320,"wires":[["79974120ad27b1c6"]]},{"id":"79974120ad27b1c6","type":"debug","z":"ab729eda43dcc3f4","name":"zen32ledtest","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":260,"wires":[]},{"id":"a97995d56450ba30","type":"change","z":"ab729eda43dcc3f4","name":"Set up device","rules":[{"t":"set","p":"var_device","pt":"flow","to":"device","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":100,"wires":[["f05727fcc8e44116","5fb759acac9537b6"]]},{"id":"a5ebab1c30a52920","type":"switch","z":"ab729eda43dcc3f4","name":"Light State","property":"state","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":430,"y":220,"wires":[["9fc453f3ebb8b148"],["64efa882af7001e6"]],"outputLabels":["On","Off"]},{"id":"9fc453f3ebb8b148","type":"change","z":"ab729eda43dcc3f4","name":"Light On","rules":[{"t":"set","p":"state","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":200,"wires":[["29421d152ee928b5"]]},{"id":"64efa882af7001e6","type":"change","z":"ab729eda43dcc3f4","name":"Light Off","rules":[{"t":"set","p":"state","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":240,"wires":[["29421d152ee928b5"]]},{"id":"de8cad69e6b6fbde","type":"change","z":"ab729eda43dcc3f4","name":"Assign Light value","rules":[{"t":"set","p":"button","pt":"msg","to":"msg.button + 1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":120,"wires":[["a5ebab1c30a52920"]]},{"id":"f05727fcc8e44116","type":"switch","z":"ab729eda43dcc3f4","name":"Check if color set","property":"color","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":190,"y":260,"wires":[["60c132babe623cba"]]},{"id":"0aa95e3cfea7c674","type":"switch","z":"ab729eda43dcc3f4","name":"Check Color","property":"color","propertyType":"msg","rules":[{"t":"eq","v":"white","vt":"str"},{"t":"eq","v":"blue","vt":"str"},{"t":"eq","v":"green","vt":"str"},{"t":"eq","v":"red","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":430,"y":360,"wires":[["63e17abc5dc27fcf"],["b0d50114a51e81de"],["e9deb8f6af42c626"],["b333ba0c5ce645de"]],"outputLabels":["White","Blue","Green","Red"]},{"id":"63e17abc5dc27fcf","type":"change","z":"ab729eda43dcc3f4","name":"White","rules":[{"t":"set","p":"state","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":300,"wires":[["3b2d756216464775"]]},{"id":"b0d50114a51e81de","type":"change","z":"ab729eda43dcc3f4","name":"Blue","rules":[{"t":"set","p":"state","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":340,"wires":[["3b2d756216464775"]]},{"id":"e9deb8f6af42c626","type":"change","z":"ab729eda43dcc3f4","name":"Green","rules":[{"t":"set","p":"state","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":380,"wires":[["3b2d756216464775"]]},{"id":"b333ba0c5ce645de","type":"change","z":"ab729eda43dcc3f4","name":"Red","rules":[{"t":"set","p":"state","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":420,"wires":[["3b2d756216464775"]]},{"id":"60c132babe623cba","type":"change","z":"ab729eda43dcc3f4","name":"Assign Color Button value","rules":[{"t":"set","p":"button","pt":"msg","to":"msg.button + 6","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":360,"wires":[["0aa95e3cfea7c674"]]},{"id":"5fb759acac9537b6","type":"switch","z":"ab729eda43dcc3f4","name":"Check if state set","property":"state","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":450,"y":60,"wires":[["de8cad69e6b6fbde"]]},{"id":"29421d152ee928b5","type":"api-call-service","z":"ab729eda43dcc3f4","name":"Send State Message","server":"711466b6fc712a78","version":5,"debugenabled":false,"domain":"zwave_js","service":"set_config_parameter","areaId":[],"deviceId":["{{flow.var_device}}"],"entityId":[],"data":"{\"parameter\":msg.button,\"value\":msg.state}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"action","propertyType":"msg","value":"set_state","valueType":"str"}],"queue":"none","x":940,"y":200,"wires":[["79974120ad27b1c6"]]},{"id":"711466b6fc712a78","type":"server","name":"Home Assistant","version":5,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":": ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"default","statusTimeFormat":"h:m","enableGlobalContextStore":false}]