Autoreset option in case of not connection with the mqtt broker

this is my first post and sorry if I’m doing something wrong! I just want to suggest a new feature and I created a PR ( in order to improve the management of config reset. The autoreset in case of missing connection with the mqtt broker.

Below my case:
I wrongly added a good wifi configuration but I missed real ip for the mqtt broker.
So the OMG started to log message that something doesn’t work and notified me to push TRIGGER_GPIO… but I haven’t configured it (ESP32). In the meantime, I have tried with arduino ide to reset the config, but I couldn’t (I am not an expert in arduino ide). As bottom line I discovered the code and I forced the erase without hardware interrupt.

Basically, I saw that there is already a connection failure management in the code, I extended it by adding a new flag that allows autoreset if configured. I thought of putting it in good shape and proposing it as a feature.

Tell me what you think about it, all comment are welcome.

Hello and welcome,

Thanks for the PR,
for info this functionality was available before v0.9.4 :slight_smile:
And enabled by default.

But it generated a lot of unwanted reset for the users, for example in case of an electricity shut down the gateway restart, doesn’t find the broker and erase the credentials…

So I removed it, and now I have far less complains of reboot and user having to enter their credentials again.

If we go to your need, you would like to have an easy way to erase the credentials when entered wrongly isn’t it?

:face_with_hand_over_mouth: Ok I was late with the feature! sorry for that but I have just start to use the current release of OMG and when I was in trouble I moved on develop with my customization.

Yes, I think the missing aspect is the edit of configuration when it is wrong. I see the process to restart of wifi in case of problem, but after that if you have some problem you can’t modify other aspect at all except with the hardware reset (if you have the ability to perform it) or via broker.

My solution is drastic, I admit it and for this reason I have added a lot of precondition: is possible to enable it only if is not present the trigger_cpo, if the user have explicitly enabled it and it works only if it’s never connected the broker (if you connect once the whole mechanism is not activated anymore) and anyway after about 40 failed attempts to connect to the broker.

Another possible and elegant solution is to provide OMG a web-admin that only works if the WifiManager is able to connect the device to Wifi. But I think this is much more than that, not so much for development, maybe more effort comes for security.

what you think about it?

No problem, sometimes planet are aligned sometimes not :slight_smile:

Agreed indeed

Unfortunately, I think it happens quite often to lose the broker on the DIY home automation world :roll_eyes:

I’m thinking of using Autoconnect which propose this kind of HMI, I think it could answer the use case.

Another possibility could be to use a hidden functionality of the EPS32, the hall sensor.
By detecting if a magnet is put and removed 2 times for example, we could trigger the reset.
I have never tested the hall sensor so just an idea to explore.

If you are interested you are welcome to participate in either of the implementations.

I do not know Autoconnect, but I am not clear the difference between Wifimanager and Autoconnect.
why are you evaluating this? [cut]

Autoconnect provides a portal even when the wifi connection is done.