Simplifies tags

It should be limited to 15ish chars
This commit is contained in:
Edward Firmo
2025-08-05 11:36:09 +02:00
parent 243a18bdf2
commit 250b22562d
9 changed files with 141 additions and 158 deletions

View File

@@ -29,6 +29,8 @@ substitutions:
DUMP_CONFIG_CALLER_DELAY: 10s # Delay to dump config after requested DUMP_CONFIG_CALLER_DELAY: 10s # Delay to dump config after requested
TAG_CORE_COMMON: core.common
api: api:
id: api_server id: api_server
on_client_connected: on_client_connected:
@@ -47,12 +49,10 @@ 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(TAG, "Pending restart: YES"); ESP_LOGW("${TAG_CORE_COMMON}", "Pending restart: YES");
else else
ESP_LOGD(TAG, "Pending restart: No"); ESP_LOGD("${TAG_CORE_COMMON}", "Pending restart: No");
- script.execute: dump_config_caller - script.execute: dump_config_caller
button: button:
@@ -152,12 +152,10 @@ 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(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 - id: boot_sequence
@@ -173,40 +171,38 @@ 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(TAG, "Device friendly name: ${friendly_name}"); ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Device friendly name: ${friendly_name}");
ESP_LOGCONFIG(TAG, "Device name: ${name}"); ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Device name: ${name}");
ESP_LOGCONFIG(TAG, "Device name (HA): %s", tx_device_name->state.c_str()); ESP_LOGCONFIG("${TAG_CORE_COMMON}", "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 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(TAG, "Framework: Arduino"); ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Framework: Arduino");
#elif defined(USE_ESP_IDF) #elif defined(USE_ESP_IDF)
ESP_LOGCONFIG(TAG, "Framework: ESP-IDF"); ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Framework: ESP-IDF");
#else #else
ESP_LOGW(TAG, "Framework: UNKNOWN"); ESP_LOGW("${TAG_CORE_COMMON}", "Framework: UNKNOWN");
#endif #endif
// Model configuration // 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()); 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"); 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()); 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" : ""); id(gang_count), id(gang_count) > 1 ? "s" : "");
// System state // System state
if (bs_pending_restart->state) if (bs_pending_restart->state)
ESP_LOGW(TAG, "Pending restart: YES"); ESP_LOGW("${TAG_CORE_COMMON}", "Pending restart: YES");
else else
ESP_LOGCONFIG(TAG, "Pending restart: No"); ESP_LOGCONFIG("${TAG_CORE_COMMON}", "Pending restart: No");
- id: dump_config_caller - id: dump_config_caller
mode: restart mode: restart
@@ -231,10 +227,10 @@ script:
then: then:
- lambda: |- - lambda: |-
// Version information // Version information
ESP_LOGCONFIG("core", "TX Ultimate firmware version: ${version}"); ESP_LOGCONFIG("${TAG_CORE_COMMON}", "TX Ultimate firmware version: ${version}");
// ESPHome builder information // ESPHome builder information
ESP_LOGCONFIG("core", "ESPHome builder: " ESPHOME_VERSION); ESP_LOGCONFIG("${TAG_CORE_COMMON}", "ESPHome builder: " ESPHOME_VERSION);
ESP_LOGCONFIG("core", "ESPHome build timestamp: %s", App.get_compilation_time().c_str()); ESP_LOGCONFIG("${TAG_CORE_COMMON}", "ESPHome build timestamp: %s", App.get_compilation_time().c_str());
- id: publish_device_info - id: publish_device_info
mode: restart mode: restart

View File

@@ -36,6 +36,8 @@ substitutions:
BUTTON_3_ID: '3' BUTTON_3_ID: '3'
BUTTON_4_ID: '4' BUTTON_4_ID: '4'
TAG_CORE_HW_BUTTONS: core.hw.buttons
binary_sensor: binary_sensor:
- &binary_sensor_button_base - &binary_sensor_button_base
id: bs_button_2 id: bs_button_2
@@ -121,8 +123,6 @@ script:
count: uint8_t count: uint8_t
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "script.button_action.core.hw.buttons";
// Send event to Home Assistant // Send event to Home Assistant
esphome::api::CustomAPIDevice ha_event; esphome::api::CustomAPIDevice ha_event;
ha_event.fire_homeassistant_event("${EVENT_NAME}", { ha_event.fire_homeassistant_event("${EVENT_NAME}", {
@@ -135,7 +135,7 @@ script:
{"count", std::to_string(count)}, {"count", std::to_string(count)},
{"position", std::to_string(id(button_press_position))} {"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") { if (action == "click") {
switch (button) { switch (button) {
case ${BUTTON_1_ID}: case ${BUTTON_1_ID}:
@@ -219,23 +219,21 @@ script:
- id: !extend dump_config - id: !extend dump_config
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "script.dump_config.core.hw.buttons";
std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : ""; std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : "";
// Button's actions // 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(),
gang_count_plural_suffix.c_str()); gang_count_plural_suffix.c_str());
ESP_LOGCONFIG(TAG, " Relay 1: %s", sl_button_1_action->has_state() ? ESP_LOGCONFIG("${TAG_CORE_HW_BUTTONS}", " Relay 1: %s", sl_button_1_action->has_state() ?
sl_button_1_action->state.c_str() : "Unknown"); sl_button_1_action->state.c_str() : "Unknown");
if (id(gang_count) >= 2) if (id(gang_count) >= 2)
ESP_LOGCONFIG(TAG, " Relay 2: %s", sl_button_2_action->has_state() ? ESP_LOGCONFIG("${TAG_CORE_HW_BUTTONS}", " Relay 2: %s", sl_button_2_action->has_state() ?
sl_button_2_action->state.c_str() : "Unknown"); sl_button_2_action->state.c_str() : "Unknown");
if (id(gang_count) >= 3) if (id(gang_count) >= 3)
ESP_LOGCONFIG(TAG, " Relay 3: %s", sl_button_3_action->has_state() ? ESP_LOGCONFIG("${TAG_CORE_HW_BUTTONS}", " Relay 3: %s", sl_button_3_action->has_state() ?
sl_button_3_action->state.c_str() : "Unknown"); sl_button_3_action->state.c_str() : "Unknown");
if (id(gang_count) >= 4) if (id(gang_count) >= 4)
ESP_LOGCONFIG(TAG, " Relay 4: %s", sl_button_4_action->has_state() ? ESP_LOGCONFIG("${TAG_CORE_HW_BUTTONS}", " Relay 4: %s", sl_button_4_action->has_state() ?
sl_button_4_action->state.c_str() : "Unknown"); sl_button_4_action->state.c_str() : "Unknown");
- id: !extend dump_config_list_packages - id: !extend dump_config_list_packages
@@ -311,27 +309,26 @@ script:
- id: !extend touch_on_release - id: !extend touch_on_release
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "script.touch_on_release.core.hw.buttons";
uint32_t current_time = millis(); uint32_t current_time = millis();
buttons_release->execute(); buttons_release->execute();
if (id(button_press_start_time) > 0 and if (id(button_press_start_time) > 0 and
id(button_press_start_time) < current_time) { id(button_press_start_time) < current_time) {
uint32_t press_duration = current_time - id(button_press_start_time); uint32_t press_duration = current_time - id(button_press_start_time);
// Handle overflow (optional, since it's unlikely to happen here) // 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}) { 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 } else if (press_duration >= ${BUTTON_CLICK_MIN_LENGTH} and
press_duration <= ${BUTTON_CLICK_MAX_LENGTH}) { // Short/normal click press_duration <= ${BUTTON_CLICK_MAX_LENGTH}) { // Short/normal click
button_click_event->execute(id(button_press_button), id(click_counter)); 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}) { } else if (press_duration >= ${BUTTON_LONG_PRESS_DELAY} and press_duration <= ${BUTTON_PRESS_TIMEOUT}) {
button_action->execute(id(button_press_button), "long_press", 1); button_action->execute(id(button_press_button), "long_press", 1);
} else if (press_duration > ${BUTTON_PRESS_TIMEOUT}) { // Timeout or invalid } 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 { } 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; id(button_press_start_time) = 0;

View File

@@ -29,6 +29,8 @@ substitutions:
LIGHT_SIDES_RESTORE_MODE: RESTORE_DEFAULT_OFF LIGHT_SIDES_RESTORE_MODE: RESTORE_DEFAULT_OFF
LIGHT_INDIVIDUAL_RESTORE_MODE: RESTORE_DEFAULT_OFF LIGHT_INDIVIDUAL_RESTORE_MODE: RESTORE_DEFAULT_OFF
TAG_CORE_HW_LEDS: core.hw.leds
esphome: esphome:
platformio_options: platformio_options:
build_flags: build_flags:
@@ -497,46 +499,44 @@ script:
- id: !extend dump_config - id: !extend dump_config
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "script.dump_config.core.hw.leds";
std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : ""; std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : "";
// Relay's LEDs modes // 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(),
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_us->state.c_str() :
sl_relay_1_light_mode_eu->state.c_str()); sl_relay_1_light_mode_eu->state.c_str());
if (id(gang_count) >= 2) 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_us->state.c_str() :
sl_relay_2_light_mode_eu->state.c_str()); sl_relay_2_light_mode_eu->state.c_str());
if (id(gang_count) >= 3) 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_us->state.c_str() :
sl_relay_3_light_mode_eu->state.c_str()); sl_relay_3_light_mode_eu->state.c_str());
if (id(gang_count) >= 4) 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_us->state.c_str() :
sl_relay_4_light_mode_eu->state.c_str()); sl_relay_4_light_mode_eu->state.c_str());
// Transition times // Transition times
ESP_LOGCONFIG(TAG, "Transition times:"); ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", "Transition times:");
ESP_LOGCONFIG(TAG, " Default: ${default_transition_length}"); ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Default: ${default_transition_length}");
if (${LIGHT_TRANSITION_TURN_ON} > 0) 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 else
ESP_LOGCONFIG(TAG, " Turning on: Disabled"); ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Turning on: Disabled");
if (${LIGHT_TRANSITION_TURN_OFF} > 0) 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 else
ESP_LOGCONFIG(TAG, " Turning off: Disabled"); ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Turning off: Disabled");
// Restore modes // Restore modes
ESP_LOGCONFIG(TAG, "LED restore modes:"); ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", "LED restore modes:");
ESP_LOGCONFIG(TAG, " Light - All: ${LIGHT_FULL_RESTORE_MODE}"); ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Light - All: ${LIGHT_FULL_RESTORE_MODE}");
ESP_LOGCONFIG(TAG, " Sides: ${LIGHT_SIDES_RESTORE_MODE}"); ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Sides: ${LIGHT_SIDES_RESTORE_MODE}");
ESP_LOGCONFIG(TAG, " Individual: ${LIGHT_INDIVIDUAL_RESTORE_MODE}"); ESP_LOGCONFIG("${TAG_CORE_HW_LEDS}", " Individual: ${LIGHT_INDIVIDUAL_RESTORE_MODE}");
- id: !extend dump_config_list_packages - id: !extend dump_config_list_packages
then: then:
@@ -558,8 +558,6 @@ script:
state: bool state: bool
then: then:
- lambda: |- - 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_ON = ${LIGHT_TRANSITION_TURN_ON};
static const uint32_t LIGHT_TRANSITION_TURN_OFF = ${LIGHT_TRANSITION_TURN_OFF}; static const uint32_t LIGHT_TRANSITION_TURN_OFF = ${LIGHT_TRANSITION_TURN_OFF};
static const uint8_t LIGHT_BRIGHTNESS_TURN_ON = ${LIGHT_BRIGHTNESS_TURN_ON}; static const uint8_t LIGHT_BRIGHTNESS_TURN_ON = ${LIGHT_BRIGHTNESS_TURN_ON};
@@ -574,11 +572,11 @@ script:
switch (light_group) { switch (light_group) {
case 1: case 1:
if (light_index >= id(gb_lights_1).size()) { 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; return;
} }
if (state and !id(gb_lights_1)[light_index]->current_values.is_on()) { 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(); auto call = id(gb_lights_1)[light_index]->turn_on();
if (LIGHT_TRANSITION_TURN_ON > 0) if (LIGHT_TRANSITION_TURN_ON > 0)
call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms 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.set_brightness(LIGHT_BRIGHTNESS_TURN_ON / 100.0f);
call.perform(); call.perform();
} else if (!state and id(gb_lights_1)[light_index]->current_values.is_on()) { } 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(); auto call = id(gb_lights_1)[light_index]->turn_off();
if (LIGHT_TRANSITION_TURN_OFF > 0) if (LIGHT_TRANSITION_TURN_OFF > 0)
call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms
@@ -595,11 +593,11 @@ script:
break; break;
case 2: case 2:
if (light_index >= id(gb_lights_2).size()) { 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; return;
} }
if (state and !id(gb_lights_2)[light_index]->current_values.is_on()) { 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(); auto call = id(gb_lights_2)[light_index]->turn_on();
if (LIGHT_TRANSITION_TURN_ON > 0) if (LIGHT_TRANSITION_TURN_ON > 0)
call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms 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.set_brightness(LIGHT_BRIGHTNESS_TURN_ON / 100.0f);
call.perform(); call.perform();
} else if (!state and id(gb_lights_2)[light_index]->current_values.is_on()) { } 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(); auto call = id(gb_lights_2)[light_index]->turn_off();
if (LIGHT_TRANSITION_TURN_OFF > 0) if (LIGHT_TRANSITION_TURN_OFF > 0)
call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms

View File

@@ -14,6 +14,8 @@
substitutions: substitutions:
TOUCH_POSITION_MAX_VALUE: '10' # Maximum touch position value returned by the touch pad via uart 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: binary_sensor:
- &bs_button_event_template - &bs_button_event_template
id: bs_button_event_template id: bs_button_event_template
@@ -291,14 +293,12 @@ 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(TAG, "Touch panel - Power: On"); ESP_LOGCONFIG("${TAG_CORE_HW_TOUCH}", "Touch panel - Power: On");
else else
ESP_LOGW(TAG, "Touch panel - Power: OFF"); ESP_LOGW("${TAG_CORE_HW_TOUCH}", "Touch panel - Power: OFF");
ESP_LOGCONFIG(TAG, "Touch event duration: %.0fms", nr_touch_duration->state); ESP_LOGCONFIG("${TAG_CORE_HW_TOUCH}", "Touch event duration: %.0fms", nr_touch_duration->state);
- id: !extend dump_config_list_packages - id: !extend dump_config_list_packages
then: then:
@@ -380,13 +380,11 @@ 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(TAG, "Invalid long-touch position: %" PRIu8, touch_position); ESP_LOGE("${TAG_CORE_HW_TOUCH}", "Invalid long-touch position: %" PRIu8, touch_position);
} else { } 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: on_multi_touch_release:
@@ -401,29 +399,24 @@ 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: |-
static const char *TAG = "tx_ultimate_easy.on_multi_touch_release.core.hw.touch"; ESP_LOGI("${TAG_CORE_HW_TOUCH}", "Multi-touch released");
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(TAG, "Invalid touch position: %" PRIu8, position); ESP_LOGE("${TAG_CORE_HW_TOUCH}", "Invalid touch position: %" PRIu8, position);
} else { } 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<uint8_t>(touch.button), position); touch_on_press->execute(static_cast<uint8_t>(touch.button), position);
} }
on_release: on_release:
then: then:
- lambda: |- - lambda: |-
static const char *TAG = "tx_ultimate_easy.on_release.core.hw.touch"; ESP_LOGI("${TAG_CORE_HW_TOUCH}", "Released");
ESP_LOGI(TAG, "Released");
- script.execute: touch_on_release - script.execute: touch_on_release
on_swipe_left: on_swipe_left:
@@ -447,8 +440,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: |-
static const char *TAG = "tx_ultimate_easy.on_swipe_left.core.hw.touch"; ESP_LOGI("${TAG_CORE_HW_TOUCH}", "Swipe %s",
ESP_LOGI(TAG, "Swipe %s", (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "left" : "down"); (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:
@@ -472,16 +465,15 @@ 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: |-
static const char *TAG = "tx_ultimate_easy.on_swipe_right.core.hw.touch"; ESP_LOGI("${TAG_CORE_HW_TOUCH}", "Swipe %s",
ESP_LOGI(TAG, "Swipe %s", (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "right" : "up"); (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: |-
static const char *TAG = "tx_ultimate_easy.on_touch_event.core.hw.touch"; ESP_LOGD("${TAG_CORE_HW_TOUCH}", "Touch event:");
ESP_LOGD(TAG, "Touch event:"); ESP_LOGD("${TAG_CORE_HW_TOUCH}", " State: %i (%s)", touch.state, touch.state_str.c_str());
ESP_LOGD(TAG, " State: %i (%s)", touch.state, touch.state_str.c_str()); ESP_LOGD("${TAG_CORE_HW_TOUCH}", " Position: %i", touch.x);
ESP_LOGD(TAG, " Position: %i", touch.x);
uart: uart:
- id: uart_touch - id: uart_touch

View File

@@ -14,6 +14,8 @@
substitutions: substitutions:
SWITCH_AUDIO_AMPLIFIER_RESTORE_MODE: RESTORE_DEFAULT_ON SWITCH_AUDIO_AMPLIFIER_RESTORE_MODE: RESTORE_DEFAULT_ON
TAG_STD_HW_AUDIO: std.hw.audio
esphome: esphome:
platformio_options: platformio_options:
build_flags: build_flags:

View File

@@ -19,6 +19,8 @@ substitutions:
RELAY_RESTORE_MODE: RESTORE_DEFAULT_OFF RELAY_RESTORE_MODE: RESTORE_DEFAULT_OFF
LIGHT_RELAYS_RESTORE_MODE: RESTORE_DEFAULT_OFF LIGHT_RELAYS_RESTORE_MODE: RESTORE_DEFAULT_OFF
TAG_STD_HW_RELAYS: std.hw.relays
esphome: esphome:
platformio_options: platformio_options:
build_flags: build_flags:
@@ -466,8 +468,6 @@ 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
@@ -514,7 +514,7 @@ script:
} }
break; break;
default: 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; break;
} }
id(boot_initialization_relays_group_assignments) = true; id(boot_initialization_relays_group_assignments) = true;
@@ -637,8 +637,6 @@ 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;
@@ -657,13 +655,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(TAG, "Toggle relays:"); ESP_LOGW("${TAG_STD_HW_RELAYS}", "Toggle relays:");
ESP_LOGW(TAG, " API state: DISCONNECTED"); ESP_LOGW("${TAG_STD_HW_RELAYS}", " API state: DISCONNECTED");
ESP_LOGW(TAG, " Button: %" PRIu8, button); ESP_LOGW("${TAG_STD_HW_RELAYS}", " Button: %" PRIu8, button);
} else { } else {
ESP_LOGVV(TAG, "Toggle relays:"); ESP_LOGVV("${TAG_STD_HW_RELAYS}", "Toggle relays:");
ESP_LOGVV(TAG, " API state: Connected"); ESP_LOGVV("${TAG_STD_HW_RELAYS}", " API state: Connected");
ESP_LOGVV(TAG, " Button: %" PRIu8, button); ESP_LOGVV("${TAG_STD_HW_RELAYS}", " Button: %" PRIu8, button);
} }
switch (button) { switch (button) {
case ${BUTTON_1_ID}: case ${BUTTON_1_ID}:
@@ -696,57 +694,59 @@ script:
break; break;
} }
if (toggle_relay) { 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()) { } 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()); button, select_state.c_str());
} else { } 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 - 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(TAG, "Relay%s mode%s:", gang_count_plural_suffix.c_str(), gang_count_plural_suffix.c_str()); ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", "Relay%s mode%s:", gang_count_plural_suffix.c_str(),
ESP_LOGCONFIG(TAG, " Relay 1: %s", sl_relay_1_mode->has_state() ? 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"); sl_relay_1_mode->state.c_str() : "Unknown");
if (id(gang_count) >= 2) 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"); sl_relay_2_mode->state.c_str() : "Unknown");
if (id(gang_count) >= 3) 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"); sl_relay_3_mode->state.c_str() : "Unknown");
if (id(gang_count) >= 4) 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"); sl_relay_4_mode->state.c_str() : "Unknown");
// Relay's states // 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_STD_HW_RELAYS}", "Relay%s state%s:", 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("${TAG_STD_HW_RELAYS}", " Relay 1: %s", sw_relay_1->state ? "ON" : "OFF");
if (id(gang_count) >= 2) 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) 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) if (id(gang_count) >= 4)
ESP_LOGCONFIG(TAG, " Relay 4: %s", sw_relay_4->state ? "ON" : "OFF"); ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " 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}", "Expose Relay's LEDs to Home Assistant: %s",
YESNO(sw_expose_relays_leds_to_ha->state));
// Boot initialization statuses // Boot initialization statuses
ESP_LOGCONFIG(TAG, "Boot initialization flags:"); ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", "Boot initialization flags:");
ESP_LOGCONFIG(TAG, " Overall: %s", YESNO(id(boot_initialization_relays))); ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Overall: %s", YESNO(id(boot_initialization_relays)));
ESP_LOGCONFIG(TAG, " Groups: %s", YESNO(id(boot_initialization_relays_group_assignments))); ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Groups: %s",
ESP_LOGCONFIG(TAG, " Light modes: %s", YESNO(id(boot_initialization_relays_light_modes))); YESNO(id(boot_initialization_relays_group_assignments)));
ESP_LOGCONFIG(TAG, " Relay modes: %s", YESNO(id(boot_initialization_relays_relay_modes))); ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Light modes: %s", YESNO(id(boot_initialization_relays_light_modes)));
ESP_LOGCONFIG(TAG, " Status LEDs: %s", YESNO(id(boot_initialization_relays_relay_leds))); 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 // Substitutions
ESP_LOGCONFIG(TAG, "Restore modes:"); ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", "Restore modes:");
ESP_LOGCONFIG(TAG, " Relays: ${RELAY_RESTORE_MODE}"); ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Relays: ${RELAY_RESTORE_MODE}");
ESP_LOGCONFIG(TAG, " Status LEDs: ${LIGHT_RELAYS_RESTORE_MODE}"); ESP_LOGCONFIG("${TAG_STD_HW_RELAYS}", " Status LEDs: ${LIGHT_RELAYS_RESTORE_MODE}");
- id: !extend dump_config_list_packages - id: !extend dump_config_list_packages
then: then:
@@ -765,10 +765,8 @@ 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(TAG, "Relays not initialized yet"); ESP_LOGW("${TAG_STD_HW_RELAYS}", "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;
@@ -811,8 +809,8 @@ script:
break; break;
} }
ESP_LOGV(TAG, "Relay %" PRIu8 " is %s", i + 1, relay_state ? "ON" : "OFF"); ESP_LOGV("${TAG_STD_HW_RELAYS}", "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}", "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

@@ -16,6 +16,8 @@ substitutions:
# d=32 (32nd note), o=5 (octave 5), b=100 (tempo 100) # 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 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: packages:
standard_hw_audio: !include TX-Ultimate-Easy-ESPHome_standard_hw_audio.yaml standard_hw_audio: !include TX-Ultimate-Easy-ESPHome_standard_hw_audio.yaml
@@ -29,11 +31,9 @@ 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(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()); rtttl_speaker->play(tone.c_str());
} }

View File

@@ -14,6 +14,8 @@
substitutions: substitutions:
vibration_max_duration: 2s vibration_max_duration: 2s
TAG_STD_HW_VIBRATION: std.hw.vibration
binary_sensor: binary_sensor:
- id: bs_vibrating - id: bs_vibrating
name: Vibrating name: Vibrating
@@ -61,19 +63,17 @@ 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(TAG, "Touch - Vibration feedback: %s", ESP_LOGCONFIG("${TAG_STD_HW_VIBRATION}", "Touch - Vibration feedback: %s",
sl_touch_vibration_feedback->state.c_str()); sl_touch_vibration_feedback->state.c_str());
ESP_LOGCONFIG(TAG, "Vibrate duration: %.0fms", nr_vibrating_duration->state); ESP_LOGCONFIG("${TAG_STD_HW_VIBRATION}", "Vibrate duration: %.0fms", nr_vibrating_duration->state);
ESP_LOGCONFIG(TAG, "Vibrate max duration: ${vibration_max_duration}"); ESP_LOGCONFIG("${TAG_STD_HW_VIBRATION}", "Vibrate max duration: ${vibration_max_duration}");
// State // State
if (bs_vibrating->state) if (bs_vibrating->state)
ESP_LOGW(TAG, "Vibrating now: YES"); ESP_LOGW("${TAG_STD_HW_VIBRATION}", "Vibrating now: YES");
else else
ESP_LOGCONFIG(TAG, "Vibrating now: No"); ESP_LOGCONFIG("${TAG_STD_HW_VIBRATION}", "Vibrating now: No");
- id: !extend dump_config_list_packages - id: !extend dump_config_list_packages
then: then:

View File

@@ -11,6 +11,9 @@
##### - For normal system use, modifications to this file are NOT required. ##### ##### - For normal system use, modifications to this file are NOT required. #####
#################################################################################################### ####################################################################################################
--- ---
substitutions:
TAG_STD_MEDIA_PLAYER: "std.media-player"
packages: packages:
standard_hw_speaker: !include TX-Ultimate-Easy-ESPHome_standard_hw_speaker.yaml standard_hw_speaker: !include TX-Ultimate-Easy-ESPHome_standard_hw_speaker.yaml
@@ -50,13 +53,12 @@ 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(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: script:
@@ -67,12 +69,11 @@ 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(TAG, "Media Player Volume Sync:"); ESP_LOGCONFIG("${TAG_STD_MEDIA_PLAYER}", "Media Player Volume Sync:");
ESP_LOGCONFIG(TAG, " Persistent volume: %" PRIu8 "%", id(persistent_media_player_volume)); ESP_LOGCONFIG("${TAG_STD_MEDIA_PLAYER}", " Persistent volume: %" PRIu8 "%",
ESP_LOGCONFIG(TAG, " Current volume: %.1f%%", mp_media_player->volume * 100.0f); 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 - id: !extend dump_config_list_packages
then: then:
@@ -97,10 +98,9 @@ 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(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: speaker:
- platform: mixer - platform: mixer