I am using mosquitto mqtt. If I turn the switch to ‘ON’ in open hab application. I have written a program in NODE MCU 12E board to trigger a relay. Its working fine. But my problem is, In rare case if my Node mcu gets restart my relay goes to off state, but switch state in OPEN HAB app is in ‘ON’ state. How to sync the state of the topic to my NODE MCU on restart…
Also If am outside my home I am controlling my devices. How should I ensure it is responded correctly. Some time If am outside, I will switch on the light in OPENHAB app… but in rare case my device have not responded. but stiill state of light is ‘ON’ in my app.