How can i disable reboot (in case of network loss) during runtime?

Hello

I am wonder how can i disable reboot (in case of network loss) during runtime?

I want to achieve the following (just don’t know how)

binary_sensor:
# Switch to select MODE (ESP/HOMASISTANT managed)
  - platform: gpio
    name: "GA_Kazan_Mode_Select"
    id: "GA_Kazan_Mode_Select"
    pin:
      number: GPIO5
      inverted: true
      mode:
        input: true
    on_press:
      then:
         ### wifi.reboot_timeout=0s ???  

    on_release:
      then:
         ### wifi.reboot_timeout=15min ???

In case for some disaster with my network i want to have some escape route so i switch a switch on and ESP local automatization can manage my hardware and after normalization of the situation i can give back the management to home assistant.

thank you

I think like this i would able to change this parameter:

    on_press:
      - lambda: |-
           WiFi.global_wifi_component.get_ap().set_reboot_timeout(0);

But unfortunately it is not working :frowning:

Looks like this is comply:

    on_release:
      - lambda: |-
          esphome::wifi::global_wifi_component->set_reboot_timeout(15*60);
    
    on_press:
      - lambda: |-
          esphome::wifi::global_wifi_component->set_reboot_timeout(0);

I wonder if it is really going to work like i want.