Handle Wifi recover and captive portal AP

Hello,

I’m facing a problem and I can’t find a good way to handle this question right now.
I have HA and few esphome on a secondary house where I’m not all the time so it’s not possible to handle manual reboot easily.

For some time, HA or wifi can be unavailable due to maintenance, bug, etc.
After 1 minute, esphome wifi fallback to AP mode with captive portal. But once in AP, if wifi recover, the esp wifi will not recover in normal state without a manuel reboot.

What are your advices for this situation ? Maybe i’m missing a configuration to handle the ability to auto reboot esp after x minutes in fallback or after wifi recover ?

Thanks

Reboot_timeout

Hey @Hellis81,

Thanks but it’s written “Does not apply when in access point mode.”. I haven’t setup this prop so by default it’s 15m, and actually, even after 6 hours after wifi recovering, device are still in AP Mode

Is that HA connected over WiFi?

Hello @Nick4,

No HA is on wired cable and there is no problem with it. The current problem is that esphome device keep in AP Mode even after wifi recover and I have to do a manual restart to make them connected again to regular wifi mode

Owkay…

I would tackle the main issue - WiFi network - instead of bypassing it.

I don’t speak here of a regular problem in the wifi network but for example, ISP Provider made an upgrade on the router that put the wifi down for more than 1 minute and the ESP will go in AP Fallback mode and never recover when wifi goes up few minutes later.
ESP control the water heater that I want to put on before arriving at the house, I can’t without reboot the esp manually before. The system is not very resilient.

The strange thing is that it seems to be an esphome feature that the esp auto recover from ap mode when wifi is up again.

But I think I have not specific configuration than can disable this behavior

wifi:
  id: main_wifi
  networks:
    - ssid: !secret wifi_ssid
      password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    password: !secret fallback_ap_password

captive_portal:

I think I have seen a post to leave that part out…

Maybe it’s not bad to post the whole file so anyone with more knowledge then me with ESPHome can have a look at it…

I put my wifi in networks and not in wifi because I use a shared configuration for all my esp devices and in yaml merging it’s easier to merge the networks array than remove the ssid, password from root wifi component.
You saw that it’s less stable than root ssid and password ?

The whole config is very simple in my current test to handle this problem. It’s a device with only my shared config across all my nodes

esphome:
    name_add_mac_suffix: false
  
# Enable logging
logger:
    id: main_logger

web_server:
    id: main_webserver
    port: 80
    include_internal: true
    auth: 
        username: !secret basic_auth_user
        password: !secret basic_auth_password

ota:
  - platform: esphome
    password: !secret ota_password
    id: main_ota

wifi:
  id: main_wifi
  networks:
    - ssid: !secret wifi_ssid
      password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    password: !secret fallback_ap_password

captive_portal:

button:
  - platform: restart
    name: "Restart (Normal Mode)"
    internal: true
    id: button_restart_normal
  - platform: safe_mode
    name: "Restart (Safe Mode)"
    internal: true
    id: button_restart_safemode

sensor:
  - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
    name: "WiFi Signal dB"
    id: wifi_signal_db
    update_interval: 600s
    entity_category: "diagnostic"
  - platform: uptime
    id: uptime_sensor
    name: Uptime
    update_interval: 600s
    entity_category: "diagnostic"