From 5ddf5388bd41d1efa3c39f02ab5c43350b114408 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Wed, 25 Dec 2024 03:00:56 +0100 Subject: [PATCH] Handle unknown states --- ...TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml | 16 ++++++++++++---- .../TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index 7cb3039..43c8717 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -206,13 +206,21 @@ script: ESP_LOGCONFIG("core_hw_buttons", "Button%s action%s:", id(gang_count_plural_suffix).c_str(), id(gang_count_plural_suffix).c_str()); - ESP_LOGCONFIG("core_hw_buttons", " Relay 1: %s", sl_button_1_action->state.c_str()); + ESP_LOGCONFIG("core_hw_buttons", " Relay 1: %s", sl_button_1_action->has_state() + ? sl_button_1_action->state.c_str() + : "Unknown"); if (id(gang_count) >= 2) - ESP_LOGCONFIG("core_hw_buttons", " Relay 2: %s", sl_button_2_action->state.c_str()); + ESP_LOGCONFIG("core_hw_buttons", " Relay 2: %s", sl_button_2_action->has_state() + ? sl_button_2_action->state.c_str() + : "Unknown"); if (id(gang_count) >= 3) - ESP_LOGCONFIG("core_hw_buttons", " Relay 3: %s", sl_button_3_action->state.c_str()); + ESP_LOGCONFIG("core_hw_buttons", " Relay 3: %s", sl_button_3_action->has_state() + ? sl_button_3_action->state.c_str() + : "Unknown"); if (id(gang_count) >= 4) - ESP_LOGCONFIG("core_hw_buttons", " Relay 4: %s", sl_button_4_action->state.c_str()); + ESP_LOGCONFIG("core_hw_buttons", " Relay 4: %s", sl_button_4_action->has_state() + ? sl_button_4_action->state.c_str() + : "Unknown"); - id: !extend touch_on_multi_touch_release then: diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index f58e374..ee1c16e 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -640,13 +640,21 @@ script: ESP_LOGCONFIG("core_hw_relays", "Relay%s mode%s:", id(gang_count_plural_suffix).c_str(), id(gang_count_plural_suffix).c_str()); - ESP_LOGCONFIG("core_hw_relays", " Relay 1: %s", sl_relay_1_mode->state.c_str()); + ESP_LOGCONFIG("core_hw_relays", " Relay 1: %s", sl_relay_1_mode->has_state() + ? sl_relay_1_mode->state.c_str() + : "Unknown"); if (id(gang_count) >= 2) - ESP_LOGCONFIG("core_hw_relays", " Relay 2: %s", sl_relay_2_mode->state.c_str()); + ESP_LOGCONFIG("core_hw_relays", " Relay 2: %s", sl_relay_2_mode->has_state() + ? sl_relay_2_mode->state.c_str() + : "Unknown"); if (id(gang_count) >= 3) - ESP_LOGCONFIG("core_hw_relays", " Relay 3: %s", sl_relay_3_mode->state.c_str()); + ESP_LOGCONFIG("core_hw_relays", " Relay 3: %s", sl_relay_3_mode->has_state() + ? sl_relay_3_mode->state.c_str() + : "Unknown"); if (id(gang_count) >= 4) - ESP_LOGCONFIG("core_hw_relays", " Relay 4: %s", sl_relay_4_mode->state.c_str()); + ESP_LOGCONFIG("core_hw_relays", " Relay 4: %s", sl_relay_4_mode->has_state() + ? sl_relay_4_mode->state.c_str() + : "Unknown"); ESP_LOGCONFIG("core_hw_relays", "Relay%s state%s:", id(gang_count_plural_suffix).c_str(), id(gang_count_plural_suffix).c_str());