Esphome example deep sleep: Difference between revisions
Jump to navigation
Jump to search
| Line 3: | Line 3: | ||
The ESP is used to determine if the Jeep is "home". If the API connects, the Jeep is "home". | The ESP is used to determine if the Jeep is "home". If the API connects, the Jeep is "home". | ||
;How | ;How OTA Updates work: | ||
In my Lovelace front end, I have a button to turn on a helper entity: <b>input_boolean.jeep_ota_mode</b>.<br> | 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> | In the ESP yaml code, the first thing I do (on_boot) is to check this flag.<br> | ||
Revision as of 09:49, 21 April 2024
Deep Sleep (API)
This is an example of how I use Deep Sleep on the ESP8266-01 module in my Jeep.
The ESP is used to determine if the Jeep is "home". If the API connects, the Jeep is "home".
- How OTA Updates work
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