Esphome Captive Portal

I would like to control programmatically the captive portal in ESPHOME.
Is there an API/example to follow?

Thank for the link, but I would like to have control over that from withing an ESPHOME custom component.
I am looking to have the captive portal stopped/started when a user presses a button on the device in order to reconfigure the SSID/PASSWORD (through the portal’s page obviously).

I was also wondering how smart captive portal is.

Currently to me it is not clear how it works:

  • it starts the captive portal 1 minute after WiFi network is not available
  • it is not clear if the captive portal is stopped if WiFi network comes back, for example, after 2 minutes

1 minute is really a short time in fact

If your device doesn’t connect within one minute of boot is not likely to do so ever.

Your reply is slightly off-topic. I understand what the current captive configuration is doing, but I need an API to control it.
I guess ESPHOME as far as I know has no such capabilities currently.

Not that I can see. Maybe raise an issue on esphome github?

Well consider as use case a router firmware upgrade.
It takes more than 1 minute and as result you will have N esp to reconnect manually?

In my case N would be 25+ so not very handy :slight_smile:

Again OT. Please start another thread.

Just to answer your comment. I did some additional tests. The 1 minute is a default for the captive portal to startup when no WiFi has been detected. ESPHome does not seem to show the captive portal but resets the ESP8266 every minute. This cannot be disabled but the timeout could be changed, DO NOT set it to 0 as it wil keep on resetting every second or so and it won’t be possible to do an OTA.

Here is my configuration:


wifi:
  ssid: "xx"
  password: "xx"
  fast_connect: true
  reboot_timeout: 0s

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "xx"
    password: "xx"
    # cannot be 0, if no wifi a reset will occur after this timeout
    ap_timeout: 60min

captive_portal:

1 Like

It will stop the captive portal and switch back to Wi-Fi autimatically. Have just confirmed that with 5 of my ESP32 controllers.

The comments slightly went off topic to this, but curious if you found a way to have the user save/reconfigure the SSID/Password on demand?

Is it possible to enable the Captive portal remotely, preferably via the MQTT protocol. This is necessary to update modules working on the MQTT protocol, far from the server without removing the module.

1 Like

also interested for security purpose to manually enable/disable the capture portal, like a press of a button or other event like receive canbus message or serial.

Maybe use SmartConfig in that case?