Standardize log tag - hw leds

This commit is contained in:
Edward Firmo
2025-08-05 09:01:36 +02:00
parent 1d8b4fee1a
commit c1f1b5a7e7

View File

@@ -497,44 +497,46 @@ 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("core_hw_leds", "Relay%s LEDs mode%s:", ESP_LOGCONFIG(TAG, "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("core_hw_leds", " Relay 1: %s", id(is_us_model) ESP_LOGCONFIG(TAG, " 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("core_hw_leds", " Relay 2: %s", id(is_us_model) ESP_LOGCONFIG(TAG, " 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("core_hw_leds", " Relay 3: %s", id(is_us_model) ESP_LOGCONFIG(TAG, " 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("core_hw_leds", " Relay 4: %s", id(is_us_model) ESP_LOGCONFIG(TAG, " 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("core_hw_leds", "Transition times:"); ESP_LOGCONFIG(TAG, "Transition times:");
ESP_LOGCONFIG("core_hw_leds", " Default: ${default_transition_length}"); ESP_LOGCONFIG(TAG, " Default: ${default_transition_length}");
if (${LIGHT_TRANSITION_TURN_ON} > 0) if (${LIGHT_TRANSITION_TURN_ON} > 0)
ESP_LOGCONFIG("core_hw_leds", " Turning on: ${LIGHT_TRANSITION_TURN_ON}ms"); ESP_LOGCONFIG(TAG, " Turning on: ${LIGHT_TRANSITION_TURN_ON}ms");
else else
ESP_LOGCONFIG("core_hw_leds", " Turning on: Disabled"); ESP_LOGCONFIG(TAG, " Turning on: Disabled");
if (${LIGHT_TRANSITION_TURN_OFF} > 0) if (${LIGHT_TRANSITION_TURN_OFF} > 0)
ESP_LOGCONFIG("core_hw_leds", " Turning off: ${LIGHT_TRANSITION_TURN_OFF}ms"); ESP_LOGCONFIG(TAG, " Turning off: ${LIGHT_TRANSITION_TURN_OFF}ms");
else else
ESP_LOGCONFIG("core_hw_leds", " Turning off: Disabled"); ESP_LOGCONFIG(TAG, " Turning off: Disabled");
// Restore modes // Restore modes
ESP_LOGCONFIG("core_hw_leds", "LED restore modes:"); ESP_LOGCONFIG(TAG, "LED restore modes:");
ESP_LOGCONFIG("core_hw_leds", " Light - All: ${LIGHT_FULL_RESTORE_MODE}"); ESP_LOGCONFIG(TAG, " Light - All: ${LIGHT_FULL_RESTORE_MODE}");
ESP_LOGCONFIG("core_hw_leds", " Sides: ${LIGHT_SIDES_RESTORE_MODE}"); ESP_LOGCONFIG(TAG, " Sides: ${LIGHT_SIDES_RESTORE_MODE}");
ESP_LOGCONFIG("core_hw_leds", " Individual: ${LIGHT_INDIVIDUAL_RESTORE_MODE}"); ESP_LOGCONFIG(TAG, " Individual: ${LIGHT_INDIVIDUAL_RESTORE_MODE}");
- id: !extend dump_config_list_packages - id: !extend dump_config_list_packages
then: then:
@@ -556,6 +558,8 @@ 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};
@@ -570,13 +574,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("core_hw_leds", "Invalid set with %s light for Relay %" PRIu8, ESP_LOGE(TAG, "Invalid set with %s light for Relay %" PRIu8, light_mode_group_1.c_str(), light_index+1);
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("core_hw_leds", "Turn-on %s light for Relay %" PRIu8, ESP_LOGI(TAG, "Turn-on %s light for Relay %" PRIu8, light_mode_group_1.c_str(), light_index+1);
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
@@ -584,8 +586,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("core_hw_leds", "Turn-off %s light for Relay %" PRIu8, ESP_LOGI(TAG, "Turn-off %s light for Relay %" PRIu8, light_mode_group_1.c_str(), light_index+1);
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
@@ -594,13 +595,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("core_hw_leds", "Invalid set with %s light for Relay %" PRIu8, ESP_LOGE(TAG, "Invalid set with %s light for Relay %" PRIu8, light_mode_group_2.c_str(), light_index+1);
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("core_hw_leds", "Turn-on %s light for Relay %" PRIu8, ESP_LOGI(TAG, "Turn-on %s light for Relay %" PRIu8, light_mode_group_2.c_str(), light_index+1);
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
@@ -608,8 +607,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("core_hw_leds", "Turn-off %s light for Relay %" PRIu8, ESP_LOGI(TAG, "Turn-off %s light for Relay %" PRIu8, light_mode_group_2.c_str(), light_index+1);
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