Manually entering captive portal

In the documentation for the wifi component there is the setting for ap_timeout. Which states "

That last bit is in which I’m interested. Instead of defaulting to an AP which everybody can access when I reboot my access point, I would like to be able to trigger that from software. For example by holding the button. But even though the documentation states it should be an option, I still have not found a way to do it!

A Factory Reset Switch would trigger the captive portal but it does wayyyyy more. I would just like to manually enter the AP-mode with captive portal. Anybody any idea?

Yes, hard to see the way straight off. Perhaps using

https://esphome.io/components/wifi.html#wifi-enable-action

The - wifi.enable: did not work for me.
I have got it to work with this:

script:
  - id: wifi_temp_on
    mode: restart
    then:
      - lambda: WiFi.mode(WIFI_AP);
      - delay: 10min
      - lambda: WiFi.mode(WIFI_OFF);

But this enables the default ESP WIFI (Not ESP-Home WIFI) without password

Thank you for the help both! You answers help me to confirm it is indeed an oversight in ESPHome :smiley:

@Hellis81 I first tried to use the actions directly in a template button. That only resulted in the device becoming ‘unavailable’ in HA for a split second. After which I made the same script and used that in the template button. That indeed results in an AP (ESP_xxxxxx) without password. But I’m not able to connect to it. Can you connect?

Yes I can connect to it.
You need to open 192.168.4.1 in the browser

I’ll give it a try in the coming days. But I wasn’t even able to connect to the AP :confused:

Did you test with a ESP32 or ESP8266?

I have tried on a ESP32 S2.
Have not tried on the S3 yet but I will probably try it tomorrow.