Standardize log tag

This commit is contained in:
Edward Firmo
2025-08-05 08:54:45 +02:00
parent 6d16d7d645
commit 1d8b4fee1a
6 changed files with 115 additions and 93 deletions

View File

@@ -47,10 +47,12 @@ binary_sensor:
on_state: on_state:
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "binary_sensor.bs_pending_restart.core.common";
if (x) if (x)
ESP_LOGW("binary_sensor.bs_pending_restart.core.common", "Pending restart: YES"); ESP_LOGW(TAG, "Pending restart: YES");
else else
ESP_LOGCONFIG("binary_sensor.bs_pending_restart.core.common", "Pending restart: No"); ESP_LOGD(TAG, "Pending restart: No");
- script.execute: dump_config_caller - script.execute: dump_config_caller
button: button:
@@ -150,10 +152,12 @@ script:
- lambda: return sl_tx_model_format->active_index().has_value(); - lambda: return sl_tx_model_format->active_index().has_value();
- lambda: return sl_tx_model_gang->active_index().has_value(); - lambda: return sl_tx_model_gang->active_index().has_value();
- lambda: |- - 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(is_us_model) = (sl_tx_model_format->state == "${TX_MODEL_FORMAT_US_TEXT}");
id(gang_count) = sl_tx_model_gang->active_index().value() + 1; id(gang_count) = sl_tx_model_gang->active_index().value() + 1;
if (id(gang_count) < 1 || id(gang_count) > 4) { if (id(gang_count) < 1 || id(gang_count) > 4) {
ESP_LOGE("script.boot_initialize.core.common", "Invalid number of gangs: %" PRIu8, id(gang_count)); ESP_LOGE(TAG, "Invalid number of gangs: %" PRIu8, id(gang_count));
} }
- id: boot_sequence - id: boot_sequence
@@ -169,38 +173,40 @@ script:
then: then:
# Extended by all modules # Extended by all modules
- lambda: |- - lambda: |-
static const char *TAG = "script.dump_config.core.common";
// Device identification // Device identification
ESP_LOGCONFIG("script.dump_config.core.common", "Device friendly name: ${friendly_name}"); ESP_LOGCONFIG(TAG, "Device friendly name: ${friendly_name}");
ESP_LOGCONFIG("script.dump_config.core.common", "Device name: ${name}"); ESP_LOGCONFIG(TAG, "Device name: ${name}");
ESP_LOGCONFIG("script.dump_config.core.common", "Device name (HA): %s", tx_device_name->state.c_str()); ESP_LOGCONFIG(TAG, "Device name (HA): %s", tx_device_name->state.c_str());
ESP_LOGCONFIG("script.dump_config.core.common", "Device hostname: %s", App.get_name().c_str()); ESP_LOGCONFIG(TAG, "Device hostname: %s", App.get_name().c_str());
dump_config_versions->execute(); dump_config_versions->execute();
// Framework detection // Framework detection
#ifdef USE_ARDUINO #ifdef USE_ARDUINO
ESP_LOGCONFIG("script.dump_config.core.common", "Framework: Arduino"); ESP_LOGCONFIG(TAG, "Framework: Arduino");
#elif defined(USE_ESP_IDF) #elif defined(USE_ESP_IDF)
ESP_LOGCONFIG("script.dump_config.core.common", "Framework: ESP-IDF"); ESP_LOGCONFIG(TAG, "Framework: ESP-IDF");
#else #else
ESP_LOGW("script.dump_config.core.common", "Framework: UNKNOWN"); ESP_LOGW(TAG, "Framework: UNKNOWN");
#endif #endif
// Model configuration // Model configuration
ESP_LOGCONFIG("script.dump_config.core.common", "Model format (selected): %s", ESP_LOGCONFIG(TAG, "Model format (selected): %s",
sl_tx_model_format->state.c_str()); sl_tx_model_format->state.c_str());
ESP_LOGCONFIG("script.dump_config.core.common", "Model format (detected): %s", ESP_LOGCONFIG(TAG, "Model format (detected): %s",
id(is_us_model) ? "US" : "EU"); id(is_us_model) ? "US" : "EU");
ESP_LOGCONFIG("script.dump_config.core.common", "Gangs (selected): %s", ESP_LOGCONFIG(TAG, "Gangs (selected): %s",
sl_tx_model_gang->state.c_str()); sl_tx_model_gang->state.c_str());
ESP_LOGCONFIG("script.dump_config.core.common", "Gangs (detected): %" PRIu8 "-Gang%s", ESP_LOGCONFIG(TAG, "Gangs (detected): %" PRIu8 "-Gang%s",
id(gang_count), id(gang_count) > 1 ? "s" : ""); id(gang_count), id(gang_count) > 1 ? "s" : "");
// System state // System state
if (bs_pending_restart->state) if (bs_pending_restart->state)
ESP_LOGW("script.dump_config.core.common", "Pending restart: YES"); ESP_LOGW(TAG, "Pending restart: YES");
else else
ESP_LOGCONFIG("script.dump_config.core.common", "Pending restart: No"); ESP_LOGCONFIG(TAG, "Pending restart: No");
- id: dump_config_caller - id: dump_config_caller
mode: restart mode: restart
@@ -268,7 +274,6 @@ select:
state: true state: true
- lambda: |- - lambda: |-
id(is_us_model) = (x == "${TX_MODEL_FORMAT_US_TEXT}"); id(is_us_model) = (x == "${TX_MODEL_FORMAT_US_TEXT}");
ESP_LOGI("select.sl_tx_model_gang.core.common", "New model selected: %s", id(is_us_model) ? "US" : "EU");
- id: sl_tx_model_gang - id: sl_tx_model_gang
name: Model (Gang) name: Model (Gang)
@@ -292,8 +297,6 @@ select:
state: true state: true
- lambda: |- - lambda: |-
id(gang_count) = static_cast<uint8_t>(i) + 1; id(gang_count) = static_cast<uint8_t>(i) + 1;
ESP_LOGI("select.sl_tx_model_gang.core.common", "New model selected: %" PRIu8 "-%s",
id(gang_count), id(gang_count) > 1 ? "Gangs" : "Gang");
tx_ultimate->set_gang_count(id(gang_count)); tx_ultimate->set_gang_count(id(gang_count));
text_sensor: text_sensor:

View File

@@ -291,12 +291,14 @@ script:
- id: !extend dump_config - id: !extend dump_config
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "script.dump_config.core.hw.touch";
// Touch panel's state // Touch panel's state
if (sw_touch_panel_power->state) if (sw_touch_panel_power->state)
ESP_LOGCONFIG("core_hw_touch", "Touch panel - Power: On"); ESP_LOGCONFIG(TAG, "Touch panel - Power: On");
else else
ESP_LOGW("core_hw_touch", "Touch panel - Power: OFF"); ESP_LOGW(TAG, "Touch panel - Power: OFF");
ESP_LOGCONFIG("core_hw_touch", "Touch event duration: %.0fms", nr_touch_duration->state); ESP_LOGCONFIG(TAG, "Touch event duration: %.0fms", nr_touch_duration->state);
- id: !extend dump_config_list_packages - id: !extend dump_config_list_packages
then: then:
@@ -378,11 +380,13 @@ tx_ultimate_easy:
on_long_touch_release: on_long_touch_release:
- lambda: |- - lambda: |-
static const char *TAG = "tx_ultimate_easy.on_long_touch_release.core.hw.touch";
const uint8_t touch_position = static_cast<uint8_t>(touch.x); const uint8_t touch_position = static_cast<uint8_t>(touch.x);
if (touch_position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range if (touch_position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range
ESP_LOGE("core_hw_touch", "Invalid long-touch position: %" PRIu8, touch_position); ESP_LOGE(TAG, "Invalid long-touch position: %" PRIu8, touch_position);
} else { } else {
ESP_LOGI("core_hw_touch", "Long-touch released at position %" PRIu8, touch_position); ESP_LOGI(TAG, "Long-touch released at position %" PRIu8, touch_position);
} }
on_multi_touch_release: on_multi_touch_release:
@@ -397,23 +401,29 @@ tx_ultimate_easy:
action: release action: release
position: !lambda return std::to_string(touch.x); position: !lambda return std::to_string(touch.x);
- lambda: |- - lambda: |-
ESP_LOGI("core_hw_touch", "Multi-touch released"); static const char *TAG = "tx_ultimate_easy.on_multi_touch_release.core.hw.touch";
ESP_LOGI(TAG, "Multi-touch released");
touch_on_multi_touch_release->execute(); touch_on_multi_touch_release->execute();
on_press: on_press:
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "tx_ultimate_easy.on_press.core.hw.touch";
const uint8_t position = static_cast<uint8_t>(touch.x); const uint8_t position = static_cast<uint8_t>(touch.x);
if (position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range if (position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range
ESP_LOGE("core_hw_touch", "Invalid touch position: %" PRIu8, position); ESP_LOGE(TAG, "Invalid touch position: %" PRIu8, position);
} else { } else {
ESP_LOGI("core_hw_touch", "Pressed at position %" PRIu8, position); ESP_LOGI(TAG, "Pressed at position %" PRIu8, position);
touch_on_press->execute(static_cast<uint8_t>(touch.button), position); touch_on_press->execute(static_cast<uint8_t>(touch.button), position);
} }
on_release: on_release:
then: then:
- lambda: ESP_LOGI("core_hw_touch", "Released"); - lambda: |-
static const char *TAG = "tx_ultimate_easy.on_release.core.hw.touch";
ESP_LOGI(TAG, "Released");
- script.execute: touch_on_release - script.execute: touch_on_release
on_swipe_left: on_swipe_left:
@@ -437,8 +447,8 @@ tx_ultimate_easy:
return "down"; return "down";
position: !lambda return std::to_string(touch.x); position: !lambda return std::to_string(touch.x);
- lambda: |- - lambda: |-
ESP_LOGI("core_hw_touch", "Swipe %s", static const char *TAG = "tx_ultimate_easy.on_swipe_left.core.hw.touch";
(sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "left" : "down"); ESP_LOGI(TAG, "Swipe %s", (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "left" : "down");
touch_swipe_left->execute(); touch_swipe_left->execute();
on_swipe_right: on_swipe_right:
@@ -462,15 +472,16 @@ tx_ultimate_easy:
return "up"; return "up";
position: !lambda return std::to_string(touch.x); position: !lambda return std::to_string(touch.x);
- lambda: |- - lambda: |-
ESP_LOGI("core_hw_touch", "Swipe %s", static const char *TAG = "tx_ultimate_easy.on_swipe_right.core.hw.touch";
(sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "right" : "up"); ESP_LOGI(TAG, "Swipe %s", (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "right" : "up");
touch_swipe_right->execute(); touch_swipe_right->execute();
on_touch_event: on_touch_event:
- lambda: |- - lambda: |-
ESP_LOGD("core_hw_touch", "Touch event:"); static const char *TAG = "tx_ultimate_easy.on_touch_event.core.hw.touch";
ESP_LOGD("core_hw_touch", " State: %i (%s)", touch.state, touch.state_str.c_str()); ESP_LOGD(TAG, "Touch event:");
ESP_LOGD("core_hw_touch", " Position: %i", touch.x); ESP_LOGD(TAG, " State: %i (%s)", touch.state, touch.state_str.c_str());
ESP_LOGD(TAG, " Position: %i", touch.x);
uart: uart:
- id: uart_touch - id: uart_touch

View File

@@ -466,6 +466,8 @@ script:
mode: restart mode: restart
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "script.boot_initialize_relays_group_assignments.standard.hw.relays";
// LED Group Assignment: // LED Group Assignment:
// - For US model: gb_lights_1 = left side LEDs, gb_lights_2 = right side LEDs // - 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 // - For EU model: gb_lights_1 = bottom LEDs, gb_lights_2 = top LEDs
@@ -512,7 +514,7 @@ script:
} }
break; break;
default: default:
ESP_LOGE("standard_hw_relays", "Invalid gang count: %" PRIu8, id(gang_count)); ESP_LOGE(TAG, "Invalid gang count: %" PRIu8, id(gang_count));
break; break;
} }
id(boot_initialization_relays_group_assignments) = true; id(boot_initialization_relays_group_assignments) = true;
@@ -635,6 +637,8 @@ script:
- id: !extend button_click_event - id: !extend button_click_event
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "script.button_click_event.standard.hw.relays";
// Handle only single clicks // Handle only single clicks
if (click_count != 1) if (click_count != 1)
return; return;
@@ -653,13 +657,13 @@ script:
std::string select_state; std::string select_state;
bool toggle_relay = false; bool toggle_relay = false;
if (api_disconnected) { if (api_disconnected) {
ESP_LOGW("standard_hw_relays", "Toggle relays:"); ESP_LOGW(TAG, "Toggle relays:");
ESP_LOGW("standard_hw_relays", " API state: DISCONNECTED"); ESP_LOGW(TAG, " API state: DISCONNECTED");
ESP_LOGW("standard_hw_relays", " Button: %" PRIu8, button); ESP_LOGW(TAG, " Button: %" PRIu8, button);
} else { } else {
ESP_LOGVV("standard_hw_relays", "Toggle relays:"); ESP_LOGVV(TAG, "Toggle relays:");
ESP_LOGVV("standard_hw_relays", " API state: Connected"); ESP_LOGVV(TAG, " API state: Connected");
ESP_LOGVV("standard_hw_relays", " Button: %" PRIu8, button); ESP_LOGVV(TAG, " Button: %" PRIu8, button);
} }
switch (button) { switch (button) {
case ${BUTTON_1_ID}: case ${BUTTON_1_ID}:
@@ -692,65 +696,57 @@ script:
break; break;
} }
if (toggle_relay) { if (toggle_relay) {
ESP_LOGI("standard_hw_relays", "Toggle relay %" PRIu8 ": (%s)", button, select_state.c_str()); ESP_LOGI(TAG, "Toggle relay %" PRIu8 ": (%s)", button, select_state.c_str());
} else if (not select_state.empty()) { } else if (not select_state.empty()) {
ESP_LOGV("standard_hw_relays", "Ignoring toggle for relay %" PRIu8 ": action is '%s'", ESP_LOGV(TAG, "Ignoring toggle for relay %" PRIu8 ": action is '%s'",
button, select_state.c_str()); button, select_state.c_str());
} else { } else {
ESP_LOGE("standard_hw_relays", "No button action selected for button %" PRIu8, button); ESP_LOGE(TAG, "No button action selected for button %" PRIu8, button);
} }
- id: !extend dump_config - id: !extend dump_config
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "script.dump_config.standard.hw.relays";
std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : ""; std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : "";
// Relay's modes // Relay's modes
ESP_LOGCONFIG("standard_hw_relays", "Relay%s mode%s:", ESP_LOGCONFIG(TAG, "Relay%s mode%s:", gang_count_plural_suffix.c_str(), gang_count_plural_suffix.c_str());
gang_count_plural_suffix.c_str(), ESP_LOGCONFIG(TAG, " Relay 1: %s", sl_relay_1_mode->has_state() ?
gang_count_plural_suffix.c_str()); sl_relay_1_mode->state.c_str() : "Unknown");
ESP_LOGCONFIG("standard_hw_relays", " Relay 1: %s", sl_relay_1_mode->has_state()
? sl_relay_1_mode->state.c_str()
: "Unknown");
if (id(gang_count) >= 2) if (id(gang_count) >= 2)
ESP_LOGCONFIG("standard_hw_relays", " Relay 2: %s", sl_relay_2_mode->has_state() ESP_LOGCONFIG(TAG, " Relay 2: %s", sl_relay_2_mode->has_state() ?
? sl_relay_2_mode->state.c_str() sl_relay_2_mode->state.c_str() : "Unknown");
: "Unknown");
if (id(gang_count) >= 3) if (id(gang_count) >= 3)
ESP_LOGCONFIG("standard_hw_relays", " Relay 3: %s", sl_relay_3_mode->has_state() ESP_LOGCONFIG(TAG, " Relay 3: %s", sl_relay_3_mode->has_state() ?
? sl_relay_3_mode->state.c_str() sl_relay_3_mode->state.c_str() : "Unknown");
: "Unknown");
if (id(gang_count) >= 4) if (id(gang_count) >= 4)
ESP_LOGCONFIG("standard_hw_relays", " Relay 4: %s", sl_relay_4_mode->has_state() ESP_LOGCONFIG(TAG, " Relay 4: %s", sl_relay_4_mode->has_state() ?
? sl_relay_4_mode->state.c_str() sl_relay_4_mode->state.c_str() : "Unknown");
: "Unknown");
// Relay's states // Relay's states
ESP_LOGCONFIG("standard_hw_relays", "Relay%s state%s:", ESP_LOGCONFIG(TAG, "Relay%s state%s:", gang_count_plural_suffix.c_str(), gang_count_plural_suffix.c_str());
gang_count_plural_suffix.c_str(), ESP_LOGCONFIG(TAG, " Relay 1: %s", sw_relay_1->state ? "ON" : "OFF");
gang_count_plural_suffix.c_str());
ESP_LOGCONFIG("standard_hw_relays", " Relay 1: %s", sw_relay_1->state ? "ON" : "OFF");
if (id(gang_count) >= 2) if (id(gang_count) >= 2)
ESP_LOGCONFIG("standard_hw_relays", " Relay 2: %s", sw_relay_2->state ? "ON" : "OFF"); ESP_LOGCONFIG(TAG, " Relay 2: %s", sw_relay_2->state ? "ON" : "OFF");
if (id(gang_count) >= 3) if (id(gang_count) >= 3)
ESP_LOGCONFIG("standard_hw_relays", " Relay 3: %s", sw_relay_3->state ? "ON" : "OFF"); ESP_LOGCONFIG(TAG, " Relay 3: %s", sw_relay_3->state ? "ON" : "OFF");
if (id(gang_count) >= 4) if (id(gang_count) >= 4)
ESP_LOGCONFIG("standard_hw_relays", " Relay 4: %s", sw_relay_4->state ? "ON" : "OFF"); ESP_LOGCONFIG(TAG, " Relay 4: %s", sw_relay_4->state ? "ON" : "OFF");
ESP_LOGCONFIG("standard_hw_relays", "Expose Relay's LEDs to Home Assistant: %s", ESP_LOGCONFIG(TAG, "Expose Relay's LEDs to Home Assistant: %s", YESNO(sw_expose_relays_leds_to_ha->state));
YESNO(sw_expose_relays_leds_to_ha->state));
// Boot initialization statuses // Boot initialization statuses
ESP_LOGCONFIG("standard_hw_relays", "Boot initialization flags:"); ESP_LOGCONFIG(TAG, "Boot initialization flags:");
ESP_LOGCONFIG("standard_hw_relays", " Overall: %s", YESNO(id(boot_initialization_relays))); ESP_LOGCONFIG(TAG, " Overall: %s", YESNO(id(boot_initialization_relays)));
ESP_LOGCONFIG("standard_hw_relays", " Groups: %s", ESP_LOGCONFIG(TAG, " Groups: %s", YESNO(id(boot_initialization_relays_group_assignments)));
YESNO(id(boot_initialization_relays_group_assignments))); ESP_LOGCONFIG(TAG, " Light modes: %s", YESNO(id(boot_initialization_relays_light_modes)));
ESP_LOGCONFIG("standard_hw_relays", " 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("standard_hw_relays", " 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("standard_hw_relays", " Status LEDs: %s", YESNO(id(boot_initialization_relays_relay_leds)));
// Substitutions // Substitutions
ESP_LOGCONFIG("standard_hw_relays", "Restore modes:"); ESP_LOGCONFIG(TAG, "Restore modes:");
ESP_LOGCONFIG("standard_hw_relays", " Relays: ${RELAY_RESTORE_MODE}"); ESP_LOGCONFIG(TAG, " Relays: ${RELAY_RESTORE_MODE}");
ESP_LOGCONFIG("standard_hw_relays", " Status LEDs: ${LIGHT_RELAYS_RESTORE_MODE}"); ESP_LOGCONFIG(TAG, " Status LEDs: ${LIGHT_RELAYS_RESTORE_MODE}");
- id: !extend dump_config_list_packages - id: !extend dump_config_list_packages
then: then:
@@ -769,8 +765,10 @@ script:
then: then:
- script.wait: boot_initialize_relays - script.wait: boot_initialize_relays
- lambda: |- - lambda: |-
static const char *TAG = "script.show_relay_status.standard.hw.relays";
if (not id(boot_initialization_relays)) { if (not id(boot_initialization_relays)) {
ESP_LOGW("standard_hw_relays", "Relays not initialized yet"); ESP_LOGW(TAG, "Relays not initialized yet");
if (not boot_initialize_relays->is_running()) if (not boot_initialize_relays->is_running())
boot_initialize_relays->execute(); boot_initialize_relays->execute();
return; return;
@@ -813,8 +811,8 @@ script:
break; break;
} }
ESP_LOGV("standard_hw_relays", "Relay %" PRIu8 " is %s", i + 1, relay_state ? "ON" : "OFF"); ESP_LOGV(TAG, "Relay %" PRIu8 " is %s", i + 1, relay_state ? "ON" : "OFF");
ESP_LOGV("standard_hw_relays", "Light Mode for Relay %" PRIu8 ": %s", i + 1, light_mode.c_str()); ESP_LOGV(TAG, "Light Mode for Relay %" PRIu8 ": %s", i + 1, light_mode.c_str());
// Use light_set_state for light updates // Use light_set_state for light updates
if (relay_state) { if (relay_state) {

View File

@@ -29,9 +29,11 @@ api:
tone: string tone: string
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "api.actions.rtttl_play.standard.hw.speaker";
rtttl_speaker->stop(); rtttl_speaker->stop();
if (speaker_volume->state > 0) { if (speaker_volume->state > 0) {
ESP_LOGI("standard_speaker", "Play tone: '%s'", tone.c_str()); ESP_LOGI(TAG, "Play tone: '%s'", tone.c_str());
rtttl_speaker->play(tone.c_str()); rtttl_speaker->play(tone.c_str());
} }

View File

@@ -61,17 +61,19 @@ script:
- id: !extend dump_config - id: !extend dump_config
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "script.dump_config.standard.hw.vibration";
// Configuration // Configuration
ESP_LOGCONFIG("standard_hw_vibration", "Touch - Vibration feedback: %s", ESP_LOGCONFIG(TAG, "Touch - Vibration feedback: %s",
sl_touch_vibration_feedback->state.c_str()); sl_touch_vibration_feedback->state.c_str());
ESP_LOGCONFIG("standard_hw_vibration", "Vibrate duration: %.0fms", nr_vibrating_duration->state); ESP_LOGCONFIG(TAG, "Vibrate duration: %.0fms", nr_vibrating_duration->state);
ESP_LOGCONFIG("standard_hw_vibration", "Vibrate max duration: ${vibration_max_duration}"); ESP_LOGCONFIG(TAG, "Vibrate max duration: ${vibration_max_duration}");
// State // State
if (bs_vibrating->state) if (bs_vibrating->state)
ESP_LOGW("standard_hw_vibration", "Vibrating now: YES"); ESP_LOGW(TAG, "Vibrating now: YES");
else else
ESP_LOGCONFIG("standard_hw_vibration", "Vibrating now: No"); ESP_LOGCONFIG(TAG, "Vibrating now: No");
- id: !extend dump_config_list_packages - id: !extend dump_config_list_packages
then: then:

View File

@@ -50,11 +50,13 @@ media_player:
on_state: on_state:
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "media_player.on_state.standard.hw.media_player";
// Check if volume has changed and update number entity // Check if volume has changed and update number entity
id(persistent_media_player_volume) = static_cast<uint8_t>(mp_media_player->volume * 100.0f); id(persistent_media_player_volume) = static_cast<uint8_t>(mp_media_player->volume * 100.0f);
if (id(persistent_media_player_volume) != id(last_media_player_volume)) { if (id(persistent_media_player_volume) != id(last_media_player_volume)) {
id(last_media_player_volume) = id(persistent_media_player_volume); id(last_media_player_volume) = id(persistent_media_player_volume);
ESP_LOGD("media_player_volume", "Media player volume changed to %" PRIu8 "%%, updating number entity", id(persistent_media_player_volume)); ESP_LOGD(TAG, "Media player volume changed to %" PRIu8 "%%, updating number entity", id(persistent_media_player_volume));
} }
script: script:
@@ -65,10 +67,12 @@ script:
- id: !extend dump_config - id: !extend dump_config
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "script.boot_sequence.standard.hw.media_player";
// Volume sync configuration // Volume sync configuration
ESP_LOGCONFIG("standard_media_player", "Media Player Volume Sync:"); ESP_LOGCONFIG(TAG, "Media Player Volume Sync:");
ESP_LOGCONFIG("standard_media_player", " Persistent volume: %" PRIu8 "%", id(persistent_media_player_volume)); ESP_LOGCONFIG(TAG, " Persistent volume: %" PRIu8 "%", id(persistent_media_player_volume));
ESP_LOGCONFIG("standard_media_player", " Current volume: %.1f%%", mp_media_player->volume * 100.0f); ESP_LOGCONFIG(TAG, " Current volume: %.1f%%", mp_media_player->volume * 100.0f);
- id: !extend dump_config_list_packages - id: !extend dump_config_list_packages
then: then:
@@ -93,8 +97,10 @@ script:
id: mp_media_player id: mp_media_player
volume: !lambda return id(persistent_media_player_volume) / 100.0f; volume: !lambda return id(persistent_media_player_volume) / 100.0f;
- lambda: |- - lambda: |-
static const char *TAG = "script.sync_initial_volume.standard.hw.media_player";
id(last_media_player_volume) = id(persistent_media_player_volume); id(last_media_player_volume) = id(persistent_media_player_volume);
ESP_LOGI("media_player_volume", "Initial volume sync: %.1f%% (restored from persistence)", id(persistent_media_player_volume)); ESP_LOGI(TAG, "Initial volume sync: %.1f%% (restored from persistence)", id(persistent_media_player_volume));
speaker: speaker:
- platform: mixer - platform: mixer