Move Entities button to ESPHome
Move logic behind Entities button (Home page) from Blueprint to ESPHome in order to gain performance on creating home page.
This commit is contained in:
@@ -446,23 +446,30 @@ api:
|
||||
embedded_climate: bool
|
||||
wakeup_page: int
|
||||
alarm_state: string
|
||||
entities_pages: bool
|
||||
entities_pages_icon: string
|
||||
entities_pages_icon_color: int
|
||||
then:
|
||||
## Logs
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("service.global_settings", "Starting");
|
||||
- lambda: |-
|
||||
if (${verbose_log})
|
||||
{
|
||||
ESP_LOGD("global_settings", "relay1_local_control: %i", (relay1_local_control) ? 1 : 0);
|
||||
ESP_LOGD("global_settings", "relay1_icon: %s", relay1_icon.c_str());
|
||||
ESP_LOGD("global_settings", "relay1_icon_color: %i", relay1_icon_color);
|
||||
ESP_LOGD("global_settings", "relay2_local_control: %i", (relay2_local_control) ? 1 : 0);
|
||||
ESP_LOGD("global_settings", "relay2_icon: %s", relay2_icon.c_str());
|
||||
ESP_LOGD("global_settings", "relay2_icon_color: %i", relay2_icon_color);
|
||||
ESP_LOGD("global_settings", "date_color: %i", date_color);
|
||||
ESP_LOGD("global_settings", "time_format: %s", time_format.c_str());
|
||||
ESP_LOGD("global_settings", "time_color: %i", time_color);
|
||||
ESP_LOGD("global_settings", "embedded_climate: %i", (embedded_climate) ? 1 : 0);
|
||||
ESP_LOGD("global_settings", "wakeup_page: %i", wakeup_page);
|
||||
ESP_LOGD("global_settings", "alarm_state: %s", alarm_state.c_str());
|
||||
ESP_LOGD("service.global_settings", "relay1_local_control: %i", (relay1_local_control) ? 1 : 0);
|
||||
ESP_LOGD("service.global_settings", "relay1_icon: %s", relay1_icon.c_str());
|
||||
ESP_LOGD("service.global_settings", "relay1_icon_color: %i", relay1_icon_color);
|
||||
ESP_LOGD("service.global_settings", "relay2_local_control: %i", (relay2_local_control) ? 1 : 0);
|
||||
ESP_LOGD("service.global_settings", "relay2_icon: %s", relay2_icon.c_str());
|
||||
ESP_LOGD("service.global_settings", "relay2_icon_color: %i", relay2_icon_color);
|
||||
ESP_LOGD("service.global_settings", "date_color: %i", date_color);
|
||||
ESP_LOGD("service.global_settings", "time_format: %s", time_format.c_str());
|
||||
ESP_LOGD("service.global_settings", "time_color: %i", time_color);
|
||||
ESP_LOGD("service.global_settings", "embedded_climate: %i", (embedded_climate) ? 1 : 0);
|
||||
ESP_LOGD("service.global_settings", "wakeup_page: %i", wakeup_page);
|
||||
ESP_LOGD("service.global_settings", "alarm_state: %s", alarm_state.c_str());
|
||||
ESP_LOGD("service.global_settings", "entities_pages: %i", (entities_pages) ? 1 : 0);
|
||||
ESP_LOGD("service.global_settings", "entities_pages_icon: %s", entities_pages_icon.c_str());
|
||||
ESP_LOGD("service.global_settings", "entities_pages_icon_color: %i", entities_pages_icon_color);
|
||||
}
|
||||
|
||||
## Relays
|
||||
@@ -488,20 +495,35 @@ api:
|
||||
embedded_climate: !lambda return embedded_climate;
|
||||
#- lambda: id(is_embedded_thermostat) = embedded_climate;
|
||||
|
||||
## Entities pages button
|
||||
- lambda: |-
|
||||
if (${verbose_log}) ESP_LOGD("service.global_settings", "Entities pages button - Start");
|
||||
id(home_entities_pages) = (entities_pages);
|
||||
id(home_entities_pages_icon) = entities_pages_icon.c_str();
|
||||
id(home_entities_pages_icon_color) = entities_pages_icon_color;
|
||||
|
||||
## Alarm button
|
||||
- lambda: id(home_alarm) = (alarm_state != "" and not alarm_state.empty());
|
||||
- lambda: |-
|
||||
if (${verbose_log}) ESP_LOGD("service.global_settings", "Alarm button - Start");
|
||||
id(home_alarm) = (alarm_state != "" and not alarm_state.empty());
|
||||
|
||||
## Wakeup page
|
||||
- lambda: id(wakeup_page_id) = wakeup_page;
|
||||
- lambda: |-
|
||||
if (${verbose_log}) ESP_LOGD("service.global_settings", "Wakeup page - Start");
|
||||
id(wakeup_page_id) = wakeup_page;
|
||||
|
||||
## Refresh colors of global components
|
||||
- script.execute:
|
||||
id: refresh_colors
|
||||
#- lambda: if (${verbose_log}) ESP_LOGD("service.global_settings", "Refresh colors of global components");
|
||||
#- script.execute:
|
||||
# id: refresh_colors
|
||||
|
||||
## Update home page
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("service.global_settings", "Update home page");
|
||||
- script.execute:
|
||||
id: update_page_home
|
||||
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("service.global_settings", "Finished");
|
||||
|
||||
#### Service to populate the alarm settings page #####
|
||||
- service: alarm_settings
|
||||
variables:
|
||||
@@ -690,6 +712,20 @@ globals:
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
|
||||
##### Entities pages button #####
|
||||
- id: home_entities_pages
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
- id: home_entities_pages_icon
|
||||
type: std::string
|
||||
restore_value: false
|
||||
initial_value: ''
|
||||
- id: home_entities_pages_icon_color
|
||||
type: int
|
||||
restore_value: false
|
||||
initial_value: '52857'
|
||||
|
||||
##### START - BINARY SENSOR CONFIGURATION #####
|
||||
binary_sensor:
|
||||
|
||||
@@ -1296,8 +1332,8 @@ display:
|
||||
- binary_sensor.template.publish:
|
||||
id: nextion_init
|
||||
state: true
|
||||
- script.execute:
|
||||
id: refresh_colors
|
||||
#- script.execute:
|
||||
# id: refresh_colors
|
||||
- lambda: id(home_relay1_icon) = "\uE3A5";
|
||||
- lambda: id(home_relay1_icon) = "\uE3A8";
|
||||
- logger.log: "Nextion start - Done!"
|
||||
@@ -1399,10 +1435,13 @@ script:
|
||||
id(disp1).set_component_font_color("home.time", id(home_time_color));
|
||||
id(disp1).set_component_font_color("home.icon_top_01", id(home_relay1_icon_color));
|
||||
id(disp1).set_component_font_color("home.icon_top_02", id(home_relay2_icon_color));
|
||||
id(disp1).set_component_font_color("home.button06_icon", id(home_entities_pages_icon_color));
|
||||
|
||||
|
||||
- id: refresh_datetime
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_datetime", "Starting");
|
||||
- if:
|
||||
condition:
|
||||
- binary_sensor.is_on: nextion_init
|
||||
@@ -1436,10 +1475,12 @@ script:
|
||||
}
|
||||
std::string time_text = id(time_provider).now().strftime(time_format_str);
|
||||
id(disp1).set_component_text_printf("home.time", "%s", time_text.c_str());
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_datetime", "Finished");
|
||||
|
||||
- id: refresh_relays
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_relays", "Starting");
|
||||
- if:
|
||||
condition:
|
||||
- binary_sensor.is_on: nextion_init
|
||||
@@ -1450,16 +1491,18 @@ script:
|
||||
- lambda: |-
|
||||
// Chips - Relays
|
||||
if (id(relay_1).state) id(disp1).set_component_text_printf("home.icon_top_01", "%s", id(home_relay1_icon).c_str());
|
||||
else id(disp1).set_component_text_printf("home.icon_top_01", "\uFFFF");
|
||||
else id(disp1).set_component_text_printf("icon_top_01", "\uFFFF");
|
||||
if (id(relay_2).state) id(disp1).set_component_text_printf("home.icon_top_02", "%s", id(home_relay2_icon).c_str());
|
||||
else id(disp1).set_component_text_printf("home.icon_top_02", "\uFFFF");
|
||||
// Hardware buttons - Fallback mode
|
||||
if (id(relay_1).state and (id(relay1_local).state or (id(relay1_fallback).state and not id(api_status).state))) id(disp1).send_command_printf("home.left_bt_pic.pic=%i", (id(relay_1).state) ? 78 : 77);
|
||||
if (id(relay_2).state and (id(relay2_local).state or (id(relay2_fallback).state and not id(api_status).state))) id(disp1).send_command_printf("home.right_bt_pic.pic=%i", (id(relay_2).state) ? 78 : 77);
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_relays", "Finished");
|
||||
|
||||
- id: refresh_wifi_icon
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_wifi_icon", "Starting");
|
||||
- if:
|
||||
condition:
|
||||
- binary_sensor.is_on: nextion_init
|
||||
@@ -1487,16 +1530,12 @@ script:
|
||||
- lambda: id(disp1).send_command_printf("api=0");
|
||||
- lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uE5A9");
|
||||
- lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488);
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_wifi_icon", "Finished");
|
||||
|
||||
- id: update_page_home
|
||||
mode: restart
|
||||
then:
|
||||
- script.execute:
|
||||
id: refresh_datetime
|
||||
- script.execute:
|
||||
id: refresh_relays
|
||||
- script.execute:
|
||||
id: refresh_wifi_icon
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.update_page_home", "Starting");
|
||||
- if:
|
||||
condition:
|
||||
- binary_sensor.is_on: nextion_init
|
||||
@@ -1505,9 +1544,30 @@ script:
|
||||
state: 'home'
|
||||
then:
|
||||
- script.execute:
|
||||
id: addon_climate_update_page_home
|
||||
id: refresh_datetime
|
||||
- script.execute:
|
||||
id: refresh_relays
|
||||
- script.execute:
|
||||
id: refresh_wifi_icon
|
||||
|
||||
- lambda: |-
|
||||
// Show Entities pages button
|
||||
if (${verbose_log}) ESP_LOGD("script.update_page_home", "Show Entities pages button");
|
||||
if (id(home_entities_pages))
|
||||
{
|
||||
if (id(home_entities_pages_icon) == "" or id(home_entities_pages_icon).empty()) id(home_entities_pages_icon) = "\uEDCF";
|
||||
id(disp1).set_component_text_printf("button06_icon", id(home_entities_pages_icon).c_str());
|
||||
id(disp1).show_component("button06");
|
||||
id(disp1).show_component("button06_icon");
|
||||
}
|
||||
else
|
||||
{
|
||||
id(disp1).hide_component("button06");
|
||||
id(disp1).hide_component("button06_icon");
|
||||
}
|
||||
|
||||
// Show alarm button
|
||||
if (${verbose_log}) ESP_LOGD("script.update_page_home", "Show alarm button");
|
||||
if (id(home_alarm))
|
||||
{
|
||||
id(disp1).set_component_text_printf("button07_icon", "\uECCB");
|
||||
@@ -1519,6 +1579,9 @@ script:
|
||||
id(disp1).hide_component("button07");
|
||||
id(disp1).hide_component("button07_icon");
|
||||
}
|
||||
- script.execute:
|
||||
id: addon_climate_update_page_home
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.update_page_home", "Finished");
|
||||
|
||||
- id: service_call_alarm_control_panel
|
||||
mode: restart
|
||||
@@ -1609,23 +1672,33 @@ script:
|
||||
value: string
|
||||
then:
|
||||
# Reserved for Add-on Climate
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_service_call", "Starting");
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_service_call", "Finished");
|
||||
- id: addon_climate_update_page_home
|
||||
mode: restart
|
||||
then:
|
||||
# Reserved for Add-on Climate
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_update_page_home", "Starting");
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_update_page_home", "Finished");
|
||||
- id: addon_climate_set_climate
|
||||
mode: restart
|
||||
parameters:
|
||||
embedded_climate: bool
|
||||
then:
|
||||
# Reserved for Add-on Climate
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_set_climate", "Starting");
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_set_climate", "Finished");
|
||||
- id: addon_climate_global_settings
|
||||
mode: restart
|
||||
parameters:
|
||||
embedded_climate: bool
|
||||
then:
|
||||
# Reserved for Add-on Climate
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_global_settings", "Starting");
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_global_settings", "Finished");
|
||||
- id: addon_climate_update_page_climate
|
||||
mode: restart
|
||||
then:
|
||||
# Reserved for Add-on Climate
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_update_page_climate", "Starting");
|
||||
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_update_page_climate", "Finished");
|
||||
|
||||
Reference in New Issue
Block a user