CodeRabbitAI suggestions

This commit is contained in:
Edward Firmo
2024-12-25 02:34:18 +01:00
parent e546fedf08
commit 7aee88c38f
5 changed files with 37 additions and 13 deletions

View File

@@ -31,8 +31,8 @@ packages:
# yamllint disable rule:colons
core_hw_buttons: !include TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml
core_hw_leds: !include TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml
core_hw_relays: !include TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml
core_hw_media_player: !include TX-Ultimate-Easy-ESPHome_core_hw_media_player.yaml
core_hw_relays: !include TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml
core_hw_touch: !include TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml
core_hw_vibration: !include TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml
# yamllint enable rule:colons
@@ -41,8 +41,8 @@ api:
id: api_server
on_client_connected:
then:
- script.execute: publish_device_info
- script.execute: dump_config_caller
- script.execute: publish_device_info
binary_sensor:
- id: bs_pending_restart
@@ -59,6 +59,7 @@ binary_sensor:
ESP_LOGW("core", "Pending restart: YES");
else
ESP_LOGCONFIG("core", "Pending restart: No");
- script.execute: dump_config_caller
button:
- id: bt_restart
@@ -105,6 +106,12 @@ globals:
restore_value: true
initial_value: '0'
- id: gang_count_plural_suffix
type: std::string
restore_value: true
max_restore_data_length: 3
# initial_value: "''"
improv_serial:
id: serial_improv
@@ -159,6 +166,7 @@ script:
if (id(gang_count) < 1 || id(gang_count) > 4) {
ESP_LOGE("core_hw_leds", "Invalid number of gangs: %" PRIu8, id(gang_count));
}
id(gang_count_plural_suffix) = id(gang_count) > 1 ? "s" : "";
- id: boot_sequence
mode: restart
@@ -173,13 +181,17 @@ script:
then:
# Extended by all modules
- lambda: |-
// Device identification
ESP_LOGCONFIG("core", "Device friendly name: ${friendly_name}");
ESP_LOGCONFIG("core", "Device name: ${name}");
ESP_LOGCONFIG("core", "Device name (HA): %s", tx_device_name->state.c_str());
ESP_LOGCONFIG("core", "Device hostname: %s", App.get_name().c_str());
// Version information
ESP_LOGCONFIG("core", "ESPHome builder: %s", esphome_fw_version->state.c_str());
ESP_LOGCONFIG("core", "TX Ultimate firmware version: ${version}");
// Report framework
// Framework detection
#ifdef ARDUINO
ESP_LOGCONFIG("core", "Framework: Arduino");
#elif defined(USE_ESP_IDF)
@@ -187,10 +199,14 @@ script:
#else
ESP_LOGW("core", "Framework: UNKNOWN");
#endif
// Model configuration
ESP_LOGCONFIG("core", "Model format (selected): %s", sl_tx_model_format->state.c_str());
ESP_LOGCONFIG("core", "Model format (detected): %s", id(is_us_model) ? "US" : "EU");
ESP_LOGCONFIG("core", "Gangs (selected): %s", sl_tx_model_gang->state.c_str());
ESP_LOGCONFIG("core", "Gangs (detected): %" PRIu8 "-Gang%s", id(gang_count), id(gang_count) == 1 ? "" : "s");
ESP_LOGCONFIG("core", "Gangs (detected): %" PRIu8 "-Gang%s", id(gang_count), id(gang_count_plural_suffix).c_str());
// System state
if (bs_pending_restart->state)
ESP_LOGW("core", "Pending restart: YES");
else

View File

@@ -204,8 +204,8 @@ script:
then:
- lambda: |-
ESP_LOGCONFIG("core_hw_buttons", "Button%s action%s:",
id(gang_count) == 1 ? "" : "s",
id(gang_count) == 1 ? "" : "s");
id(gang_count_plural_suffix).c_str(),
id(gang_count_plural_suffix).c_str());
ESP_LOGCONFIG("core_hw_buttons", " Relay 1: %s", sl_button_1_action->state.c_str());
if (id(gang_count) >= 2)
ESP_LOGCONFIG("core_hw_buttons", " Relay 2: %s", sl_button_2_action->state.c_str());

View File

@@ -489,9 +489,10 @@ script:
- id: !extend dump_config
then:
- lambda: |-
// Relay's LEDs modes
ESP_LOGCONFIG("core_hw_leds", "Relay%s LEDs mode%s:",
id(gang_count) == 1 ? "" : "s",
id(gang_count) == 1 ? "" : "s");
id(gang_count_plural_suffix).c_str(),
id(gang_count_plural_suffix).c_str());
ESP_LOGCONFIG("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());
@@ -507,7 +508,9 @@ script:
ESP_LOGCONFIG("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());
ESP_LOGCONFIG("core_hw_leds", "Transition time:");
// Transition times
ESP_LOGCONFIG("core_hw_leds", "Transition times:");
ESP_LOGCONFIG("core_hw_leds", " Default: ${default_transition_length}");
if (${LIGHT_TRANSITION_TURN_ON} > 0)
ESP_LOGCONFIG("core_hw_leds", " Turning on: ${LIGHT_TRANSITION_TURN_ON}ms");
@@ -517,6 +520,8 @@ script:
ESP_LOGCONFIG("core_hw_leds", " Turning off: ${LIGHT_TRANSITION_TURN_OFF}ms");
else
ESP_LOGCONFIG("core_hw_leds", " Turning off: Disabled");
// Restore modes
ESP_LOGCONFIG("core_hw_leds", "LED restore modes:");
ESP_LOGCONFIG("core_hw_leds", " Light - All: ${LIGHT_FULL_RESTORE_MODE}");
ESP_LOGCONFIG("core_hw_leds", " Sides: ${LIGHT_SIDES_RESTORE_MODE}");

View File

@@ -638,8 +638,8 @@ script:
then:
- lambda: |-
ESP_LOGCONFIG("core_hw_relays", "Relay%s mode%s:",
id(gang_count) == 1 ? "" : "s",
id(gang_count) == 1 ? "" : "s");
id(gang_count_plural_suffix).c_str(),
id(gang_count_plural_suffix).c_str());
ESP_LOGCONFIG("core_hw_relays", " Relay 1: %s", sl_relay_1_mode->state.c_str());
if (id(gang_count) >= 2)
ESP_LOGCONFIG("core_hw_relays", " Relay 2: %s", sl_relay_2_mode->state.c_str());
@@ -648,8 +648,8 @@ script:
if (id(gang_count) >= 4)
ESP_LOGCONFIG("core_hw_relays", " Relay 4: %s", sl_relay_4_mode->state.c_str());
ESP_LOGCONFIG("core_hw_relays", "Relay%s state%s:",
id(gang_count) == 1 ? "" : "s",
id(gang_count) == 1 ? "" : "s");
id(gang_count_plural_suffix).c_str(),
id(gang_count_plural_suffix).c_str());
ESP_LOGCONFIG("core_hw_relays", " Relay 1: %s", sw_relay_1->state ? "ON" : "OFF");
if (id(gang_count) >= 2)
ESP_LOGCONFIG("core_hw_relays", " Relay 2: %s", sw_relay_2->state ? "ON" : "OFF");

View File

@@ -56,10 +56,13 @@ script:
- id: !extend dump_config
then:
- lambda: |-
// Configuration
ESP_LOGCONFIG("core_hw_vibration", "Touch - Vibration feedback: %s",
sl_touch_vibration_feedback->state.c_str());
ESP_LOGCONFIG("core_hw_vibration", "Vibrate duration: %.0fms", nr_vibrating_duration->state);
ESP_LOGCONFIG("core_hw_vibration", "Vibrate max duration: ${vibration_max_duration}");
// State
if (bs_vibrating->state)
ESP_LOGW("core_hw_vibration", "Vibrating now: YES");
else