From 10698fa666652b626a6b187614790edef6ec4096 Mon Sep 17 00:00:00 2001 From: Edward Firmo Date: Wed, 16 Aug 2023 22:38:11 +0200 Subject: [PATCH] Fix alarm without pin not working Solves https://github.com/Blackymas/NSPanel_HA_Blueprint/pull/930#issuecomment-1680981977 --- nspanel_blueprint.yaml | 2 +- nspanel_esphome.yaml | 34 ++++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 93c4009..1bd0c2f 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -7711,7 +7711,7 @@ action: page_title: '{{ alarm.friendly_name }}' state: '{{ alarm.state }}' supported_features: '{{ alarm.supported_features }}' - code_format: '{{ alarm.code_format }}' + code_format: '{{ alarm.code_format if alarm.code_format else "none" }}' entity: '{{ alarm_entity }}' mui_alarm: '{{ dict.values(mui[language].alarm) | list }}' continue_on_error: true diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index 28e9dfd..de70b4c 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -513,6 +513,7 @@ api: entity: string mui_alarm: string[] #std::vector #std::map then: + - lambda: if (${verbose_log}) ESP_LOGD("service.alarm_settings", "Starting"); - if: condition: - binary_sensor.is_on: nextion_init @@ -532,7 +533,8 @@ api: ESP_LOGD("service.alarm_settings", "entity: %s", entity.c_str()); } - - lambda: |- # Alarm page - Header + - lambda: |- + // Alarm page - Header if (page_icon == "" or page_icon.empty()) id(disp1).set_component_text_printf("icon_state", "%s", "\uE497"); //mdi:shield else @@ -541,7 +543,7 @@ api: id(disp1).set_component_text_printf("code_format", "%s", code_format.c_str()); id(disp1).set_component_text_printf("entity", "%s", entity.c_str()); - - lambda: |- # Alarm page - Button's icons + // Alarm page - Button's icons id(disp1).set_component_text_printf("bt_home_icon", "\uE689"); //mdi:shield-home id(disp1).set_component_text_printf("bt_away_icon", "\uE99C"); //mdi:shield-lock id(disp1).set_component_text_printf("bt_night_icon", "\uF827"); //mdi:shield-moon @@ -549,66 +551,70 @@ api: id(disp1).set_component_text_printf("bt_bypass_icon", "\uF19F"); //mdi:shield-edit id(disp1).set_component_text_printf("bt_disarm_icon", "\uE99D"); //mdi:shield-off - - lambda: |- # Alarm - Buttons + // Alarm page - Button's text + id(disp1).set_component_text_printf("bt_home_text", mui_alarm[0].c_str()); + id(disp1).set_component_text_printf("bt_away_text", mui_alarm[1].c_str()); + id(disp1).set_component_text_printf("bt_night_text", mui_alarm[2].c_str()); + id(disp1).set_component_text_printf("bt_vacat_text", mui_alarm[3].c_str()); + id(disp1).set_component_text_printf("bt_bypass_text", mui_alarm[4].c_str()); + id(disp1).set_component_text_printf("bt_disarm_text", mui_alarm[5].c_str()); + + // Alarm page - Buttons if (supported_features & 1) // Alarm - Button - Home { id(disp1).send_command_printf("bt_home_pic.pic=%i", (state=="armed_home") ? 133 : 132); - id(disp1).set_component_text_printf("bt_home_text", mui_alarm[0].c_str()); id(disp1).set_component_background_color("bt_home_text", (state=="armed_home") ? 19818 : 52857); id(disp1).set_component_background_color("bt_home_icon", (state=="armed_home") ? 19818 : 52857); id(disp1).set_component_font_color("bt_home_text", (state=="armed_home") ? 65535 : 0); id(disp1).set_component_font_color("bt_home_icon", (state=="armed_home") ? 65535 : 0); - id(disp1).show_component("bt_home"); + if (state=="armed_home") id(disp1).hide_component("bt_home"); else id(disp1).show_component("bt_home"); } if (supported_features & 2) // Alarm - Button - Away { id(disp1).send_command_printf("bt_away_pic.pic=%i", (state=="armed_away") ? 133 : 132); - id(disp1).set_component_text_printf("bt_away_text", mui_alarm[1].c_str()); id(disp1).set_component_background_color("bt_away_text", (state=="armed_away") ? 19818 : 52857); id(disp1).set_component_background_color("bt_away_icon", (state=="armed_away") ? 19818 : 52857); id(disp1).set_component_font_color("bt_away_text", (state=="armed_away") ? 65535 : 0); id(disp1).set_component_font_color("bt_away_icon", (state=="armed_away") ? 65535 : 0); - id(disp1).show_component("bt_away"); + if (state=="armed_away") id(disp1).hide_component("bt_away"); else id(disp1).show_component("bt_away"); } if (supported_features & 4) // Alarm - Button - Night { id(disp1).send_command_printf("bt_night_pic.pic=%i", (state=="armed_night") ? 133 : 132); - id(disp1).set_component_text_printf("bt_night_text", mui_alarm[2].c_str()); id(disp1).set_component_background_color("bt_night_text", (state=="armed_night") ? 19818 : 52857); id(disp1).set_component_background_color("bt_night_icon", (state=="armed_night") ? 19818 : 52857); id(disp1).set_component_font_color("bt_night_text", (state=="armed_night") ? 65535 : 0); id(disp1).set_component_font_color("bt_night_icon", (state=="armed_night") ? 65535 : 0); - id(disp1).show_component("bt_night"); + if (state=="armed_night") id(disp1).hide_component("bt_night"); else id(disp1).show_component("bt_night"); } if (supported_features & 32) // Alarm - Button - Vacation { id(disp1).send_command_printf("bt_vacat_pic.pic=%i", (state=="armed_vacation") ? 133 : 132); - id(disp1).set_component_text_printf("bt_vacat_text", mui_alarm[3].c_str()); id(disp1).set_component_background_color("bt_vacat_text", (state=="armed_vacation") ? 19818 : 52857); id(disp1).set_component_background_color("bt_vacat_icon", (state=="armed_vacation") ? 19818 : 52857); id(disp1).set_component_font_color("bt_vacat_text", (state=="armed_vacation") ? 65535 : 0); id(disp1).set_component_font_color("bt_vacat_icon", (state=="armed_vacation") ? 65535 : 0); - id(disp1).show_component("bt_vacat"); + if (state=="armed_vacation") id(disp1).hide_component("bt_vacat"); else id(disp1).show_component("bt_vacat"); } if (supported_features & 16) // Alarm - Button - Custom bypass { id(disp1).send_command_printf("bt_bypass_pic.pic=%i", (state=="armed_bypass") ? 133 : 132); - id(disp1).set_component_text_printf("bt_bypass_text", mui_alarm[4].c_str()); id(disp1).set_component_background_color("bt_bypass_text", (state=="armed_bypass") ? 19818 : 52857); id(disp1).set_component_background_color("bt_bypass_icon", (state=="armed_bypass") ? 19818 : 52857); id(disp1).set_component_font_color("bt_bypass_text", (state=="armed_bypass") ? 65535 : 0); id(disp1).set_component_font_color("bt_bypass_icon", (state=="armed_bypass") ? 65535 : 0); - id(disp1).show_component("bt_bypass"); + if (state=="armed_bypass") id(disp1).hide_component("bt_bypass"); else id(disp1).show_component("bt_bypass"); } if ( true ) // Alarm - Button - Disarm { id(disp1).send_command_printf("bt_disarm_pic.pic=%i", (state=="disarmed") ? 133 : 132); - id(disp1).set_component_text_printf("bt_disarm_text", mui_alarm[5].c_str()); id(disp1).set_component_background_color("bt_disarm_text", (state=="disarmed") ? 19818 : 52857); id(disp1).set_component_background_color("bt_disarm_icon", (state=="disarmed") ? 19818 : 52857); id(disp1).set_component_font_color("bt_disarm_text", (state=="disarmed") ? 65535 : 0); id(disp1).set_component_font_color("bt_disarm_icon", (state=="disarmed") ? 65535 : 0); + if (state=="disarmed") id(disp1).hide_component("bt_disarm"); else id(disp1).show_component("bt_disarm"); } + - lambda: if (${verbose_log}) ESP_LOGD("service.alarm_settings", "Finished"); ##### START - GLOBALS CONFIGURATION ##### globals: