Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .test/esphome_common_customizations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ binary_sensor:
id: display_state
platform: template
lambda: |-
return (current_page_id != ${PAGE_SCREENSAVER_ID});
return (current_page_id != get_page_id("screensaver"));

button:
# Adds a button to put the panel to sleep
Expand All @@ -28,7 +28,7 @@ button:
then:
- logger.log: Button Sleep pressed
- lambda: |-
goto_page->execute(${PAGE_SCREENSAVER_ID});
goto_page->execute(get_page_id("screensaver"));

# Adds a button to wake-up the panel (similar to the existing service)
- name: ${device_name} Wake-up
Expand All @@ -39,7 +39,7 @@ button:
then:
- logger.log: Button Wake-up pressed
- lambda: |-
if (current_page_id == ${PAGE_SCREENSAVER_ID}) id(disp1).goto_page(wakeup_page_id);
if (current_page_id == get_page_id("screensaver")) id(disp1).goto_page(wakeup_page_id);
// timer_page->execute(); // enable this if you want page timeout to be reset
timer_sleep->execute();
timer_dim->execute();
Expand Down
4 changes: 0 additions & 4 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ allowing for real-time interaction with the alarm system directly from the panel

**Parameters:**

- `page_title` (string): The title displayed at the top of the alarm settings page.
- `state` (string): The current state of the alarm system, such as "armed_home" or "disarmed".
- `supported_features` (int): A bitmask indicating the features supported by the alarm system.
This determines the controls and options available on the alarm settings page.
Expand All @@ -521,7 +520,6 @@ The bitmask values are aligned with the
```yaml
action: esphome.<your_panel_name>_page_alarm
data:
page_title: "Home Security System"
state: "disarmed"
supported_features: 31 # Example: Supports arm/disarm, home/away modes, etc.
code_format: "number"
Expand Down Expand Up @@ -624,7 +622,6 @@ allowing real-time interaction with the media player directly from the panel.
- `entity` (string): The entity ID of the media player.
- `state` (string): The current state of the media player (e.g., playing, paused, stopped).
- `is_volume_muted` (bool): Indicates whether the volume is currently muted.
- `friendly_name` (string): The friendly name of the media player to be displayed as the page title.
- `volume_level` (int): The current volume level of the media player.
- `media_title` (string): The title of the currently playing media.
- `media_artist` (string): The artist of the currently playing media.
Expand All @@ -643,7 +640,6 @@ data:
entity: "media_player.living_room"
state: "playing"
is_volume_muted: false
friendly_name: "Living Room Player"
volume_level: 40
media_title: "Favorite Song"
media_artist: "Famous Artist"
Expand Down
8 changes: 4 additions & 4 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ binary_sensor:
id: display_state
platform: template
lambda: |-
return (current_page_id != ${PAGE_SCREENSAVER_ID});
return (current_page_id != get_page_id("screensaver"));
```

You can easily invert the meaning to have a sensor for display sleeping:
Expand All @@ -335,7 +335,7 @@ binary_sensor:
id: display_sleeping
platform: template
lambda: |-
return (current_page_id == ${PAGE_SCREENSAVER_ID});
return (current_page_id == get_page_id("screensaver"));
```

### Deep sleep
Expand Down Expand Up @@ -414,7 +414,7 @@ button:
then:
- logger.log: Button Sleep pressed
- lambda: |-
goto_page->execute(${PAGE_SCREENSAVER_ID});
goto_page->execute(get_page_id("screensaver"));

# Adds a button to wake-up the panel (similar to the existing action)
- name: Wake-up
Expand All @@ -425,7 +425,7 @@ button:
then:
- logger.log: Button Wake-up pressed
- lambda: |-
if (current_page_id == ${PAGE_SCREENSAVER_ID}) disp1->goto_page(wakeup_page_id);
if (current_page_id == get_page_id("screensaver")) disp1->goto_page(wakeup_page_id);
// timer_page->execute(); // enable this if you want page timeout to be reset
timer_sleep->execute();
timer_dim->execute();
Expand Down
24 changes: 12 additions & 12 deletions esphome/nspanel_esphome_addon_climate_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ climate:
ESP_LOGW("${TAG_ADDON_CLIMATE}", "Device not ready to work with the new state");
return;
}
if (current_page_id == ${PAGE_CLIMATE_ID} and detailed_entity->state == "embedded_climate") {
if (current_page_id == get_page_id("climate") and detailed_entity->state == "embedded_climate") {
ESP_LOGV("${TAG_ADDON_CLIMATE}", "Update page 'climate'");
page_climate->execute();
}
Expand Down Expand Up @@ -200,7 +200,7 @@ script:
- id: !extend page_climate
then:
- lambda: |-
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;
if (not id(is_embedded_thermostat)) return;
if (detailed_entity->state.empty()) return;
if (detailed_entity->state != "embedded_climate") return;
Expand All @@ -218,7 +218,7 @@ script:
// Feed watchdog
delay(${DELAY_SHORT});
App.feed_wdt();
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;

// Extract temperature values (static since they don't change during runtime)
ESP_LOGV("${TAG_ADDON_CLIMATE}", "Extracted temperature values:");
Expand All @@ -238,7 +238,7 @@ script:
// Feed watchdog
delay(${DELAY_SHORT});
App.feed_wdt();
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;

// Calculate static values
ESP_LOGV("${TAG_ADDON_CLIMATE}", "Calculated static values:");
Expand All @@ -251,7 +251,7 @@ script:
// Feed watchdog
delay(${DELAY_SHORT});
App.feed_wdt();
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;

// Get dynamic temperature values
ESP_LOGV("${TAG_ADDON_CLIMATE}", "Get dynamic temperature values:");
Expand All @@ -274,7 +274,7 @@ script:
ESP_LOGV("${TAG_ADDON_CLIMATE}", " temp_target_low: %f${temp_units}", temp_target_low);
ESP_LOGV("${TAG_ADDON_CLIMATE}", " temp_current: %f${temp_units}", temp_current);
feed_wdt_delay(${DELAY_SHORT});
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;

#ifdef NSPANEL_EASY_ADDON_CLIMATE_DUAL
ESP_LOGV("${TAG_ADDON_CLIMATE}", "Is add-on Climate dual: YES");
Expand Down Expand Up @@ -302,7 +302,7 @@ script:
set_climate_climate_icon = "";
set_climate_embedded_climate = true;
feed_wdt_delay(${DELAY_SHORT});
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;

// Execute set_climate
ESP_LOGV("${TAG_ADDON_CLIMATE}", "Call set_climate");
Expand Down Expand Up @@ -330,7 +330,7 @@ script:
(thermostat_embedded->mode==climate::CLIMATE_MODE_HEAT_COOL) ? Colors::WHITE : Colors::GRAY_DARK));
#endif // NSPANEL_EASY_ADDON_CLIMATE_DUAL
feed_wdt_delay(${DELAY_SHORT});
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;

#if defined(NSPANEL_EASY_ADDON_CLIMATE_HEAT) || defined(NSPANEL_EASY_ADDON_CLIMATE_DUAL)
disp1->show_component("button03"); // Heat
Expand All @@ -342,7 +342,7 @@ script:
(thermostat_embedded->mode==climate::CLIMATE_MODE_HEAT) ? Colors::DEEP_ORANGE : Colors::GRAY_DARK));
#endif // NSPANEL_EASY_ADDON_CLIMATE_HEAT || NSPANEL_EASY_ADDON_CLIMATE_DUAL
feed_wdt_delay(${DELAY_SHORT});
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;

#if defined(NSPANEL_EASY_ADDON_CLIMATE_COOL) || defined(NSPANEL_EASY_ADDON_CLIMATE_DUAL)
disp1->show_component("button04"); // Cool
Expand All @@ -354,17 +354,17 @@ script:
(thermostat_embedded->mode==climate::CLIMATE_MODE_COOL) ? Colors::BLUE : Colors::GRAY_DARK));
#endif // NSPANEL_EASY_ADDON_CLIMATE_COOL || NSPANEL_EASY_ADDON_CLIMATE_DUAL
feed_wdt_delay(${DELAY_SHORT});
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;

disp1->hide_component("button05");
disp1->set_component_font_color("climate.button05", static_cast<uint16_t>(Colors::GRAY_DARK));
feed_wdt_delay(${DELAY_SHORT});
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;

disp1->hide_component("button06");
disp1->set_component_font_color("climate.button06", static_cast<uint16_t>(Colors::GRAY_DARK));
feed_wdt_delay(${DELAY_SHORT});
if (current_page_id != ${PAGE_CLIMATE_ID}) return;
if (current_page_id != get_page_id("climate")) return;

disp1->show_component("button07"); // Off
disp1->set_component_font_color("climate.button07", static_cast<uint16_t>(
Expand Down
10 changes: 5 additions & 5 deletions esphome/nspanel_esphome_addon_display_light.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ light:
on_turn_on:
then:
- lambda: |-
if (current_page_id == ${PAGE_SCREENSAVER_ID}) disp1->goto_page(wakeup_page_id);
if (current_page_id == get_page_id("screensaver")) disp1->goto_page(wakeup_page_id);
timer_reset_all->execute();
on_turn_off:
then:
- lambda: |-
goto_page->execute(${PAGE_SCREENSAVER_ID});
goto_page->execute(get_page_id("screensaver"));

output:
# Output required by `display_light` to send the commands to Nextion
Expand All @@ -55,10 +55,10 @@ script:
then:
- lambda: |-
ESP_LOGV("${TAG_ADDON_DISPLAY_LIGHT}", "is_on(): %s", display_light->current_values.is_on() ? "True" : "False");
if (current_page_id == ${PAGE_SCREENSAVER_ID} and display_light->current_values.is_on()) {
if (current_page_id == get_page_id("screensaver") and display_light->current_values.is_on()) {
auto call = display_light->turn_off();
call.perform();
} else if (current_page_id != ${PAGE_SCREENSAVER_ID} and (not display_light->current_values.is_on())) {
} else if (current_page_id != get_page_id("screensaver") and (not display_light->current_values.is_on())) {
auto call = display_light->turn_on();
call.perform();
}
Expand All @@ -69,7 +69,7 @@ script:
- lambda: |-
uint8_t current_light_brightness = int(round(display_light->current_values.is_on() ? (display_light->current_values.get_brightness() * 100.0f) : 0.0));
if (brightness != current_light_brightness) {
if (current_page_id != ${PAGE_SCREENSAVER_ID} and brightness > 0) {
if (current_page_id != get_page_id("screensaver") and brightness > 0) {
auto call = display_light->turn_on();
call.set_brightness(brightness / 100.0f);
call.perform();
Expand Down
14 changes: 7 additions & 7 deletions esphome/nspanel_esphome_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,13 @@ script:
- lambda: |-
update_flag_api_ready->execute();
if (!system_flags.api_ready and
current_page_id != ${PAGE_BOOT_ID} and
current_page_id != ${PAGE_CONFIRM_ID} and
current_page_id != ${PAGE_HOME_ID} and
current_page_id != ${PAGE_QRCODE_ID} and
current_page_id != ${PAGE_SCREENSAVER_ID} and
current_page_id != ${PAGE_SETTINGS_ID}) {
current_page_id != get_page_id("boot") and
current_page_id != get_page_id("confirm") and
current_page_id != get_page_id("home") and
current_page_id != get_page_id("qrcode") and
current_page_id != get_page_id("screensaver") and
current_page_id != get_page_id("settings")) {
ESP_LOGW("${TAG_API}", "API disconnected. Falling back to Home page.");
goto_page->execute(${PAGE_HOME_ID});
goto_page->execute(get_page_id("home"));
}
...
25 changes: 4 additions & 21 deletions esphome/nspanel_esphome_page_alarm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ substitutions:
PAGE_ALARM_DELAY_LONG: ${DELAY_LONG}
PAGE_ALARM_DELAY_SHORT: ${DELAY_SHORT}

BOOT_STEP_PAGE_ALARM: 10
PAGE_ALARM_ID: 23
TAG_PAGE_ALARM: nspanel.page.alarm

api:
actions:
# Updates the alarm settings page with current state and configuration, integrating with the panel's interface.
- action: page_alarm
variables:
page_title: string # Title for the alarm settings page, displayed prominently at the top.
state: string # Current state of the alarm system (e.g., "armed_home", "disarmed").
supported_features: int # Bitmask representing the alarm system's supported features, determining available controls on the page.
code_format: string # Format required for the alarm code (numeric, alphanumeric).
Expand All @@ -31,7 +28,7 @@ api:
then:
# To do: This page constructor should be moved to Blueprint
- lambda: |-
if (current_page_id != ${PAGE_ALARM_ID}) return;
if (current_page_id != get_page_id("alarm")) return;

// Helper function to update alarm button state and visibility
// Handles feature checking, logging, and UI updates for all buttons including disarm
Expand Down Expand Up @@ -131,20 +128,6 @@ api:
10, ${LANG_BYTES_PER_CHAR}).c_str());
feed_wdt_delay(${PAGE_ALARM_DELAY_SHORT});

// Page header
ESP_LOGV("${TAG_PAGE_ALARM}", "Page header");
update_alarm_icon->execute("icon_state", state.c_str()); // Icon
// Page header - Title
std::string title = page_title.c_str();

// Replace the first occurrence of "\r" (two chars: backslash + r) with a space
auto pos = title.find("\\r");
if (pos != std::string::npos) {
title.replace(pos, 2, " ");
}

disp1->set_component_text("page_label", title.c_str());

ESP_LOGV("${TAG_PAGE_ALARM}", "Done!");

esphome:
Expand Down Expand Up @@ -177,9 +160,9 @@ script:

if (code_format == "number" && (key == "disarm" || code_arm_req == "1")) {
ESP_LOGV("${TAG_PAGE_ALARM}", "Open keypad");
goto_page->execute(${PAGE_KEYB_NUM_ID});
goto_page->execute(get_page_id("keyb_num"));

disp1->set_component_value("page_id", ${PAGE_ALARM_ID});
disp1->set_component_value("page_id", get_page_id("alarm"));
disp1->set_component_text("domain", "alarm");
disp1->set_component_text("key", key.c_str());
disp1->set_component_text("value", "click");
Expand Down Expand Up @@ -243,7 +226,7 @@ script:
- id: !extend page_change
then:
- lambda: |-
if (new_page_id == ${PAGE_ALARM_ID})
if (new_page_id == get_page_id("alarm"))
page_alarm->execute();

- id: !extend stop_all
Expand Down
Loading
Loading