Last active
January 13, 2022 23:09
-
-
Save tathamoddie/dc11892d1499996f51cbf2ab918587ef to your computer and use it in GitHub Desktop.
This file contains 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
substitutions: | |
device_name: demo_deepsleep | |
friendly_name: Demo Deep Sleep | |
## Board config | |
esphome: | |
name: ${device_name} | |
platform: ESP32 | |
board: m5stack-core-esp32 | |
on_boot: | |
then: | |
- light.turn_on: status_led | |
- script.execute: consider_deep_sleep | |
## Boilerplate, same for all devices | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
power_save_mode: none | |
ap: | |
ssid: Fallback ${device_name} | |
logger: | |
api: | |
password: !secret esphome_secret | |
ota: | |
password: !secret esphome_secret | |
## Hardware | |
light: | |
- platform: fastled_clockless | |
chipset: WS2812B | |
pin: 27 | |
num_leds: 1 | |
rgb_order: GRB | |
id: status_led | |
## Deep Sleep | |
deep_sleep: | |
id: deep_sleep_control | |
sleep_duration: 30s | |
# Will only pick up a value if this device is configured in Home Assistant > Integrations | |
# If the device isn't configured, or Home Assistant is offline, it'll default to false | |
binary_sensor: | |
- platform: homeassistant | |
id: prevent_deep_sleep | |
entity_id: input_boolean.prevent_deep_sleep | |
script: | |
- id: consider_deep_sleep | |
mode: queued | |
then: | |
- delay: 10s | |
- if: | |
condition: | |
binary_sensor.is_on: prevent_deep_sleep | |
then: | |
- logger.log: 'Skipping sleep, per prevent_deep_sleep' | |
else: | |
- deep_sleep.enter: deep_sleep_control | |
- script.execute: consider_deep_sleep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you please share the code for nodemcu esp3266 device i tried to change the board but it doesn't work
https://community.home-assistant.io/t/cant-create-id-to-check-a-toggle-button-for-deep-sleep-in-home-assistant-for-ota-update-on-nodemcu/301545