Skip to content

Commit

Permalink
Merge pull request #72 from edwardtfn/dump-config
Browse files Browse the repository at this point in the history
Add dump config
  • Loading branch information
edwardtfn authored Dec 25, 2024
2 parents cca59bb + 5ddf538 commit 876d03a
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 13 deletions.
6 changes: 6 additions & 0 deletions ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ rtttl:
- id: rtttl_speaker
speaker: mp_speaker

script:
- id: !extend dump_config
then:
- lambda: |-
ESP_LOGCONFIG("addon_ble_proxy", "Add-on BLE Proxy installed");
speaker:
- id: mp_speaker
platform: i2s_audio
Expand Down
72 changes: 66 additions & 6 deletions ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ substitutions:
TX_MODEL_3_GANG_TEXT: "3 Gang"
TX_MODEL_4_GANG_TEXT: "4 Gang"

DUMP_CONFIG_CALLER_DELAY: 10s # Delay to dump config after requested

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_speaker: !include TX-Ultimate-Easy-ESPHome_core_hw_speaker.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
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_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

api:
id: api_server
on_client_connected:
then:
- script.execute: dump_config_caller
- script.execute: publish_device_info

binary_sensor:
Expand All @@ -49,6 +52,14 @@ binary_sensor:
platform: template
entity_category: diagnostic
device_class: problem
on_state:
then:
- lambda: |-
if (x)
ESP_LOGW("core", "Pending restart: YES");
else
ESP_LOGCONFIG("core", "Pending restart: No");
- script.execute: dump_config_caller

button:
- id: bt_restart
Expand Down Expand Up @@ -95,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

Expand Down Expand Up @@ -149,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
Expand All @@ -158,6 +176,48 @@ script:
id: bs_pending_restart
state: false

- id: dump_config
mode: restart
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}");
// Framework detection
#ifdef ARDUINO
ESP_LOGCONFIG("core", "Framework: Arduino");
#elif defined(USE_ESP_IDF)
ESP_LOGCONFIG("core", "Framework: ESP-IDF");
#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_plural_suffix).c_str());
// System state
if (bs_pending_restart->state)
ESP_LOGW("core", "Pending restart: YES");
else
ESP_LOGCONFIG("core", "Pending restart: No");
- id: dump_config_caller
mode: restart
then:
- delay: ${DUMP_CONFIG_CALLER_DELAY}
- script.execute: dump_config

- id: publish_device_info
mode: restart
then:
Expand Down
22 changes: 22 additions & 0 deletions ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,28 @@ script:
}
}
- id: !extend dump_config
then:
- lambda: |-
ESP_LOGCONFIG("core_hw_buttons", "Button%s action%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->has_state()
? sl_button_1_action->state.c_str()
: "Unknown");
if (id(gang_count) >= 2)
ESP_LOGCONFIG("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("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("core_hw_buttons", " Relay 4: %s", sl_button_4_action->has_state()
? sl_button_4_action->state.c_str()
: "Unknown");
- id: !extend touch_on_multi_touch_release
then:
- script.execute: buttons_release
Expand Down
50 changes: 44 additions & 6 deletions ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,52 @@ script:
light_eu_rl_3_4_top, light_eu_rl_4_4_top };
}
break;
default:
ESP_LOGE("core_hw_leds", "Invalid gang count: %" PRIu8, id(gang_count));
break;
}
- id: !extend dump_config
then:
- lambda: |-
// Relay's LEDs modes
ESP_LOGCONFIG("core_hw_leds", "Relay%s LEDs mode%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());
if (id(gang_count) >= 2)
ESP_LOGCONFIG("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("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("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("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");
else
ESP_LOGCONFIG("core_hw_leds", " Turning on: Disabled");
if (${LIGHT_TRANSITION_TURN_OFF} > 0)
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}");
ESP_LOGCONFIG("core_hw_leds", " Individual: ${LIGHT_INDIVIDUAL_RESTORE_MODE}");
- id: light_set_state
mode: parallel
parameters:
Expand Down Expand Up @@ -571,15 +615,12 @@ select:
entity_category: config
disabled_by_default: false
icon: mdi:dots-square

- id: sl_relay_2_light_mode_eu
name: Relay 2 light mode
<<: *relay_light_mode_eu

- id: sl_relay_3_light_mode_eu
name: Relay 3 light mode
<<: *relay_light_mode_eu

- id: sl_relay_4_light_mode_eu
name: Relay 4 light mode
<<: *relay_light_mode_eu
Expand All @@ -601,15 +642,12 @@ select:
entity_category: config
disabled_by_default: false
icon: mdi:dots-square

- id: sl_relay_2_light_mode_us
name: Relay 2 light mode
<<: *relay_light_mode_us

- id: sl_relay_3_light_mode_us
name: Relay 3 light mode
<<: *relay_light_mode_us

- id: sl_relay_4_light_mode_us
name: Relay 4 light mode
<<: *relay_light_mode_us
Expand Down
42 changes: 42 additions & 0 deletions ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,48 @@ script:
ESP_LOGE("core_hw_relays", "No button action selected for button %" PRIu8, button);
}
- id: !extend dump_config
then:
- lambda: |-
ESP_LOGCONFIG("core_hw_relays", "Relay%s mode%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->has_state()
? sl_relay_1_mode->state.c_str()
: "Unknown");
if (id(gang_count) >= 2)
ESP_LOGCONFIG("core_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("core_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("core_hw_relays", " Relay 4: %s", sl_relay_4_mode->has_state()
? sl_relay_4_mode->state.c_str()
: "Unknown");
ESP_LOGCONFIG("core_hw_relays", "Relay%s state%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");
if (id(gang_count) >= 3)
ESP_LOGCONFIG("core_hw_relays", " Relay 3: %s", sw_relay_3->state ? "ON" : "OFF");
if (id(gang_count) >= 4)
ESP_LOGCONFIG("core_hw_relays", " Relay 4: %s", sw_relay_4->state ? "ON" : "OFF");
ESP_LOGCONFIG("core_hw_relays", "Expose Relay's LEDs to Home Assistant: %s",
YESNO(sw_expose_relays_leds_to_ha->state));
ESP_LOGCONFIG("core_hw_relays", "Boot initialization flags:");
ESP_LOGCONFIG("core_hw_relays", " Overall: %s", YESNO(id(boot_initialization_relays)));
ESP_LOGCONFIG("core_hw_relays", " Light modes: %s", YESNO(id(boot_initialization_relays_light_modes)));
ESP_LOGCONFIG("core_hw_relays", " Relay modes: %s", YESNO(id(boot_initialization_relays_relay_modes)));
ESP_LOGCONFIG("core_hw_relays", " Status LEDs: %s", YESNO(id(boot_initialization_relays_relay_leds)));
ESP_LOGCONFIG("core_hw_relays", "Restore modes:");
ESP_LOGCONFIG("core_hw_relays", " Relays: ${RELAY_RESTORE_MODE}");
ESP_LOGCONFIG("core_hw_relays", " Status LEDs: ${LIGHT_RELAYS_RESTORE_MODE}");
- id: show_relay_status
mode: restart
then:
Expand Down
9 changes: 9 additions & 0 deletions ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ script:
bs_button_3_long_press_event->set_internal(id(gang_count) < 3);
bs_button_4_long_press_event->set_internal(id(gang_count) < 4);
- id: !extend dump_config
then:
- lambda: |-
if (sw_touch_panel_power->state)
ESP_LOGCONFIG("core_hw_touch", "Touch panel - Power: On");
else
ESP_LOGW("core_hw_touch", "Touch panel - Power: OFF");
ESP_LOGCONFIG("core_hw_touch", "Touch event duration: %.0fms", nr_touch_duration->state);
- id: touch_on_multi_touch_release
mode: restart
then:
Expand Down
16 changes: 15 additions & 1 deletion ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ ota:
- switch.turn_off: sw_vibration_motor

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
ESP_LOGCONFIG("core_hw_vibration", "Vibrating now: No");
- id: !extend touch_on_multi_touch_release
then:
- script.execute: touch_on_multi_touch_release_vibration
Expand Down Expand Up @@ -133,5 +148,4 @@ switch:
- binary_sensor.template.publish:
id: bs_vibrating
state: OFF # yamllint disable-line rule:truthy

...

0 comments on commit 876d03a

Please sign in to comment.