Update alarm icon on home page

Refresh icon when alarm state changes.
This commit is contained in:
Edward Firmo
2023-08-22 20:02:58 +02:00
parent 2edfeef095
commit b83c513093
2 changed files with 22 additions and 18 deletions

View File

@@ -534,30 +534,34 @@ api:
entity: string
mui_alarm: string[] #std::vector<std::string> #std::map
then:
- lambda: if (${verbose_log}) ESP_LOGD("service.alarm_settings", "Starting");
- lambda: |-
// log
if (${verbose_log})
{
ESP_LOGD("service.alarm_settings", "Starting");
ESP_LOGD("service.alarm_settings", "page_title: %s", page_title.c_str());
ESP_LOGD("service.alarm_settings", "state: %s", state.c_str());
ESP_LOGD("service.alarm_settings", "supported_features: %i", supported_features);
ESP_LOGD("service.alarm_settings", "code_format: %s", code_format.c_str());
ESP_LOGD("service.alarm_settings", "code_arm_required: %i", (code_arm_required) ? 1 : 0);
ESP_LOGD("service.alarm_settings", "entity: %s", entity.c_str());
}
// set alarm icon on home page
if (${verbose_log}) ESP_LOGD("service.alarm_settings", "Updating home page icon");
id(home_alarm_state) = state;
id(update_alarm_icon)->execute("icon_state", state.c_str());
## Update alarm page
- if:
condition:
- binary_sensor.is_on: nextion_init
- text_sensor.state: # Is alarm page visible?
id: current_page
state: 'alarm'
then:
# Log
- lambda: |-
if (${verbose_log})
{
ESP_LOGD("service.alarm_settings", "page_title: %s", page_title.c_str());
ESP_LOGD("service.alarm_settings", "state: %s", state.c_str());
ESP_LOGD("service.alarm_settings", "supported_features: %i", supported_features);
ESP_LOGD("service.alarm_settings", "code_format: %s", code_format.c_str());
ESP_LOGD("service.alarm_settings", "code_arm_required: %i", (code_arm_required) ? 1 : 0);
ESP_LOGD("service.alarm_settings", "entity: %s", entity.c_str());
}
- lambda: |-
id(home_alarm_state) = state;
if (${verbose_log}) ESP_LOGD("service.alarm_settings", "Updating alarm page");
// Alarm page - Header
id(update_alarm_icon)->execute("icon_state", state.c_str());
id(disp1).set_component_text_printf("page_label", "%s", page_title.c_str());
id(disp1).set_component_text_printf("code_format", "%s", code_format.c_str());
if (code_arm_required) id(disp1).set_component_text_printf("code_arm_req", "1"); else id(disp1).set_component_text_printf("code_arm_req", "0");