From 250b22562d080399d19e555f9df9be529a1972f5 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Tue, 5 Aug 2025 11:36:09 +0200 Subject: [PATCH] Simplifies tags It should be limited to 15ish chars --- .../TX-Ultimate-Easy-ESPHome_core_common.yaml | 46 +++++------ ...Ultimate-Easy-ESPHome_core_hw_buttons.yaml | 37 ++++----- ...TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 48 ++++++----- ...X-Ultimate-Easy-ESPHome_core_hw_touch.yaml | 44 +++++----- ...timate-Easy-ESPHome_standard_hw_audio.yaml | 2 + ...imate-Easy-ESPHome_standard_hw_relays.yaml | 80 +++++++++---------- ...mate-Easy-ESPHome_standard_hw_speaker.yaml | 6 +- ...te-Easy-ESPHome_standard_hw_vibration.yaml | 14 ++-- ...te-Easy-ESPHome_standard_media_player.yaml | 22 ++--- 9 files changed, 141 insertions(+), 158 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml index d1c85d8..09e699e 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml @@ -29,6 +29,8 @@ substitutions: DUMP_CONFIG_CALLER_DELAY: 10s # Delay to dump config after requested + TAG_CORE_COMMON: core.common + api: id: api_server on_client_connected: @@ -47,12 +49,10 @@ binary_sensor: on_state: then: - lambda: |- - static const char *TAG = "binary_sensor.bs_pending_restart.core.common"; - if (x) - ESP_LOGW(TAG, "Pending restart: YES"); + ESP_LOGW("${TAG_CORE_COMMON}", "Pending restart: YES"); else - ESP_LOGD(TAG, "Pending restart: No"); + ESP_LOGD("${TAG_CORE_COMMON}", "Pending restart: No"); - script.execute: dump_config_caller button: @@ -152,12 +152,10 @@ script: - lambda: return sl_tx_model_format->active_index().has_value(); - lambda: return sl_tx_model_gang->active_index().has_value(); - lambda: |- - static const char *TAG = "script.boot_initialize.core.common"; - id(is_us_model) = (sl_tx_model_format->state == "${TX_MODEL_FORMAT_US_TEXT}"); id(gang_count) = sl_tx_model_gang->active_index().value() + 1; if (id(gang_count) < 1 || id(gang_count) > 4) { - ESP_LOGE(TAG, "Invalid number of gangs: %" PRIu8, id(gang_count)); + ESP_LOGE("${TAG_CORE_COMMON}", "Invalid number of gangs: %" PRIu8, id(gang_count)); } - id: boot_sequence @@ -173,40 +171,38 @@ script: then: # Extended by all modules - lambda: |- - static const char *TAG = "script.dump_config.core.common"; - // Device identification - ESP_LOGCONFIG(TAG, "Device friendly name: ${friendly_name}"); - ESP_LOGCONFIG(TAG, "Device name: ${name}"); - ESP_LOGCONFIG(TAG, "Device name (HA): %s", tx_device_name->state.c_str()); - ESP_LOGCONFIG(TAG, "Device hostname: %s", App.get_name().c_str()); + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Device friendly name: ${friendly_name}"); + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Device name: ${name}"); + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Device name (HA): %s", tx_device_name->state.c_str()); + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Device hostname: %s", App.get_name().c_str()); dump_config_versions->execute(); // Framework detection #ifdef USE_ARDUINO - ESP_LOGCONFIG(TAG, "Framework: Arduino"); + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Framework: Arduino"); #elif defined(USE_ESP_IDF) - ESP_LOGCONFIG(TAG, "Framework: ESP-IDF"); + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Framework: ESP-IDF"); #else - ESP_LOGW(TAG, "Framework: UNKNOWN"); + ESP_LOGW("${TAG_CORE_COMMON}", "Framework: UNKNOWN"); #endif // Model configuration - ESP_LOGCONFIG(TAG, "Model format (selected): %s", + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Model format (selected): %s", sl_tx_model_format->state.c_str()); - ESP_LOGCONFIG(TAG, "Model format (detected): %s", + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Model format (detected): %s", id(is_us_model) ? "US" : "EU"); - ESP_LOGCONFIG(TAG, "Gangs (selected): %s", + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Gangs (selected): %s", sl_tx_model_gang->state.c_str()); - ESP_LOGCONFIG(TAG, "Gangs (detected): %" PRIu8 "-Gang%s", + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Gangs (detected): %" PRIu8 "-Gang%s", id(gang_count), id(gang_count) > 1 ? "s" : ""); // System state if (bs_pending_restart->state) - ESP_LOGW(TAG, "Pending restart: YES"); + ESP_LOGW("${TAG_CORE_COMMON}", "Pending restart: YES"); else - ESP_LOGCONFIG(TAG, "Pending restart: No"); + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Pending restart: No"); - id: dump_config_caller mode: restart @@ -231,10 +227,10 @@ script: then: - lambda: |- // Version information - ESP_LOGCONFIG("core", "TX Ultimate firmware version: ${version}"); + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "TX Ultimate firmware version: ${version}"); // ESPHome builder information - ESP_LOGCONFIG("core", "ESPHome builder: " ESPHOME_VERSION); - ESP_LOGCONFIG("core", "ESPHome build timestamp: %s", App.get_compilation_time().c_str()); + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "ESPHome builder: " ESPHOME_VERSION); + ESP_LOGCONFIG("${TAG_CORE_COMMON}", "ESPHome build timestamp: %s", App.get_compilation_time().c_str()); - id: publish_device_info mode: restart diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index 804f302..c70670d 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -36,6 +36,8 @@ substitutions: BUTTON_3_ID: '3' BUTTON_4_ID: '4' + TAG_CORE_HW_BUTTONS: core.hw.buttons + binary_sensor: - &binary_sensor_button_base id: bs_button_2 @@ -121,8 +123,6 @@ script: count: uint8_t then: - lambda: |- - static const char *TAG = "script.button_action.core.hw.buttons"; - // Send event to Home Assistant esphome::api::CustomAPIDevice ha_event; ha_event.fire_homeassistant_event("${EVENT_NAME}", { @@ -135,7 +135,7 @@ script: {"count", std::to_string(count)}, {"position", std::to_string(id(button_press_position))} }); - ESP_LOGI(TAG, "Button %" PRIu8 " action: '%s'", button, action.c_str()); + ESP_LOGI("${TAG_CORE_HW_BUTTONS}", "Button %" PRIu8 " action: '%s'", button, action.c_str()); if (action == "click") { switch (button) { case ${BUTTON_1_ID}: @@ -219,24 +219,22 @@ script: - id: !extend dump_config then: - lambda: |- - static const char *TAG = "script.dump_config.core.hw.buttons"; - std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : ""; // Button's actions - ESP_LOGCONFIG(TAG, "Button%s action%s:", + ESP_LOGCONFIG("${TAG_CORE_HW_BUTTONS}", "Button%s action%s:", gang_count_plural_suffix.c_str(), gang_count_plural_suffix.c_str()); - ESP_LOGCONFIG(TAG, " Relay 1: %s", sl_button_1_action->has_state() ? - sl_button_1_action->state.c_str() : "Unknown"); + ESP_LOGCONFIG("${TAG_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(TAG, " Relay 2: %s", sl_button_2_action->has_state() ? - sl_button_2_action->state.c_str() : "Unknown"); + ESP_LOGCONFIG("${TAG_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(TAG, " Relay 3: %s", sl_button_3_action->has_state() ? - sl_button_3_action->state.c_str() : "Unknown"); + ESP_LOGCONFIG("${TAG_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(TAG, " Relay 4: %s", sl_button_4_action->has_state() ? - sl_button_4_action->state.c_str() : "Unknown"); + ESP_LOGCONFIG("${TAG_CORE_HW_BUTTONS}", " Relay 4: %s", sl_button_4_action->has_state() ? + sl_button_4_action->state.c_str() : "Unknown"); - id: !extend dump_config_list_packages then: @@ -311,27 +309,26 @@ script: - id: !extend touch_on_release then: - lambda: |- - static const char *TAG = "script.touch_on_release.core.hw.buttons"; - uint32_t current_time = millis(); buttons_release->execute(); if (id(button_press_start_time) > 0 and id(button_press_start_time) < current_time) { uint32_t press_duration = current_time - id(button_press_start_time); // Handle overflow (optional, since it's unlikely to happen here) - ESP_LOGI(TAG, "Button press duration: %" PRIu32 " ms", press_duration); + ESP_LOGI("${TAG_CORE_HW_BUTTONS}", "Button press duration: %" PRIu32 " ms", press_duration); if (press_duration < ${BUTTON_CLICK_MIN_LENGTH}) { - ESP_LOGW(TAG, "Ignoring button press (too short)"); + ESP_LOGW("${TAG_CORE_HW_BUTTONS}", "Ignoring button press (too short)"); } else if (press_duration >= ${BUTTON_CLICK_MIN_LENGTH} and press_duration <= ${BUTTON_CLICK_MAX_LENGTH}) { // Short/normal click button_click_event->execute(id(button_press_button), id(click_counter)); } else if (press_duration >= ${BUTTON_LONG_PRESS_DELAY} and press_duration <= ${BUTTON_PRESS_TIMEOUT}) { button_action->execute(id(button_press_button), "long_press", 1); } else if (press_duration > ${BUTTON_PRESS_TIMEOUT}) { // Timeout or invalid - ESP_LOGW(TAG, "Button press cancelled or timed out after ${BUTTON_PRESS_TIMEOUT} ms"); + ESP_LOGW("${TAG_CORE_HW_BUTTONS}", + "Button press cancelled or timed out after ${BUTTON_PRESS_TIMEOUT} ms"); } } else { - ESP_LOGW(TAG, "Press event timestamp not recorded yet"); + ESP_LOGW("${TAG_CORE_HW_BUTTONS}", "Press event timestamp not recorded yet"); } id(button_press_start_time) = 0; diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 056f6e8..90dddea 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -29,6 +29,8 @@ substitutions: LIGHT_SIDES_RESTORE_MODE: RESTORE_DEFAULT_OFF LIGHT_INDIVIDUAL_RESTORE_MODE: RESTORE_DEFAULT_OFF + TAG_CORE_HW_LEDS: core.hw.leds + esphome: platformio_options: build_flags: @@ -497,46 +499,44 @@ script: - id: !extend dump_config then: - lambda: |- - static const char *TAG = "script.dump_config.core.hw.leds"; - std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : ""; // Relay's LEDs modes - ESP_LOGCONFIG(TAG, "Relay%s LEDs mode%s:", + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", "Relay%s LEDs mode%s:", gang_count_plural_suffix.c_str(), gang_count_plural_suffix.c_str()); - ESP_LOGCONFIG(TAG, " Relay 1: %s", id(is_us_model) ? + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Relay 1: %s", id(is_us_model) ? sl_relay_1_light_mode_us->state.c_str() : sl_relay_1_light_mode_eu->state.c_str()); if (id(gang_count) >= 2) - ESP_LOGCONFIG(TAG, " Relay 2: %s", id(is_us_model) ? + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Relay 2: %s", id(is_us_model) ? sl_relay_2_light_mode_us->state.c_str() : sl_relay_2_light_mode_eu->state.c_str()); if (id(gang_count) >= 3) - ESP_LOGCONFIG(TAG, " Relay 3: %s", id(is_us_model) ? + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Relay 3: %s", id(is_us_model) ? sl_relay_3_light_mode_us->state.c_str() : sl_relay_3_light_mode_eu->state.c_str()); if (id(gang_count) >= 4) - ESP_LOGCONFIG(TAG, " Relay 4: %s", id(is_us_model) ? + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Relay 4: %s", id(is_us_model) ? sl_relay_4_light_mode_us->state.c_str() : sl_relay_4_light_mode_eu->state.c_str()); // Transition times - ESP_LOGCONFIG(TAG, "Transition times:"); - ESP_LOGCONFIG(TAG, " Default: ${default_transition_length}"); + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", "Transition times:"); + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Default: ${default_transition_length}"); if (${LIGHT_TRANSITION_TURN_ON} > 0) - ESP_LOGCONFIG(TAG, " Turning on: ${LIGHT_TRANSITION_TURN_ON}ms"); + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Turning on: ${LIGHT_TRANSITION_TURN_ON}ms"); else - ESP_LOGCONFIG(TAG, " Turning on: Disabled"); + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Turning on: Disabled"); if (${LIGHT_TRANSITION_TURN_OFF} > 0) - ESP_LOGCONFIG(TAG, " Turning off: ${LIGHT_TRANSITION_TURN_OFF}ms"); + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Turning off: ${LIGHT_TRANSITION_TURN_OFF}ms"); else - ESP_LOGCONFIG(TAG, " Turning off: Disabled"); + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Turning off: Disabled"); // Restore modes - ESP_LOGCONFIG(TAG, "LED restore modes:"); - ESP_LOGCONFIG(TAG, " Light - All: ${LIGHT_FULL_RESTORE_MODE}"); - ESP_LOGCONFIG(TAG, " Sides: ${LIGHT_SIDES_RESTORE_MODE}"); - ESP_LOGCONFIG(TAG, " Individual: ${LIGHT_INDIVIDUAL_RESTORE_MODE}"); + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", "LED restore modes:"); + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Light - All: ${LIGHT_FULL_RESTORE_MODE}"); + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Sides: ${LIGHT_SIDES_RESTORE_MODE}"); + ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Individual: ${LIGHT_INDIVIDUAL_RESTORE_MODE}"); - id: !extend dump_config_list_packages then: @@ -558,8 +558,6 @@ script: state: bool then: - lambda: |- - static const char *TAG = "script.light_set_state.core.hw.leds"; - static const uint32_t LIGHT_TRANSITION_TURN_ON = ${LIGHT_TRANSITION_TURN_ON}; static const uint32_t LIGHT_TRANSITION_TURN_OFF = ${LIGHT_TRANSITION_TURN_OFF}; static const uint8_t LIGHT_BRIGHTNESS_TURN_ON = ${LIGHT_BRIGHTNESS_TURN_ON}; @@ -574,11 +572,11 @@ script: switch (light_group) { case 1: if (light_index >= id(gb_lights_1).size()) { - ESP_LOGE(TAG, "Invalid set with %s light for Relay %" PRIu8, light_mode_group_1.c_str(), light_index+1); + ESP_LOGE("${TAG_CORE_HW_LEDS}", "Invalid set with %s light for Relay %" PRIu8, light_mode_group_1.c_str(), light_index+1); return; } if (state and !id(gb_lights_1)[light_index]->current_values.is_on()) { - ESP_LOGI(TAG, "Turn-on %s light for Relay %" PRIu8, light_mode_group_1.c_str(), light_index+1); + ESP_LOGI("${TAG_CORE_HW_LEDS}", "Turn-on %s light for Relay %" PRIu8, light_mode_group_1.c_str(), light_index+1); auto call = id(gb_lights_1)[light_index]->turn_on(); if (LIGHT_TRANSITION_TURN_ON > 0) call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms @@ -586,7 +584,7 @@ script: call.set_brightness(LIGHT_BRIGHTNESS_TURN_ON / 100.0f); call.perform(); } else if (!state and id(gb_lights_1)[light_index]->current_values.is_on()) { - ESP_LOGI(TAG, "Turn-off %s light for Relay %" PRIu8, light_mode_group_1.c_str(), light_index+1); + ESP_LOGI("${TAG_CORE_HW_LEDS}", "Turn-off %s light for Relay %" PRIu8, light_mode_group_1.c_str(), light_index+1); auto call = id(gb_lights_1)[light_index]->turn_off(); if (LIGHT_TRANSITION_TURN_OFF > 0) call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms @@ -595,11 +593,11 @@ script: break; case 2: if (light_index >= id(gb_lights_2).size()) { - ESP_LOGE(TAG, "Invalid set with %s light for Relay %" PRIu8, light_mode_group_2.c_str(), light_index+1); + ESP_LOGE("${TAG_CORE_HW_LEDS}", "Invalid set with %s light for Relay %" PRIu8, light_mode_group_2.c_str(), light_index+1); return; } if (state and !id(gb_lights_2)[light_index]->current_values.is_on()) { - ESP_LOGI(TAG, "Turn-on %s light for Relay %" PRIu8, light_mode_group_2.c_str(), light_index+1); + ESP_LOGI("${TAG_CORE_HW_LEDS}", "Turn-on %s light for Relay %" PRIu8, light_mode_group_2.c_str(), light_index+1); auto call = id(gb_lights_2)[light_index]->turn_on(); if (LIGHT_TRANSITION_TURN_ON > 0) call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms @@ -607,7 +605,7 @@ script: call.set_brightness(LIGHT_BRIGHTNESS_TURN_ON / 100.0f); call.perform(); } else if (!state and id(gb_lights_2)[light_index]->current_values.is_on()) { - ESP_LOGI(TAG, "Turn-off %s light for Relay %" PRIu8, light_mode_group_2.c_str(), light_index+1); + ESP_LOGI("${TAG_CORE_HW_LEDS}", "Turn-off %s light for Relay %" PRIu8, light_mode_group_2.c_str(), light_index+1); auto call = id(gb_lights_2)[light_index]->turn_off(); if (LIGHT_TRANSITION_TURN_OFF > 0) call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml index 0e1377b..dfe940e 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml @@ -14,6 +14,8 @@ substitutions: TOUCH_POSITION_MAX_VALUE: '10' # Maximum touch position value returned by the touch pad via uart + TAG_CORE_HW_TOUCH: core.hw.touch + binary_sensor: - &bs_button_event_template id: bs_button_event_template @@ -291,14 +293,12 @@ script: - id: !extend dump_config then: - lambda: |- - static const char *TAG = "script.dump_config.core.hw.touch"; - // Touch panel's state if (sw_touch_panel_power->state) - ESP_LOGCONFIG(TAG, "Touch panel - Power: On"); + ESP_LOGCONFIG("${TAG_CORE_HW_TOUCH}", "Touch panel - Power: On"); else - ESP_LOGW(TAG, "Touch panel - Power: OFF"); - ESP_LOGCONFIG(TAG, "Touch event duration: %.0fms", nr_touch_duration->state); + ESP_LOGW("${TAG_CORE_HW_TOUCH}", "Touch panel - Power: OFF"); + ESP_LOGCONFIG("${TAG_CORE_HW_TOUCH}", "Touch event duration: %.0fms", nr_touch_duration->state); - id: !extend dump_config_list_packages then: @@ -380,13 +380,11 @@ tx_ultimate_easy: on_long_touch_release: - lambda: |- - static const char *TAG = "tx_ultimate_easy.on_long_touch_release.core.hw.touch"; - const uint8_t touch_position = static_cast(touch.x); if (touch_position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range - ESP_LOGE(TAG, "Invalid long-touch position: %" PRIu8, touch_position); + ESP_LOGE("${TAG_CORE_HW_TOUCH}", "Invalid long-touch position: %" PRIu8, touch_position); } else { - ESP_LOGI(TAG, "Long-touch released at position %" PRIu8, touch_position); + ESP_LOGI("${TAG_CORE_HW_TOUCH}", "Long-touch released at position %" PRIu8, touch_position); } on_multi_touch_release: @@ -401,29 +399,24 @@ tx_ultimate_easy: action: release position: !lambda return std::to_string(touch.x); - lambda: |- - static const char *TAG = "tx_ultimate_easy.on_multi_touch_release.core.hw.touch"; - - ESP_LOGI(TAG, "Multi-touch released"); + ESP_LOGI("${TAG_CORE_HW_TOUCH}", "Multi-touch released"); touch_on_multi_touch_release->execute(); on_press: then: - lambda: |- - static const char *TAG = "tx_ultimate_easy.on_press.core.hw.touch"; - const uint8_t position = static_cast(touch.x); if (position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range - ESP_LOGE(TAG, "Invalid touch position: %" PRIu8, position); + ESP_LOGE("${TAG_CORE_HW_TOUCH}", "Invalid touch position: %" PRIu8, position); } else { - ESP_LOGI(TAG, "Pressed at position %" PRIu8, position); + ESP_LOGI("${TAG_CORE_HW_TOUCH}", "Pressed at position %" PRIu8, position); touch_on_press->execute(static_cast(touch.button), position); } on_release: then: - lambda: |- - static const char *TAG = "tx_ultimate_easy.on_release.core.hw.touch"; - ESP_LOGI(TAG, "Released"); + ESP_LOGI("${TAG_CORE_HW_TOUCH}", "Released"); - script.execute: touch_on_release on_swipe_left: @@ -447,8 +440,8 @@ tx_ultimate_easy: return "down"; position: !lambda return std::to_string(touch.x); - lambda: |- - static const char *TAG = "tx_ultimate_easy.on_swipe_left.core.hw.touch"; - ESP_LOGI(TAG, "Swipe %s", (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "left" : "down"); + ESP_LOGI("${TAG_CORE_HW_TOUCH}", "Swipe %s", + (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "left" : "down"); touch_swipe_left->execute(); on_swipe_right: @@ -472,16 +465,15 @@ tx_ultimate_easy: return "up"; position: !lambda return std::to_string(touch.x); - lambda: |- - static const char *TAG = "tx_ultimate_easy.on_swipe_right.core.hw.touch"; - ESP_LOGI(TAG, "Swipe %s", (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "right" : "up"); + ESP_LOGI("${TAG_CORE_HW_TOUCH}", "Swipe %s", + (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "right" : "up"); touch_swipe_right->execute(); on_touch_event: - lambda: |- - static const char *TAG = "tx_ultimate_easy.on_touch_event.core.hw.touch"; - ESP_LOGD(TAG, "Touch event:"); - ESP_LOGD(TAG, " State: %i (%s)", touch.state, touch.state_str.c_str()); - ESP_LOGD(TAG, " Position: %i", touch.x); + ESP_LOGD("${TAG_CORE_HW_TOUCH}", "Touch event:"); + ESP_LOGD("${TAG_CORE_HW_TOUCH}", " State: %i (%s)", touch.state, touch.state_str.c_str()); + ESP_LOGD("${TAG_CORE_HW_TOUCH}", " Position: %i", touch.x); uart: - id: uart_touch diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_audio.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_audio.yaml index 0894e3a..e53dc0f 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_audio.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_audio.yaml @@ -14,6 +14,8 @@ substitutions: SWITCH_AUDIO_AMPLIFIER_RESTORE_MODE: RESTORE_DEFAULT_ON + TAG_STD_HW_AUDIO: std.hw.audio + esphome: platformio_options: build_flags: diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_relays.yaml index 9e9839e..6d036f5 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_relays.yaml @@ -19,6 +19,8 @@ substitutions: RELAY_RESTORE_MODE: RESTORE_DEFAULT_OFF LIGHT_RELAYS_RESTORE_MODE: RESTORE_DEFAULT_OFF + TAG_STD_HW_RELAYS: std.hw.relays + esphome: platformio_options: build_flags: @@ -466,8 +468,6 @@ script: mode: restart then: - lambda: |- - static const char *TAG = "script.boot_initialize_relays_group_assignments.standard.hw.relays"; - // LED Group Assignment: // - For US model: gb_lights_1 = left side LEDs, gb_lights_2 = right side LEDs // - For EU model: gb_lights_1 = bottom LEDs, gb_lights_2 = top LEDs @@ -514,7 +514,7 @@ script: } break; default: - ESP_LOGE(TAG, "Invalid gang count: %" PRIu8, id(gang_count)); + ESP_LOGE("${TAG_STD_HW_RELAYS}", "Invalid gang count: %" PRIu8, id(gang_count)); break; } id(boot_initialization_relays_group_assignments) = true; @@ -637,8 +637,6 @@ script: - id: !extend button_click_event then: - lambda: |- - static const char *TAG = "script.button_click_event.standard.hw.relays"; - // Handle only single clicks if (click_count != 1) return; @@ -657,13 +655,13 @@ script: std::string select_state; bool toggle_relay = false; if (api_disconnected) { - ESP_LOGW(TAG, "Toggle relays:"); - ESP_LOGW(TAG, " API state: DISCONNECTED"); - ESP_LOGW(TAG, " Button: %" PRIu8, button); + ESP_LOGW("${TAG_STD_HW_RELAYS}", "Toggle relays:"); + ESP_LOGW("${TAG_STD_HW_RELAYS}", " API state: DISCONNECTED"); + ESP_LOGW("${TAG_STD_HW_RELAYS}", " Button: %" PRIu8, button); } else { - ESP_LOGVV(TAG, "Toggle relays:"); - ESP_LOGVV(TAG, " API state: Connected"); - ESP_LOGVV(TAG, " Button: %" PRIu8, button); + ESP_LOGVV("${TAG_STD_HW_RELAYS}", "Toggle relays:"); + ESP_LOGVV("${TAG_STD_HW_RELAYS}", " API state: Connected"); + ESP_LOGVV("${TAG_STD_HW_RELAYS}", " Button: %" PRIu8, button); } switch (button) { case ${BUTTON_1_ID}: @@ -696,57 +694,59 @@ script: break; } if (toggle_relay) { - ESP_LOGI(TAG, "Toggle relay %" PRIu8 ": (%s)", button, select_state.c_str()); + ESP_LOGI("${TAG_STD_HW_RELAYS}", "Toggle relay %" PRIu8 ": (%s)", button, select_state.c_str()); } else if (not select_state.empty()) { - ESP_LOGV(TAG, "Ignoring toggle for relay %" PRIu8 ": action is '%s'", + ESP_LOGV("${TAG_STD_HW_RELAYS}", "Ignoring toggle for relay %" PRIu8 ": action is '%s'", button, select_state.c_str()); } else { - ESP_LOGE(TAG, "No button action selected for button %" PRIu8, button); + ESP_LOGE("${TAG_STD_HW_RELAYS}", "No button action selected for button %" PRIu8, button); } - id: !extend dump_config then: - lambda: |- - static const char *TAG = "script.dump_config.standard.hw.relays"; - std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : ""; // Relay's modes - ESP_LOGCONFIG(TAG, "Relay%s mode%s:", gang_count_plural_suffix.c_str(), gang_count_plural_suffix.c_str()); - ESP_LOGCONFIG(TAG, " Relay 1: %s", sl_relay_1_mode->has_state() ? + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", "Relay%s mode%s:", gang_count_plural_suffix.c_str(), + gang_count_plural_suffix.c_str()); + ESP_LOGCONFIG("${TAG_STD_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(TAG, " Relay 2: %s", sl_relay_2_mode->has_state() ? + ESP_LOGCONFIG("${TAG_STD_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(TAG, " Relay 3: %s", sl_relay_3_mode->has_state() ? + ESP_LOGCONFIG("${TAG_STD_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(TAG, " Relay 4: %s", sl_relay_4_mode->has_state() ? + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Relay 4: %s", sl_relay_4_mode->has_state() ? sl_relay_4_mode->state.c_str() : "Unknown"); // Relay's states - ESP_LOGCONFIG(TAG, "Relay%s state%s:", gang_count_plural_suffix.c_str(), gang_count_plural_suffix.c_str()); - ESP_LOGCONFIG(TAG, " Relay 1: %s", sw_relay_1->state ? "ON" : "OFF"); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", "Relay%s state%s:", gang_count_plural_suffix.c_str(), + gang_count_plural_suffix.c_str()); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Relay 1: %s", sw_relay_1->state ? "ON" : "OFF"); if (id(gang_count) >= 2) - ESP_LOGCONFIG(TAG, " Relay 2: %s", sw_relay_2->state ? "ON" : "OFF"); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Relay 2: %s", sw_relay_2->state ? "ON" : "OFF"); if (id(gang_count) >= 3) - ESP_LOGCONFIG(TAG, " Relay 3: %s", sw_relay_3->state ? "ON" : "OFF"); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Relay 3: %s", sw_relay_3->state ? "ON" : "OFF"); if (id(gang_count) >= 4) - ESP_LOGCONFIG(TAG, " Relay 4: %s", sw_relay_4->state ? "ON" : "OFF"); - ESP_LOGCONFIG(TAG, "Expose Relay's LEDs to Home Assistant: %s", YESNO(sw_expose_relays_leds_to_ha->state)); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Relay 4: %s", sw_relay_4->state ? "ON" : "OFF"); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", "Expose Relay's LEDs to Home Assistant: %s", + YESNO(sw_expose_relays_leds_to_ha->state)); // Boot initialization statuses - ESP_LOGCONFIG(TAG, "Boot initialization flags:"); - ESP_LOGCONFIG(TAG, " Overall: %s", YESNO(id(boot_initialization_relays))); - ESP_LOGCONFIG(TAG, " Groups: %s", YESNO(id(boot_initialization_relays_group_assignments))); - ESP_LOGCONFIG(TAG, " Light modes: %s", YESNO(id(boot_initialization_relays_light_modes))); - ESP_LOGCONFIG(TAG, " Relay modes: %s", YESNO(id(boot_initialization_relays_relay_modes))); - ESP_LOGCONFIG(TAG, " Status LEDs: %s", YESNO(id(boot_initialization_relays_relay_leds))); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", "Boot initialization flags:"); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Overall: %s", YESNO(id(boot_initialization_relays))); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Groups: %s", + YESNO(id(boot_initialization_relays_group_assignments))); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Light modes: %s", YESNO(id(boot_initialization_relays_light_modes))); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Relay modes: %s", YESNO(id(boot_initialization_relays_relay_modes))); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Status LEDs: %s", YESNO(id(boot_initialization_relays_relay_leds))); // Substitutions - ESP_LOGCONFIG(TAG, "Restore modes:"); - ESP_LOGCONFIG(TAG, " Relays: ${RELAY_RESTORE_MODE}"); - ESP_LOGCONFIG(TAG, " Status LEDs: ${LIGHT_RELAYS_RESTORE_MODE}"); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", "Restore modes:"); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Relays: ${RELAY_RESTORE_MODE}"); + ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Status LEDs: ${LIGHT_RELAYS_RESTORE_MODE}"); - id: !extend dump_config_list_packages then: @@ -765,10 +765,8 @@ script: then: - script.wait: boot_initialize_relays - lambda: |- - static const char *TAG = "script.show_relay_status.standard.hw.relays"; - if (not id(boot_initialization_relays)) { - ESP_LOGW(TAG, "Relays not initialized yet"); + ESP_LOGW("${TAG_STD_HW_RELAYS}", "Relays not initialized yet"); if (not boot_initialize_relays->is_running()) boot_initialize_relays->execute(); return; @@ -811,8 +809,8 @@ script: break; } - ESP_LOGV(TAG, "Relay %" PRIu8 " is %s", i + 1, relay_state ? "ON" : "OFF"); - ESP_LOGV(TAG, "Light Mode for Relay %" PRIu8 ": %s", i + 1, light_mode.c_str()); + ESP_LOGV("${TAG_STD_HW_RELAYS}", "Relay %" PRIu8 " is %s", i + 1, relay_state ? "ON" : "OFF"); + ESP_LOGV("${TAG_STD_HW_RELAYS}", "Light Mode for Relay %" PRIu8 ": %s", i + 1, light_mode.c_str()); // Use light_set_state for light updates if (relay_state) { diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_speaker.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_speaker.yaml index ceee20f..86a19e2 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_speaker.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_speaker.yaml @@ -16,6 +16,8 @@ substitutions: # d=32 (32nd note), o=5 (octave 5), b=100 (tempo 100) tone_volume_change: "scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b" # Use "none" to disable sound + TAG_STD_HW_SPEAKER: std.hw.speaker + packages: standard_hw_audio: !include TX-Ultimate-Easy-ESPHome_standard_hw_audio.yaml @@ -29,11 +31,9 @@ api: tone: string then: - lambda: |- - static const char *TAG = "api.actions.rtttl_play.standard.hw.speaker"; - rtttl_speaker->stop(); if (speaker_volume->state > 0) { - ESP_LOGI(TAG, "Play tone: '%s'", tone.c_str()); + ESP_LOGI("${TAG_STD_HW_SPEAKER}", "Play tone: '%s'", tone.c_str()); rtttl_speaker->play(tone.c_str()); } diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_vibration.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_vibration.yaml index bb55b43..d66124f 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_vibration.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_vibration.yaml @@ -14,6 +14,8 @@ substitutions: vibration_max_duration: 2s + TAG_STD_HW_VIBRATION: std.hw.vibration + binary_sensor: - id: bs_vibrating name: Vibrating @@ -61,19 +63,17 @@ script: - id: !extend dump_config then: - lambda: |- - static const char *TAG = "script.dump_config.standard.hw.vibration"; - // Configuration - ESP_LOGCONFIG(TAG, "Touch - Vibration feedback: %s", + ESP_LOGCONFIG("${TAG_STD_HW_VIBRATION}", "Touch - Vibration feedback: %s", sl_touch_vibration_feedback->state.c_str()); - ESP_LOGCONFIG(TAG, "Vibrate duration: %.0fms", nr_vibrating_duration->state); - ESP_LOGCONFIG(TAG, "Vibrate max duration: ${vibration_max_duration}"); + ESP_LOGCONFIG("${TAG_STD_HW_VIBRATION}", "Vibrate duration: %.0fms", nr_vibrating_duration->state); + ESP_LOGCONFIG("${TAG_STD_HW_VIBRATION}", "Vibrate max duration: ${vibration_max_duration}"); // State if (bs_vibrating->state) - ESP_LOGW(TAG, "Vibrating now: YES"); + ESP_LOGW("${TAG_STD_HW_VIBRATION}", "Vibrating now: YES"); else - ESP_LOGCONFIG(TAG, "Vibrating now: No"); + ESP_LOGCONFIG("${TAG_STD_HW_VIBRATION}", "Vibrating now: No"); - id: !extend dump_config_list_packages then: diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_media_player.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_media_player.yaml index 95bebb6..54474e9 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_media_player.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_media_player.yaml @@ -11,6 +11,9 @@ ##### - For normal system use, modifications to this file are NOT required. ##### #################################################################################################### --- +substitutions: + TAG_STD_MEDIA_PLAYER: "std.media-player" + packages: standard_hw_speaker: !include TX-Ultimate-Easy-ESPHome_standard_hw_speaker.yaml @@ -50,13 +53,12 @@ media_player: on_state: then: - lambda: |- - static const char *TAG = "media_player.on_state.standard.hw.media_player"; - // Check if volume has changed and update number entity id(persistent_media_player_volume) = static_cast(mp_media_player->volume * 100.0f); if (id(persistent_media_player_volume) != id(last_media_player_volume)) { id(last_media_player_volume) = id(persistent_media_player_volume); - ESP_LOGD(TAG, "Media player volume changed to %" PRIu8 "%%, updating number entity", id(persistent_media_player_volume)); + ESP_LOGD("${TAG_STD_MEDIA_PLAYER}", "Media player volume changed to %" PRIu8 "%%, updating number entity", + id(persistent_media_player_volume)); } script: @@ -67,12 +69,11 @@ script: - id: !extend dump_config then: - lambda: |- - static const char *TAG = "script.boot_sequence.standard.hw.media_player"; - // Volume sync configuration - ESP_LOGCONFIG(TAG, "Media Player Volume Sync:"); - ESP_LOGCONFIG(TAG, " Persistent volume: %" PRIu8 "%", id(persistent_media_player_volume)); - ESP_LOGCONFIG(TAG, " Current volume: %.1f%%", mp_media_player->volume * 100.0f); + ESP_LOGCONFIG("${TAG_STD_MEDIA_PLAYER}", "Media Player Volume Sync:"); + ESP_LOGCONFIG("${TAG_STD_MEDIA_PLAYER}", " Persistent volume: %" PRIu8 "%", + id(persistent_media_player_volume)); + ESP_LOGCONFIG("${TAG_STD_MEDIA_PLAYER}", " Current volume: %.1f%%", mp_media_player->volume * 100.0f); - id: !extend dump_config_list_packages then: @@ -97,10 +98,9 @@ script: id: mp_media_player volume: !lambda return id(persistent_media_player_volume) / 100.0f; - lambda: |- - static const char *TAG = "script.sync_initial_volume.standard.hw.media_player"; - id(last_media_player_volume) = id(persistent_media_player_volume); - ESP_LOGI(TAG, "Initial volume sync: %.1f%% (restored from persistence)", id(persistent_media_player_volume)); + ESP_LOGI("${TAG_STD_MEDIA_PLAYER}", "Initial volume sync: %.1f%% (restored from persistence)", + id(persistent_media_player_volume)); speaker: - platform: mixer