Esphome example deep sleep

From Notebook
Revision as of 12:19, 20 April 2024 by Steve (talk | contribs) (Created page with "==Deep Sleep (API)== In my Lovelace front end, I have a button to turn on a helper entity: <b>input_boolean.jeep_ota_mode</b>.<br> In the ESP yaml code, the first thing I do (on_boot) is to check this flag.<br> If the flag is on, I prevent deep sleep: <b> - deep_sleep.prevent: deep_sleep_handler</b><br> <nowiki># This is the ESP device inside the Jeep to provide presence (status=connected). substitutions: device_name: jeep friendly_name: jeep packages: wifi: !in...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Deep Sleep (API)

In my Lovelace front end, I have a button to turn on a helper entity: input_boolean.jeep_ota_mode.
In the ESP yaml code, the first thing I do (on_boot) is to check this flag.
If the flag is on, I prevent deep sleep: - deep_sleep.prevent: deep_sleep_handler

# This is the ESP device inside the Jeep to provide presence (status=connected).
substitutions:
  device_name: jeep
  friendly_name: jeep

packages:
  wifi: !include common/wifi.yaml
  device_base: !include common/esp8266.yaml

esphome:
  on_boot:
    priority: -100.0
    then:
      - delay: 1s
      - script.execute: test_ota



binary_sensor:
  - platform: status
    name: "Jeep Status"
  - platform: homeassistant
    id: otamode
    entity_id: input_boolean.jeep_ota_mode
    
    
    
#################################################    
# Script to test if the otamode switch is on or off
script:
  - id: test_ota
    mode: queued
    then:
      - logger.log: "Checking OTA Mode"
      - if:
          condition:
            binary_sensor.is_on: otamode
          then:
            - logger.log: 'OTA Mode ON'
            - deep_sleep.prevent: deep_sleep_handler
          else:
            - logger.log: 'OTA Mode OFF'
      - delay: 2s
      - script.execute: test_ota


    
#################################################
#Deep Sleep
deep_sleep:
  id: deep_sleep_handler
  run_duration: 5s
  sleep_duration: 120s
  




(TOP)