Skip to content

Commit

Permalink
add-on climate self registering
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardtfn committed Dec 5, 2024
1 parent 55edc0e commit 2ca516c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 38 deletions.
2 changes: 1 addition & 1 deletion components/nspanel_ha_blueprint/core_boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace nspanel_ha_blueprint {
};

// Fixed array to store the boot steps
static constexpr size_t MAX_BOOT_STEPS = 32;
static constexpr size_t MAX_BOOT_STEPS = 35;
extern BootStep boot_steps[MAX_BOOT_STEPS];

// Function to set up the boot steps array
Expand Down
5 changes: 5 additions & 0 deletions esphome/nspanel_esphome_addon_climate_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ substitutions:
cool_overrun: "0.5" # Temperature delta before disengaging cooling
heat_deadband: "0.5" # Temperature delta before engaging heat
heat_overrun: "0.5" # Temperature delta before disengaging heat
BOOT_STEP_ADDON_CLIMATE: '32'

esphome:
platformio_options:
Expand Down Expand Up @@ -105,6 +106,10 @@ switch:
optimistic: true

script:
- id: !extend boot_package_register
then:
- lambda: boot_package_register_add->execute(${BOOT_STEP_ADDON_CLIMATE}, "ADDON_CLIMATE", "Add-on Climate");

- id: !extend boot_sequence
then:
- lambda: |-
Expand Down
10 changes: 2 additions & 8 deletions esphome/nspanel_esphome_core_boot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,11 @@ script:
- id: boot_event
mode: restart
then:
- lambda: |-
ESP_LOGW("DEBUG", "boot_event called");
- delay: 20s
- lambda: |-
ESP_LOGW("DEBUG", "boot_event checking");
- while:
condition:
- lambda: return not is_boot_complete();
then:
- lambda: |-
ESP_LOGW("DEBUG", "boot_event informing HA");
- script.execute:
id: boot_event_ha
step_name: timeout
Expand All @@ -84,7 +78,6 @@ script:
step_name: string
then:
- lambda: |-
ESP_LOGW("DEBUG", "boot_event_ha called with step_name: '%s'", step_name.c_str());
esphome::api::CustomAPIDevice ha_event;
std::map<std::string, std::string> event_data;
Expand Down Expand Up @@ -180,6 +173,7 @@ script:
page_boot_log->execute("Boot", "Starting boot sequence");
if (!show_boot_page)
reset_boot_steps();
boot_event_ha->execute("start");
boot_event->execute();
boot_progress_dump->execute();
if (!disp1->is_setup())
Expand Down Expand Up @@ -218,7 +212,7 @@ script:
timeout: 10s
- lambda: |-
page_boot_log->execute("Boot", "Report to Blueprint");
boot_event_ha->execute("start");
boot_event_ha->execute("ready");
boot_progress->execute(${BOOT_STEP_BOOT});
boot_event->execute();
Expand Down
20 changes: 10 additions & 10 deletions esphome/nspanel_esphome_core_hw_display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ script:
- lambda: |-
screen_power->turn_off();
ESP_LOGE("script", "Nextion reported a buffer overflow");
ESP_LOGE("script", "Increasing the delay factor...");
ESP_LOGE("script", "Increasing the display delay...");
- number.increment:
id: display_delay
cycle: false
Expand Down Expand Up @@ -576,23 +576,23 @@ script:
// Report Nextion status
nextion_init->publish_state(nextion_init->state and disp1->is_setup());
ESP_LOGI("${project_tag}", "Nextion:");
ESP_LOGI("${project_tag}", " Delay factor: %" PRIu8, static_cast<uint8_t>(display_delay->state));
ESP_LOGI("${project_tag}", " Queue size: %d", disp1->queue_size());
ESP_LOGI("${project_tag}", " Display delay: %" PRIu8, static_cast<uint8_t>(display_delay->state));
ESP_LOGI("${project_tag}", " Queue size: %d", disp1->queue_size());
if (disp1->is_setup())
ESP_LOGI("${project_tag}", " Is setup: True");
ESP_LOGI("${project_tag}", " Is setup: True");
else {
ESP_LOGW("${project_tag}", " Is setup: False");
ESP_LOGW("${project_tag}", " Is detected: %s", YESNO(disp1->is_detected()));
ESP_LOGW("${project_tag}", " Is setup: False");
ESP_LOGW("${project_tag}", " Is detected: %s", YESNO(disp1->is_detected()));
//exit_reparse->execute();
}
if (nextion_init->state) {
ESP_LOGI("${project_tag}", " Init: True");
ESP_LOGI("${project_tag}", " Init: True");
} else
ESP_LOGW("${project_tag}", " Init: False");
ESP_LOGW("${project_tag}", " Init: False");
if (id(version_tft).empty())
ESP_LOGW("${project_tag}", " TFT: UNKNOWN");
ESP_LOGW("${project_tag}", " TFT: UNKNOWN");
else
ESP_LOGI("${project_tag}", " TFT: %s", id(version_tft).c_str());
ESP_LOGI("${project_tag}", " TFT: %s", id(version_tft).c_str());
- id: entity_details_show_action
mode: restart
Expand Down
53 changes: 34 additions & 19 deletions nspanel_blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8591,7 +8591,6 @@ actions:
- alias: Boot init
conditions:
- '{{ nspanel_event.type == "boot"}}'
- '{{ nspanel_event.step is defined and nspanel_event.step in ["start", "timeout"]}}'
sequence: # Boot init
- variables:
is_boot: true
Expand All @@ -8611,7 +8610,9 @@ actions:
message: 'NSPanel requested boot parameters: {{ nspanel_event }}'

- alias: BOOT_STEP_VERSIONING
if: '{{ nspanel_event.BOOT_STEP_VERSIONING is defined and nspanel_event.BOOT_STEP_VERSIONING }}'
if:
- '{{ nspanel_event.BOOT_STEP_VERSIONING is defined }}'
- '{{ nspanel_event.BOOT_STEP_VERSIONING }}'
then:
- alias: Send the blueprint version
sequence:
Expand Down Expand Up @@ -9123,7 +9124,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_HW_TEMPERATURE
if: >
if:
- '{{ nspanel_event.BOOT_STEP_HW_TEMPERATURE is defined }}'
- '{{ nspanel_event.BOOT_STEP_HW_TEMPERATURE }}'
then:
Expand Down Expand Up @@ -9206,7 +9207,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_BUTTONS
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_BUTTONS is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_BUTTONS }}'
then:
Expand Down Expand Up @@ -9487,7 +9488,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_CLIMATE
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_CLIMATE is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_CLIMATE }}'
then:
Expand Down Expand Up @@ -9524,7 +9525,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_CONFIRM
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_CONFIRM is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_CONFIRM }}'
then:
Expand Down Expand Up @@ -9565,7 +9566,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_ENTITIES
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_ENTITIES is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_ENTITIES }}'
then:
Expand Down Expand Up @@ -10163,7 +10164,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_KEYBOARD_NUM
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_KEYBOARD_NUM is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_KEYBOARD_NUM }}'
then: # There's nothing here so far
Expand Down Expand Up @@ -10193,7 +10194,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_MEDIA_PLAYER
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_MEDIA_PLAYER is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_MEDIA_PLAYER }}'
then: # There's nothing here so far
Expand All @@ -10209,7 +10210,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_NOTIFICATION
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_NOTIFICATION is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_NOTIFICATION }}'
then: # There's nothing here so far
Expand All @@ -10225,7 +10226,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_QRCODE
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_QRCODE is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_QRCODE }}'
then:
Expand Down Expand Up @@ -10307,7 +10308,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_SCREENSAVER
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_SCREENSAVER is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_SCREENSAVER }}'
then:
Expand Down Expand Up @@ -10351,7 +10352,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_SETTINGS
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_SETTINGS is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_SETTINGS }}'
then:
Expand Down Expand Up @@ -10407,7 +10408,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_UTILITIES
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_UTILITIES is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_UTILITIES }}'
then:
Expand Down Expand Up @@ -10447,7 +10448,7 @@ actions:
continue_on_error: true

- alias: BOOT_STEP_PAGE_WEATHER
if: >
if:
- '{{ nspanel_event.BOOT_STEP_PAGE_WEATHER is defined }}'
- '{{ nspanel_event.BOOT_STEP_PAGE_WEATHER }}'
then:
Expand Down Expand Up @@ -10490,11 +10491,15 @@ actions:
val: 30
continue_on_error: true

- &ADD_ON
sequence:
- &ADD_ON_CLIMATE
- alias: BOOT_STEP_ADDON_CLIMATE
if:
- '{{ BOOT_STEP_ADDON_CLIMATE in nspanel_event }}'
- '{{ nspanel_event.BOOT_STEP_ADDON_CLIMATE }}'
then: # There's nothing here so far
- *boot_delay

- alias: Set climate friendly name
sequence:
- *boot_delay
- variables:
climate_friendly_name: '{{ state_attr(climate, "friendly_name") }}'
- *delay_default
Expand All @@ -10504,6 +10509,16 @@ actions:
val: '{{ climate_friendly_name if climate_friendly_name else "" }}'
continue_on_error: true

- alias: Set BOOT_STEP_ADDON_CLIMATE
sequence:
- *delay_default
- alias: set_bool.BOOT_STEP_ADDON_CLIMATE
action: 'esphome.{{ nspanel_name }}_set_int'
data:
component: BOOT_STEP
val: 32
continue_on_error: true

##### Update Date & Time before showing the Home page #####
- *refresh_date

Expand Down

0 comments on commit 2ca516c

Please sign in to comment.