From 8af692e82d3ab3f1a590e313de1a3158fdeef835 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 10 Aug 2025 22:59:29 +0200 Subject: [PATCH] Introduces `bs_boot_completed` to know the boot status To know when the boot was completed --- .../TX-Ultimate-Easy-ESPHome_core_common.yaml | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml index ca66660..7eace18 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml @@ -27,7 +27,7 @@ substitutions: TX_MODEL_3_GANG_TEXT: "3 Gang" TX_MODEL_4_GANG_TEXT: "4 Gang" - DUMP_CONFIG_CALLER_DELAY: 10s # Delay to dump config after requested + DUMP_CONFIG_CALLER_DELAY: 5s # Delay to dump config after requested TAG_CORE_COMMON: core.common @@ -48,11 +48,18 @@ binary_sensor: device_class: problem on_state: then: - - lambda: |- - if (x) - ESP_LOGW("${TAG_CORE_COMMON}", "Pending restart: YES"); - else - ESP_LOGD("${TAG_CORE_COMMON}", "Pending restart: No"); + - script.execute: dump_config_caller + + - id: bs_boot_completed + name: Boot Completed + internal: false + disabled_by_default: false + platform: template + entity_category: diagnostic + device_class: connectivity + icon: mdi:rocket-launch + on_state: + then: - script.execute: dump_config_caller button: @@ -80,6 +87,12 @@ esphome: - -D TX_ULTIMATE_EASY_CORE_COMMON on_boot: + - priority: 1000 # Very early in boot process + then: + - binary_sensor.template.publish: + id: bs_boot_completed + state: OFF # yamllint disable-line rule:truthy + - priority: 750 then: - script.execute: restore_from_nvs @@ -106,16 +119,16 @@ external_components: - tx_ultimate_easy globals: - - id: is_us_model - type: bool - restore_value: true - initial_value: 'false' - - id: gang_count type: uint8_t restore_value: true initial_value: '0' + - id: is_us_model + type: bool + restore_value: true + initial_value: 'false' + logger: level: DEBUG @@ -143,9 +156,16 @@ script: - id: boot_done mode: restart then: + - script.wait: restore_from_nvs + - script.wait: boot_initialize + - script.wait: boot_sequence - script.execute: id: api_send_ha_event_boot type: done + - script.wait: api_send_ha_event_boot + - binary_sensor.template.publish: + id: bs_boot_completed + state: ON # yamllint disable-line rule:truthy - id: boot_initialize mode: restart @@ -208,6 +228,12 @@ script: ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Gangs (detected): %" PRIu8 "-Gang%s", id(gang_count), id(gang_count) > 1 ? "s" : ""); + // Boot completion status + if (bs_boot_completed->state) + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Boot completed: Yes"); + else + ESP_LOGW("${TAG_CORE_COMMON}", "Boot completed: NO"); + // System state if (bs_pending_restart->state) ESP_LOGW("${TAG_CORE_COMMON}", "Pending restart: YES");