Edit esp-reterminal-e1001.yaml
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-reterminal-e1001.yaml
|
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-reterminal-e1001.yaml
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# VERSIONS:
|
# VERSIONS:
|
||||||
|
# V0.9.5 2026-08-02 Hardened deep-sleep control and startup data validation;
|
||||||
|
# added a Home Assistant wake-cause diagnostic.
|
||||||
# V0.9.4 2026-07-30 Status sub-line shows ago/due-in time; COMPLETED shows
|
# V0.9.4 2026-07-30 Status sub-line shows ago/due-in time; COMPLETED shows
|
||||||
# last_completed_human (15:45/Yesterday @/X days ago @);
|
# last_completed_human (15:45/Yesterday @/X days ago @);
|
||||||
# PIR retrigger guard verified; renamed jobs.
|
# PIR retrigger guard verified; renamed jobs.
|
||||||
@@ -89,7 +91,7 @@ substitutions:
|
|||||||
|
|
||||||
# Project Naming
|
# Project Naming
|
||||||
project_name: "SeeedStudio.reTerminal-E1001"
|
project_name: "SeeedStudio.reTerminal-E1001"
|
||||||
project_version: "v0.9.4"
|
project_version: "v0.9.5"
|
||||||
|
|
||||||
# Passwords and Secrets
|
# Passwords and Secrets
|
||||||
api_key: !secret esp-api_key
|
api_key: !secret esp-api_key
|
||||||
@@ -202,6 +204,8 @@ esphome:
|
|||||||
- deep_sleep.prevent: deep_sleep_1
|
- deep_sleep.prevent: deep_sleep_1
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(sleep_allowed) = false;
|
id(sleep_allowed) = false;
|
||||||
|
id(mqtt_sleep_command_received) = false;
|
||||||
|
id(ha_data_ready) = false;
|
||||||
id(boot_sequence_complete) = false;
|
id(boot_sequence_complete) = false;
|
||||||
id(last_activity_ms) = millis();
|
id(last_activity_ms) = millis();
|
||||||
id(awake_timeout_ms) = ${button_wake_awake_seconds} * 1000UL;
|
id(awake_timeout_ms) = ${button_wake_awake_seconds} * 1000UL;
|
||||||
@@ -212,6 +216,10 @@ esphome:
|
|||||||
#:####################################################################################:#
|
#:####################################################################################:#
|
||||||
- priority: -100
|
- priority: -100
|
||||||
then:
|
then:
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: wakeup_cause_sensor
|
||||||
|
state: !lambda "return id(wakeup_cause);"
|
||||||
|
|
||||||
- wait_until:
|
- wait_until:
|
||||||
condition:
|
condition:
|
||||||
mqtt.connected:
|
mqtt.connected:
|
||||||
@@ -222,14 +230,21 @@ esphome:
|
|||||||
not:
|
not:
|
||||||
mqtt.connected:
|
mqtt.connected:
|
||||||
then:
|
then:
|
||||||
- logger.log: "MQTT unavailable after ${mqtt_connect_timeout}; allowing fallback sleep for battery protection."
|
- logger.log: "MQTT unavailable after ${mqtt_connect_timeout}."
|
||||||
- lambda: |-
|
|
||||||
id(sleep_allowed) = true;
|
|
||||||
- deep_sleep.allow: deep_sleep_1
|
|
||||||
else:
|
else:
|
||||||
# Allow time for the retained deepsleep command to be delivered.
|
# Allow time for the retained deepsleep command to be delivered.
|
||||||
- delay: 2s
|
- delay: 2s
|
||||||
|
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
lambda: |-
|
||||||
|
return !id(mqtt_sleep_command_received);
|
||||||
|
then:
|
||||||
|
- logger.log: "No valid retained deep-sleep command received; allowing normal sleep for battery protection."
|
||||||
|
- lambda: |-
|
||||||
|
id(sleep_allowed) = true;
|
||||||
|
- deep_sleep.allow: deep_sleep_1
|
||||||
|
|
||||||
- wait_until:
|
- wait_until:
|
||||||
condition:
|
condition:
|
||||||
api.connected:
|
api.connected:
|
||||||
@@ -261,12 +276,34 @@ esphome:
|
|||||||
id(job_empty_washing_machine_due_ts).has_state();
|
id(job_empty_washing_machine_due_ts).has_state();
|
||||||
timeout: "${ha_data_timeout}"
|
timeout: "${ha_data_timeout}"
|
||||||
|
|
||||||
|
- lambda: |-
|
||||||
|
id(ha_data_ready) =
|
||||||
|
id(homeassistant_time).now().is_valid() &&
|
||||||
|
id(job_dog_feeding_morning_state).has_state() &&
|
||||||
|
id(job_dog_feeding_evening_state).has_state() &&
|
||||||
|
id(job_dog_depooping_state).has_state() &&
|
||||||
|
id(job_dishwasher_unpacked_state).has_state() &&
|
||||||
|
id(job_rubbish_removed_state).has_state() &&
|
||||||
|
id(job_water_tv_pot_plant_state).has_state() &&
|
||||||
|
id(job_water_table_pot_plant_state).has_state() &&
|
||||||
|
id(job_empty_dryer_state).has_state() &&
|
||||||
|
id(job_empty_washing_machine_state).has_state() &&
|
||||||
|
id(job_dog_feeding_morning_due_ts).has_state() &&
|
||||||
|
id(job_dog_feeding_evening_due_ts).has_state() &&
|
||||||
|
id(job_dog_depooping_due_ts).has_state() &&
|
||||||
|
id(job_dishwasher_unpacked_due_ts).has_state() &&
|
||||||
|
id(job_rubbish_removed_due_ts).has_state() &&
|
||||||
|
id(job_water_tv_pot_plant_due_ts).has_state() &&
|
||||||
|
id(job_water_table_pot_plant_due_ts).has_state() &&
|
||||||
|
id(job_empty_dryer_due_ts).has_state() &&
|
||||||
|
id(job_empty_washing_machine_due_ts).has_state();
|
||||||
|
|
||||||
- display.page.show: page_jobs
|
- display.page.show: page_jobs
|
||||||
|
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: |-
|
lambda: |-
|
||||||
return id(homeassistant_time).now().is_valid();
|
return id(ha_data_ready);
|
||||||
then:
|
then:
|
||||||
- script.execute:
|
- script.execute:
|
||||||
id: refresh_display_if_changed
|
id: refresh_display_if_changed
|
||||||
@@ -288,9 +325,11 @@ esphome:
|
|||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(boot_sequence_complete) = true;
|
id(boot_sequence_complete) = true;
|
||||||
id(last_activity_ms) = millis();
|
id(last_activity_ms) = millis();
|
||||||
|
if (!id(mqtt_sleep_command_received)) {
|
||||||
id(awake_timeout_ms) =
|
id(awake_timeout_ms) =
|
||||||
(id(woke_by_button) ? ${button_wake_awake_seconds} : ${timer_wake_awake_seconds})
|
(id(woke_by_button) ? ${button_wake_awake_seconds} : ${timer_wake_awake_seconds})
|
||||||
* 1000UL;
|
* 1000UL;
|
||||||
|
}
|
||||||
|
|
||||||
ESP_LOGI(
|
ESP_LOGI(
|
||||||
"deep_sleep",
|
"deep_sleep",
|
||||||
@@ -397,6 +436,16 @@ globals:
|
|||||||
restore_value: no
|
restore_value: no
|
||||||
initial_value: "false"
|
initial_value: "false"
|
||||||
|
|
||||||
|
- id: mqtt_sleep_command_received
|
||||||
|
type: bool
|
||||||
|
restore_value: no
|
||||||
|
initial_value: "false"
|
||||||
|
|
||||||
|
- id: ha_data_ready
|
||||||
|
type: bool
|
||||||
|
restore_value: no
|
||||||
|
initial_value: "false"
|
||||||
|
|
||||||
- id: boot_sequence_complete
|
- id: boot_sequence_complete
|
||||||
type: bool
|
type: bool
|
||||||
restore_value: no
|
restore_value: no
|
||||||
@@ -937,6 +986,50 @@ display:
|
|||||||
# https://esphome.io/components/script.html
|
# https://esphome.io/components/script.html
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
script:
|
script:
|
||||||
|
- id: apply_sleep_allowed
|
||||||
|
mode: restart
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
id(mqtt_sleep_command_received) = true;
|
||||||
|
id(sleep_allowed) = true;
|
||||||
|
id(last_activity_ms) = millis();
|
||||||
|
id(awake_timeout_ms) = ${mqtt_enable_awake_seconds} * 1000UL;
|
||||||
|
- deep_sleep.allow: deep_sleep_1
|
||||||
|
- logger.log: "Deep sleep ALLOWED by retained MQTT command."
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_status_topic}/deepsleep"
|
||||||
|
payload: "On"
|
||||||
|
qos: 1
|
||||||
|
retain: true
|
||||||
|
|
||||||
|
- id: apply_sleep_prevented
|
||||||
|
mode: restart
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
id(mqtt_sleep_command_received) = true;
|
||||||
|
id(sleep_allowed) = false;
|
||||||
|
id(panel_awake_indicator) = true;
|
||||||
|
- deep_sleep.prevent: deep_sleep_1
|
||||||
|
- logger.log: "Deep sleep PREVENTED by retained MQTT command."
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_status_topic}/deepsleep"
|
||||||
|
payload: "Off"
|
||||||
|
qos: 1
|
||||||
|
retain: true
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_status_topic}/state"
|
||||||
|
payload: "awake"
|
||||||
|
qos: 1
|
||||||
|
retain: true
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
lambda: |-
|
||||||
|
return id(boot_sequence_complete);
|
||||||
|
then:
|
||||||
|
- script.execute:
|
||||||
|
id: refresh_display_if_changed
|
||||||
|
force: false
|
||||||
|
|
||||||
- id: refresh_display_if_changed
|
- id: refresh_display_if_changed
|
||||||
mode: restart
|
mode: restart
|
||||||
parameters:
|
parameters:
|
||||||
@@ -1158,7 +1251,7 @@ interval:
|
|||||||
|
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# MQTT COMMANDS:
|
# MQTT COMMANDS:
|
||||||
# Retained ON allows sleep; retained OFF prevents sleep for OTA/development.
|
# Retained On/ON allows sleep; retained Off/OFF prevents sleep for OTA/development.
|
||||||
# This extends common/mqtt_common.yaml with device-specific subscriptions.
|
# This extends common/mqtt_common.yaml with device-specific subscriptions.
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
mqtt:
|
mqtt:
|
||||||
@@ -1168,44 +1261,22 @@ mqtt:
|
|||||||
- topic: "${mqtt_command_topic}/deepsleep"
|
- topic: "${mqtt_command_topic}/deepsleep"
|
||||||
payload: "On"
|
payload: "On"
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- script.execute: apply_sleep_allowed
|
||||||
id(sleep_allowed) = true;
|
|
||||||
id(last_activity_ms) = millis();
|
- topic: "${mqtt_command_topic}/deepsleep"
|
||||||
id(awake_timeout_ms) = ${mqtt_enable_awake_seconds} * 1000UL;
|
payload: "ON"
|
||||||
- deep_sleep.allow: deep_sleep_1
|
then:
|
||||||
- logger.log: "Deep sleep ALLOWED by retained MQTT command."
|
- script.execute: apply_sleep_allowed
|
||||||
- mqtt.publish:
|
|
||||||
topic: "${mqtt_status_topic}/deepsleep"
|
|
||||||
payload: "On"
|
|
||||||
qos: 1
|
|
||||||
retain: true
|
|
||||||
|
|
||||||
- topic: "${mqtt_command_topic}/deepsleep"
|
- topic: "${mqtt_command_topic}/deepsleep"
|
||||||
payload: "Off"
|
payload: "Off"
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- script.execute: apply_sleep_prevented
|
||||||
id(sleep_allowed) = false;
|
|
||||||
id(panel_awake_indicator) = true;
|
- topic: "${mqtt_command_topic}/deepsleep"
|
||||||
- deep_sleep.prevent: deep_sleep_1
|
payload: "OFF"
|
||||||
- logger.log: "Deep sleep PREVENTED by retained MQTT command."
|
|
||||||
- mqtt.publish:
|
|
||||||
topic: "${mqtt_status_topic}/deepsleep"
|
|
||||||
payload: "Off"
|
|
||||||
qos: 1
|
|
||||||
retain: true
|
|
||||||
- mqtt.publish:
|
|
||||||
topic: "${mqtt_status_topic}/state"
|
|
||||||
payload: "awake"
|
|
||||||
qos: 1
|
|
||||||
retain: true
|
|
||||||
- if:
|
|
||||||
condition:
|
|
||||||
lambda: |-
|
|
||||||
return id(boot_sequence_complete);
|
|
||||||
then:
|
then:
|
||||||
- script.execute:
|
- script.execute: apply_sleep_prevented
|
||||||
id: refresh_display_if_changed
|
|
||||||
force: false
|
|
||||||
|
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# DEEP SLEEP:
|
# DEEP SLEEP:
|
||||||
@@ -1405,6 +1476,14 @@ text_sensor:
|
|||||||
# Job due timestamps
|
# Job due timestamps
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
sensor:
|
sensor:
|
||||||
|
- platform: template
|
||||||
|
id: wakeup_cause_sensor
|
||||||
|
name: "${friendly_name} Wakeup Cause"
|
||||||
|
icon: mdi:power-sleep
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: never
|
||||||
|
entity_category: diagnostic
|
||||||
|
|
||||||
#:######################################################################################:#
|
#:######################################################################################:#
|
||||||
# Job current due timestamps #
|
# Job current due timestamps #
|
||||||
#:######################################################################################:#
|
#:######################################################################################:#
|
||||||
|
|||||||
Reference in New Issue
Block a user