Hi all
I am trying to create a simple sketch where by I can put a d1 mini esp32 in to deep sleep for a predetermined time by pressing a switch in home assistant. Once the time has elapsed and the mini wakes up I want to stay awake until the switch is pressed again.
The first bit works fine, the program loads a waiting until the switch is pressed but then the sleep process just cycles.
I think it is because the ‘switch on’ status is stored when the sleep starts so the program thinks the switch is pressed constantly.
Any ideas how to stop this would be gratefully appreciated .
> esphome:
> name: battery_esp32
> platform: ESP32
> board: esp-wrover-kit
>
> wifi:
> ssid: ""
> password: ""
>
> # Enable fallback hotspot (captive portal) in case wifi connection fails
> ap:
> ssid: "Battery Esp32 Fallback Hotspot"
> password: ""
>
> captive_portal:
>
> # Enable logging
> logger:
>
> # Enable Home Assistant API
> api:
> password: ""
>
> ota:
> password: ""
>
>
> switch:
> - platform: gpio
> pin: 5
> name: sleep
> on_turn_on:
> - deep_sleep.enter: deep_sleep_1
> - logger.log: "Switch Turned On!"
> on_turn_off:
> - logger.log: "Switch Turned Off!"
> - deep_sleep.prevent: deep_sleep_1
>
>
> deep_sleep:
> id: deep_sleep_1
> sleep_duration: 20s