Deep Sleep on an ESP32 is driving me nuts. This is on an M5Stack Core Ink, here is the relevant config.
deep_sleep:
id: deep_sleep_mode
run_duration: 60s
sleep_duration: 1min
esphome:
name: ${name}
friendly_name: ${friendly_name}
name_add_mac_suffix: false
project:
name: esphome.web
version: '1.0'
on_boot:
priority: -100
then:
- wait_until:
condition:
wifi.connected
- delay: 60s
- deep_sleep.enter: deep_sleep_mode
binary_sensor:
- platform: gpio
id: bnt_left
name: BTN Left
pin: GPIO37
on_press:
then:
- logger.log: "LEFT was pressed - No Sleep"
- deep_sleep.prevent: deep_sleep_mode
- platform: gpio
id: bnt_right
name: BTN Right
pin: GPIO39
on_press:
then:
- logger.log: "Right was pressed - Sleep Resumed"
- deep_sleep.allow: deep_sleep_mode
As far as I understand, this should mean that the ESP32 will start and stay awake for 60s, deep sleep for 60s, wakes up for 60s…repeat. If I press the “Left” button, it will no longer deep sleep, until I press right. But that is simply not the case, as shown below:
The code snipped is the only code in my entire project related to deep_sleep. It shows the log “LEFT was pressed - No Sleep” then seconds later sleeps anyways. What in the name of PEBKAC am I missing?