I have a wemos d1 mini setup to operate my garage door. It’s been working flawlessly except for one thing.
When the ESP8266 loses wifi connection and reconnects to wifi and the MQTT server - the relay is triggered and my garage door opens, even if I am away from the house without any new MQTT messages being published.
How can I resolve this – here is the code - https://gist.github.com/hink/8f3444a7dab1b669a9a5362c31c99fc6
This may be due to the message with the topic and payload to open the garage has been retained in broker database. You can check this by subscribing to all topics in the broker with a client and check to see if the topic and payload are displayed immediately when the client connects.
Such as
mosquitto_sub -t '#' -v
The broker database entry can only be cleared by sending a message with that topic and a null payload with the retain flag set
mosquitto_pub -t <topic to open garage> -r -n
You may need additional parameters for the host, username and password, depending on your broker setup.
In addition to what @gpbenton says, check your HA configuration, what is the mqtt setup for the garage door?
Thanks. My cover in HA is set to retain. I’ll set that to false and test again. That makes perfect sense
Setting it to false in HA does not remove it from the database, so you will still need to issue the command I stated above to do that.
That was the issue! Thanks again. I’m all set.