How to configure a ESPHome device to look for Wi-Fi in a loop?

I have Wi-Fi relays (Sonoff Basic for instance, flashed with ESPHome) that connect to my Wi-Fi. My Wi-Fi may be down, or the device may not want to connect (because, say, the Wi-Fi password was changed) and I would like to build the following configuration:

  • try to connect to a known SSID, say for 5 minutes
  • then open a ad-hoc hotspot (so that I can connect to the device), for, say 5 minutes
  • then try again the SSID for 5 minutes
  • and then the hotspot
  • etc.

Is this possible?

The documentation mentions several timeouts, but I did not find a way to create such a continuous loop

Pretty sure thats how the WIFI component works, you can set the ap timeout to 5 minutes:

I confirm what Holdestmade says - what you describe is default wifi behaviour for ESPHome. You only need to set the AP timeout.
Wifi will continuously search for the known SSID(s) though, no timeout needed for that.

@Holdestmade @andyfsimon Thanks for the answer.

Taking my actual configuration below, should I expect

  • the AP to fire up after 1 minute of not finding my Wi-Fi network
  • and staying up for 14 minutes, because after that the device reboots
  • and again search for 1 minute for the Wi-Fi network
  • and start the AP for 14 minutes, then reboot
  • etc.
wifi:
  domain: .mydomain
  ap:
    ssid: switch01
    password: apassword
    ap_timeout: 1min
  reboot_timeout: 15min
  power_save_mode: NONE
  fast_connect: false
  output_power: 20.0
  networks:
  - ssid: myssid
    password: thessidpassword
    priority: 0.0
  use_address: switch01.mydomain

Yes I think so. 15 minutes is the default for reboot_timeout, output_power default is 20 and fast_connect is default off so no need to specify those. And priority is only needed for multiple SSIDs (and default is 0)

1 Like

Thanks.

My configuration is much shorter as it only addresses the non-default values. This is the output from ESPHome verification that dumps all possible entries.