Enable access point mode on demand?

Is there a way at present to force an ESPHome device to switch to access point mode?

My setup is that I hard code wifi networks and IP addresses to all my devices to maximize reliability and minimize flash memory usage. This works fine.

However if I replace a device, then the old device - if it has the same IP - on power up will find it’s old wifi SSID and reconnect immediately with that IP.

What I’d like to be able to do is use one of the normal factory default/safe mode buttons to force the device to start AP mode even if the wifi is discovered.

Is there any way to request AP mode from a button press?

Why not power up the device connected to a computer. You can then update the IP/YAML straight away and update via the cable and not OTA. You could also use a different IP for the new device. Unless a device has failed my IP’s remain linked to that device.

I haven’t read anywhere that AP can be forced. You could power up outside your wifi range and then AP would start.

Not sure how adding AP to image helps to

Esphome documentation tells :
“ap_timeout (Optional, Time): The time after which to enable the configured fallback hotspot. Can be disabled by setting this to 0s, which requires manually starting the AP by other means (eg: from a button press). Defaults to 1min.”

But obviously doesn’t tell how…
I had a look a the wifi component library and in case of timeout it calls function:
void WiFiComponent::setup_ap_config_()
You could try to call that in labda.