substitutions:
  device_name: bedroom_tkm_lily1
  device_ip: 192.168.87.44

esphome:
  name: ${device_name}
  platform: ESP32
  board: esp32dev
  on_boot:
    - priority: 900 #900 tried down to 500
      then:
        - lambda: |-
            id(wake_up_reason) = log(esp_sleep_get_ext1_wakeup_status())/log(2);

<<: !include standard_wifi.yaml
logger:
    level: INFO
api:
ota:
<<: !include standard_mqtt_deepsleep.yaml
deep_sleep:
        run_duration: 20s
        sleep_duration: 8h #40s #24h
        esp32_ext1_wakeup: 
                pins: 
                  - 33 #middle button
                  - 34 #T button
                  - 35 #L button
                mode: ANY_HIGH
        id: deep_sleep_1

globals:
        - id: wake_up_reason
          type: int
          restore_value: no
          initial_value: '0'
sensor:
  - platform: template
    name: "Remote Control Wake Reason"
    accuracy_decimals: 0
    lambda: |-
            return id(wake_up_reason);

binary_sensor:
  - platform: gpio
    pin: 
        number: GPIO33
        mode: INPUT_PULLUP
    filters:
      - delayed_on: 100ms ### <---- debounce time, was 100ms
      # - delayed_off: 10s ### <---- delay to capture state change on wake up         
    name: "TKM Test 33 middle button"
    id: tkm_test_33
  - platform: gpio
    pin: 
        number: GPIO34
        mode: INPUT_PULLUP
    filters:
      - delayed_on: 100ms ### <---- debounce time, was 100ms
      # - delayed_off: 10s ### <---- delay to capture state change on wake up             
    name: "TKM Test 34 T button"
    id: tkm_test_34
  - platform: gpio
    pin: 
        number: GPIO35
        mode: INPUT_PULLUP
    filters:
      - delayed_on: 100ms ### <---- debounce time, was 100ms
    name: "TKM Test 35 L button"
    id: tkm_test35