This is a tricky one which has just come to light for me.
See flow.
The idea is that the "LED" can be turned on/off but pressing the on or off button.
Fair enough.
Here it is simple: all on one machine and on one screen.
The problem I have is not as easy.
I am wanting a way so I can have a button to press that will remember what was last pressed and re-send that.
So, say the machine on which the LED is rebooted/reset/what ever and it no longer knows the state of affairs for that LED, it can request the last known state to be re-sent to it.
For now I have a button for the sake of keeping it simple.
Anyone got any ideas on how to do this?
The flow has a comment node and function node "extra" which is leaning towards how I would think it could be done, but I am stuck with how to save that information and re-send it when the button is pressed.
[{"id":"482cb7b8.9089e8","type":"function","z":"ce6685c3.4b0cd","name":"Test","func":"msg.color = (msg.payload === \"ON\")?\"lime\":\"red\";\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":640,"wires":[["8f0ac71f.d1914"]]},{"id":"b9c17396.622c","type":"inject","z":"ce6685c3.4b0cd","name":"","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"x":320,"y":680,"wires":[["fa97900.48783f"]]},{"id":"8f0ac71f.d1914","type":"ui_text","z":"ce6685c3.4b0cd","group":"54ced452.f54c4c","order":1,"width":"3","height":"1","name":"","label":"LED","format":"<font color={{msg.color}} ><i class=\"fa fa-circle\" style=\"font-size:24px;\"></i></font>","layout":"row-left","x":910,"y":640,"wires":[]},{"id":"286b299e.170566","type":"inject","z":"ce6685c3.4b0cd","name":"","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"x":320,"y":600,"wires":[["6759ba0.1f3aa48"]]},{"id":"6759ba0.1f3aa48","type":"ui_button","z":"ce6685c3.4b0cd","name":"","group":"54ced452.f54c4c","order":2,"width":"3","height":"1","passthru":true,"label":"OFF","color":"","bgcolor":"","icon":"","payload":"OFF","payloadType":"str","topic":"","x":460,"y":600,"wires":[["482cb7b8.9089e8","481a6060.c53f48"]]},{"id":"fa97900.48783f","type":"ui_button","z":"ce6685c3.4b0cd","name":"","group":"54ced452.f54c4c","order":3,"width":"3","height":"1","passthru":true,"label":"ON","color":"","bgcolor":"","icon":"","payload":"ON","payloadType":"str","topic":"","x":460,"y":680,"wires":[["482cb7b8.9089e8","481a6060.c53f48"]]},{"id":"daae9940.ab86c","type":"comment","z":"ce6685c3.4b0cd","name":"Stuck here","info":"Below is sort of what is wanted.","x":650,"y":510,"wires":[]},{"id":"481a6060.c53f48","type":"function","z":"ce6685c3.4b0cd","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":550,"wires":[["ce36cb30.c24de"]]},{"id":"ce36cb30.c24de","type":"ui_button","z":"ce6685c3.4b0cd","name":"","group":"54ced452.f54c4c","order":2,"width":"3","height":"1","passthru":true,"label":"Resend","color":"","bgcolor":"","icon":"","payload":"???","payloadType":"str","topic":"","x":730,"y":550,"wires":[["8f0ac71f.d1914"]]},{"id":"54ced452.f54c4c","type":"ui_group","z":"","name":"LED Testing","tab":"bf921cba.037998","disp":true,"width":"3","collapse":false},{"id":"bf921cba.037998","type":"ui_tab","z":"","name":"Tab","icon":"home","order":1}]