Node-Red Flow Samples/Sharing

Hubitat group devices do not support the commands startLevelChange and stopLevelChange even if the individual devices within the group support those commands - for example zigbee bulbs that use the new Advanced Zigbee Bulb drivers, or other devices that support these commands.

So I created this sequence to approximate startLevelChange and stopLevelChange for group devices that are exposed to Node-RED. It works really well for me using a Pico remote to control a group of two zigbee bulbs. No popcorning, no jerky changes in level.

It works by saving the level of the group device to a flow variable and using that to calculate msg.arguments in repetitive steps that are 200 milliseconds apart (i.e. approximating a "held" action for startLevelChange). Releasing the button resets the reiterative timer, thereby approximating a stopLevelChange.

Sequence code:

[{"id":"a0abf5bc.dff248","type":"switch","z":"9cecb34b.b047c8","name":"1/2/3/4/5","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"5","vt":"num"}],"checkall":"true","repair":false,"outputs":5,"x":3520,"y":1740,"wires":[["d66182d6.93d2b8"],["6da2d826.4d05b"],["5379a442.f405d4"],["de8d5dd9.b4cb78"],["4b5228e.cfbb5d8"]]},{"id":"6da2d826.4d05b","type":"switch","z":"9cecb34b.b047c8","name":"pushed/held/released","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"pushed","vt":"str"},{"t":"eq","v":"held","vt":"str"},{"t":"eq","v":"released","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":3740,"y":1680,"wires":[["4ef9822d.52e8fc"],["9293c97a.518cb8"],["2ac61b11.701b9c"]]},{"id":"9293c97a.518cb8","type":"delay","z":"9cecb34b.b047c8","name":"200 ms","pauseType":"delay","timeout":"200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":4020,"y":1680,"wires":[["fbefe70e.f72b28"]]},{"id":"2ac61b11.701b9c","type":"change","z":"9cecb34b.b047c8","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":3895,"y":1700,"wires":[["9293c97a.518cb8"]],"l":false},{"id":"fbefe70e.f72b28","type":"change","z":"9cecb34b.b047c8","name":"raise","rules":[{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"$flowContext(\"gn_level\") + 3","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":4190,"y":1680,"wires":[["9293c97a.518cb8","65a9d48c.7e0fcc"]]},{"id":"de8d5dd9.b4cb78","type":"switch","z":"9cecb34b.b047c8","name":"pushed/held/released","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"pushed","vt":"str"},{"t":"eq","v":"held","vt":"str"},{"t":"eq","v":"released","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":3740,"y":1800,"wires":[["1a30ac21.8c5264"],["5c74d2bb.ca1e24"],["22a9038e.d950e4"]]},{"id":"5c74d2bb.ca1e24","type":"delay","z":"9cecb34b.b047c8","name":"200 ms","pauseType":"delay","timeout":"200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":4020,"y":1800,"wires":[["b9e49bc2.7ea398"]]},{"id":"22a9038e.d950e4","type":"change","z":"9cecb34b.b047c8","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":3895,"y":1820,"wires":[["5c74d2bb.ca1e24"]],"l":false},{"id":"b9e49bc2.7ea398","type":"change","z":"9cecb34b.b047c8","name":"lower","rules":[{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"$flowContext(\"gn_level\") - 3","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":4190,"y":1800,"wires":[["5c74d2bb.ca1e24","b7616fa2.94cc4"]]},{"id":"50ab32be.f7589c","type":"hubitat command","z":"9cecb34b.b047c8","deviceLabel":"Guest Nightstand","name":"","server":"a22e0ea9.276dc8","deviceId":"1482","command":"","commandArgs":"","x":4550,"y":1740,"wires":[[]]},{"id":"7591bac8.38e28c","type":"switch","z":"9cecb34b.b047c8","name":"0-100","property":"arguments","propertyType":"msg","rules":[{"t":"btwn","v":"0","vt":"num","v2":"100","v2t":"num"}],"checkall":"true","repair":false,"outputs":1,"x":4350,"y":1740,"wires":[["50ab32be.f7589c"]]},{"id":"d66182d6.93d2b8","type":"change","z":"9cecb34b.b047c8","name":"on 100%","rules":[{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":3700,"y":1620,"wires":[["50ab32be.f7589c"]]},{"id":"4b5228e.cfbb5d8","type":"change","z":"9cecb34b.b047c8","name":"off","rules":[{"t":"set","p":"command","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3690,"y":1860,"wires":[["50ab32be.f7589c"]]},{"id":"5379a442.f405d4","type":"change","z":"9cecb34b.b047c8","name":"on 50%","rules":[{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"50","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":3700,"y":1740,"wires":[["50ab32be.f7589c"]]},{"id":"4ef9822d.52e8fc","type":"change","z":"9cecb34b.b047c8","name":"raise by 5","rules":[{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"$flowContext(\"gn_level\") + 5","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":3895,"y":1660,"wires":[["50ab32be.f7589c"]],"l":false},{"id":"1a30ac21.8c5264","type":"change","z":"9cecb34b.b047c8","name":"lower by 5","rules":[{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"$flowContext(\"gn_level\") - 5","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":3895,"y":1780,"wires":[["50ab32be.f7589c"]],"l":false},{"id":"65a9d48c.7e0fcc","type":"function","z":"9cecb34b.b047c8","name":"","func":"if (msg.arguments > 100) {\n    msg.arguments = 100\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":4295,"y":1680,"wires":[["7591bac8.38e28c"]],"l":false},{"id":"b7616fa2.94cc4","type":"function","z":"9cecb34b.b047c8","name":"","func":"if (msg.arguments < 0) {\n    msg.arguments = 0\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":4295,"y":1800,"wires":[["7591bac8.38e28c"]],"l":false},{"id":"52498b04.53727c","type":"hubitat device","z":"9cecb34b.b047c8","name":"Guest Nightstand level","server":"a22e0ea9.276dc8","deviceId":"1482","attribute":"level","sendEvent":true,"x":4090,"y":1580,"wires":[["e6e48278.ee0f"]]},{"id":"e6e48278.ee0f","type":"change","z":"9cecb34b.b047c8","name":"flow.gn_level","rules":[{"t":"set","p":"gn_level","pt":"flow","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":4310,"y":1580,"wires":[[]]},{"id":"7887fb68.739014","type":"hubitat device","z":"9cecb34b.b047c8","deviceLabel":"Guest Bedroom Pico Hold","name":"Guest Bedroom Pico","server":"662851c4.3ccad","deviceId":"22","attribute":"","sendEvent":true,"x":3300,"y":1740,"wires":[["a0abf5bc.dff248"]]},{"id":"a22e0ea9.276dc8","type":"hubitat config","name":"HubitatM","usetls":false,"host":"192.168.1.46","port":"80","appId":"1522","nodeRedServer":"http://192.168.1.4:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false},{"id":"662851c4.3ccad","type":"hubitat config","name":"HubitatS","usetls":false,"host":"192.168.1.36","port":"80","appId":"4489","nodeRedServer":"http://192.168.1.4:1880","webhookPath":"/hubitat/webhook2","autoRefresh":true,"useWebsocket":false}]
5 Likes