I have a set of buttons that send different state commands to a controlled device.
I want the button state to reflect the realtime status of the controlled device, so I am using the feedback to set the correct button as "active" and the others as "inactive".
However, I also need to delay how quickly commands can be sent, so I want to disable all buttons for a certain amount of time after pressing one of them.
Reaching either of these goals is easily achievable, but I am having a hard time trying to combine them into a complete system.
I am attaching a basic flow demonstrating the issue. Since I can't include the actual device feedback I added a simple delay on the button press which does the same thing for the purposes of demonstrating the issue.
When I press "State 1", both buttons are disabled. When I get the feedback that the device is in "State 1", the background and text colors change as expected. However, when the timer expires and the buttons are enabled again, they return to the default dashboard universal button state and I lose the state feedback.
Is this not possible without adding a bunch of extra state-tracking logic to restore the correct button state after it is wiped? Shouldn't the enable command only enable the buttons, not modify their other attributes?
[{"id":"dab9bb38.6245e8","type":"ui_button","z":"f1d06a71.51424","name":"State 2","group":"dd64112c.15ad78","order":22,"width":0,"height":0,"passthru":false,"label":"State 2","tooltip":"","color":"{{msg.color}}","bgcolor":"{{msg.background}}","icon":"","payload":"2","payloadType":"str","topic":"","x":300,"y":180,"wires":[["c35c5e66.d510d","e4419de7.65b02"]]},{"id":"6ff77c47.0a405c","type":"ui_button","z":"f1d06a71.51424","name":"State 1","group":"dd64112c.15ad78","order":21,"width":0,"height":0,"passthru":false,"label":"State 1","tooltip":"","color":"{{msg.color}}","bgcolor":"{{msg.background}}","icon":"","payload":"1","payloadType":"str","topic":"","x":300,"y":140,"wires":[["e4419de7.65b02","5feca31a.ea4b8c"]]},{"id":"c35c5e66.d510d","type":"change","z":"f1d06a71.51424","name":"Disable State Buttons","rules":[{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":180,"wires":[["ea991425.141e38","52f9a2c1.ec5034"]]},{"id":"ea991425.141e38","type":"link out","z":"f1d06a71.51424","name":"Button Control","links":["87de42d.51a28c"],"x":675,"y":240,"wires":[]},{"id":"52f9a2c1.ec5034","type":"delay","z":"f1d06a71.51424","name":"Wait 5 Seconds","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":760,"y":140,"wires":[["7507aec3.a90c48"]]},{"id":"7507aec3.a90c48","type":"change","z":"f1d06a71.51424","name":"Re-Enable State Buttons","rules":[{"t":"set","p":"enabled","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":180,"wires":[["ea991425.141e38"]]},{"id":"87de42d.51a28c","type":"link in","z":"f1d06a71.51424","name":"Button Control","links":["ea991425.141e38"],"x":175,"y":160,"wires":[["6ff77c47.0a405c","dab9bb38.6245e8"]]},{"id":"5feca31a.ea4b8c","type":"change","z":"f1d06a71.51424","name":"Disable State Buttons","rules":[{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":140,"wires":[["ea991425.141e38","52f9a2c1.ec5034"]]},{"id":"c8ca7726.51e9","type":"function","z":"f1d06a71.51424","name":"Button State","func":"let source = msg.payload\nif (source == \"1\"){\n msg1 = {background:\"#0094CE\", color:\"white\"}\n msg2 = {background:\"#036288\", color:\"grey\"}\n}\nelse if (source == \"2\"){\n msg2 = {background:\"#0094CE\", color:\"white\"}\n msg1 = {background:\"#036288\", color:\"grey\"}\n}\n\nreturn [msg1, msg2];","outputs":2,"noerr":0,"x":450,"y":240,"wires":[["6ff77c47.0a405c"],["dab9bb38.6245e8"]]},{"id":"e4419de7.65b02","type":"delay","z":"f1d06a71.51424","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":290,"y":240,"wires":[["c8ca7726.51e9"]]},{"id":"dd64112c.15ad78","type":"ui_group","z":"","name":"Test","tab":"6d2ffe37.0d7c8","disp":true,"width":"6","collapse":false},{"id":"6d2ffe37.0d7c8","type":"ui_tab","z":"","name":"Test","icon":"dashboard","disabled":false,"hidden":false}]