rbroker / ecodan-ha-local

Local HomeAssistant support for Air to Water Heat Pump Data/Control for Mitsubishi Ecodan
GNU General Public License v3.0
46 stars 10 forks source link

Error esp32 don't reconnect to Wifi AP #18

Closed limkinZero closed 8 months ago

limkinZero commented 8 months ago

Hi @rbroker ,

Merry Christmas! I think there is an issue when reconnecting to the Wi-Fi network if the router reboots.

This Christmas I noticed that when I was configuring my new router, the Ecodan local integration was not connecting to my Wi-Fi network. I had to press the reset button on the board for it to come back.

mharizanov commented 8 months ago

I had the same issue with my home setup of 4 ASUS routers in a mesh setup. Fixed it with a more aggressive reconnection strategy, see my branch here: https://github.com/rbroker/ecodan-ha-local/compare/main...mharizanov:ecodan-ha-local:main The code is too quick and dirty to request a merge though.

rbroker commented 8 months ago

I'll take a look. The code which resets the WiFi configuration tries to do that in case people's WiFi setup changes, so they don't need to physically access / re-flash things. I guess the restart from your fork is needed for that @mharizanov, which is missing from mine.

Out of interest was rebooting every 24h needed for you? Or just being defensive?

mharizanov commented 8 months ago

The code which resets the WiFi configuration tries to do that in case people's WiFi setup changes, so they don't need to physically access / re-flash things.

I understand, but that may also pose a security risk.

Out of interest was rebooting every 24h needed for you? Or just being defensive?

The 24-hour restart timer is just a precaution, I admit it is not the best of practices but it gives me peace of mind that worst-case downtime would be 24 hours.

rbroker commented 8 months ago

I understand, but that may also pose a security risk.

Yeah, fair enough. It should preserve the password for that reason, but I can see that no everyone would want that behaviour.

The 24-hour restart timer is just a precaution

Understood, thanks!

rbroker commented 8 months ago

I've made some changes in commit #97243e1 which extends the time we wait for WiFi reconnects to 10 mins, and will reset the board after those 10 mins if the WiFi connection hasn't been re-established (in theory it should figure it out if the SSID/password haven't changed because of this).

It'll now log when the WiFi connection is lost, and how long it takes to recover it too:

[00:07:54] WiFi disconnection detected... allowing up to 10 minutes to recover...
[00:08:42] WiFi connection re-established after (48) seconds.

There's now also a setting to stop the ESP32 falling back to captive portal mode if the connection can't be established on boot ("Auto-Reset WiFi Settings") for people who don't want it that (it'll just reboot every 10 minutes until the originally-configured WiFi network comes back)

Hopefully that improves things!

limkinZero commented 8 months ago

Thanks for your work Robert. I'll test it

mharizanov commented 7 months ago

This version works well in my Asus router mesh WiFi setup. Thanks!

limkinZero commented 7 months ago

Yes, me too! Works with my Asus wifi mesh.

El mié, 10 ene 2024, 11:00, Martin Harizanov @.***> escribió:

This version works well in my Asus router mesh WiFi setup. Thanks!

— Reply to this email directly, view it on GitHub https://github.com/rbroker/ecodan-ha-local/issues/18#issuecomment-1884533080, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADLQJD6KRW6QSVFOQYCAEJ3YNZRCFAVCNFSM6AAAAABBPBQ2ASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBUGUZTGMBYGA . You are receiving this because you authored the thread.Message ID: @.***>