Guys, i have just started using the Dashboard Switch component and would like to be able to set its iniitial state after a Node-Red restart/reload/reboot to the same as the real world device that it is controlling. Likewise if the Arduino that is physically attached to the relay is restarted i would like it to transmit the new state back to the NR instance and for that to be reflected in the switch
Yep just saw that as i had the Debug window selected as was not seeing the node info - also found this thread - time to start playing around and seeing how this works
The way I handle such issues is to have a Retained topic in MQTT which represents the current status. Then on startup that value can be sent to the device and also initiates the display state of the dashboard switch. The output of the dashboard switch does not need to directly control the device, it just sets the value in MQTT, then the same nodes that pick up the state on startup will pick it up and send it to the device.
Listening the event of dashboard connection allow you to feed stored state to switch or button nodes and your widgets are always "up to date" at the moment you are opened the dashboard page. Included reloads and deploy events.
Absolutely. Just the MQTT is one of many possible communication protocols you can use with Node-RED and it really depends on project if it is reasonable choice to use or in some cases just include for state management. So I pointed out the other way and I think it is not bad thing to do so.
@hotNipi would you be able to expound on how to use the UI control node for my challange?
I have a UI switch node which can get it's state altered via an external input (433mhz) message, and also be controlled by the UI. Upon re-deploy or reboot, the state of that UI switch is lost, thus I wish to deploy a method to "remember" the state of the UI switch, then reset it (if necessary) to the state it was in prior to the reboot etc. Currently my UI switch is using a change node to set a flow.xxx and is storing hat in Persistable file storage
The ui_control node has ability to fire an event when dashboard connects to server. Connect it to the change node to retrieve last known state and send that state to the switch node.
This appears to be continuation of your previous thread. I thought we had a solution that did what you want. There is no point switching to an existing thread that is a year old. Please continue on that old thread or, since the thread title is not relevant to this issue then start a new thread with a relevant title. However, if you do that then start by posting the flow you currently have and explain what about it does not work.
Understood, but as I worked more on the solution that you have guided me with...I am finding unreliability issues. Thus I continued my investigation. I posted what I believe to be my biggest challenge with the reset switch state back in the other thread earlier. Thank you!