Created
December 10, 2025 04:46
-
-
Save RagingRoosevelt/ead3345c577192ae07c35bd792f4150b to your computer and use it in GitHub Desktop.
ESPHome Deep Sleep Mailbox Monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Physical Wiring | |
| # | |
| # ESP32-C3 NC Switch | |
| # ┌──────┐ ┌──────┐ | |
| # │ │ │ │ | |
| # │GPIO3 ├──────────┤ • │ (• = common terminal) | |
| # │ │ │ │ | |
| # │ │ ┌───┤ • │ (• = NC terminal) | |
| # │ │ │ └──────┘ | |
| # │ GND ├──────┘ | |
| # └──────┘ | |
| esphome: | |
| name: esphome-mailbox | |
| friendly_name: Mailbox | |
| on_boot: | |
| priority: -100 | |
| then: | |
| # Wait a moment for everything to initialize | |
| - logger.log: "Delaying for 2m to check for sleep conditions" | |
| - delay: 120s | |
| - if: | |
| condition: | |
| binary_sensor.is_off: mailbox_door | |
| then: | |
| - logger.log: "Going to sleep" | |
| - delay: 2s | |
| - deep_sleep.enter: deep_sleep_control | |
| else: | |
| - logger.log: "Door no longer closed, skipping sleep" | |
| esp32: | |
| board: esp32-c3-devkitm-1 | |
| framework: | |
| type: arduino | |
| logger: | |
| level: DEBUG | |
| api: | |
| encryption: | |
| key: !secret api_key | |
| ota: | |
| - platform: esphome | |
| password: !secret ota_password | |
| wifi: | |
| networks: | |
| - ssid: !secret wifi_ssid | |
| password: !secret wifi_password | |
| priority: 10 | |
| - ssid: !secret secondary_wifi_ssid | |
| password: !secret secondary_wifi_password | |
| priority: 5 | |
| fast_connect: true | |
| power_save_mode: light | |
| time: | |
| - platform: homeassistant | |
| id: homeassistant_time | |
| captive_portal: | |
| # Deep sleep configuration | |
| deep_sleep: | |
| id: deep_sleep_control | |
| # Wake when GPIO3 goes HIGH (switch opens - NC switch) | |
| wakeup_pin: | |
| number: GPIO3 | |
| allow_other_uses: True | |
| wakeup_pin_mode: INVERT_WAKEUP | |
| # Binary sensor for Home Assistant | |
| binary_sensor: | |
| - platform: gpio | |
| name: "Mailbox Door" | |
| id: mailbox_door | |
| device_class: opening | |
| pin: | |
| number: GPIO3 | |
| mode: | |
| input: true | |
| pullup: true | |
| inverted: true # Wake on HIGH (switch opens) | |
| allow_other_uses: True | |
| on_release: | |
| then: | |
| - logger.log: "Door closed, delaying for 2m to check for sleep conditions" | |
| - delay: 120s # Stay awake for 30 seconds | |
| - if: | |
| condition: | |
| binary_sensor.is_off: mailbox_door | |
| then: | |
| - logger.log: "Door still closed, going to sleep" | |
| - deep_sleep.enter: deep_sleep_control | |
| else: | |
| - logger.log: "Door no longer closed, skipping sleep" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment