Esphome example deep sleep: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
<div id="Index"></div> | |||
==Deep Sleep (API)== | ==Deep Sleep (API)== | ||
This is an example of how I use Deep Sleep on the ESP8266-01 module in my Jeep.<br> | This is an example of how I use Deep Sleep on the ESP8266-01 module in my Jeep.<br> |
Latest revision as of 08:51, 21 April 2024
Deep Sleep (API)[edit]
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