diff --git a/docs/en/alarm.md b/docs/en/alarm.md index 08e40d7..08d7d9d 100644 --- a/docs/en/alarm.md +++ b/docs/en/alarm.md @@ -32,4 +32,20 @@ When an alarm control panel is set in your Blueprint automation, you will see th A click on that icon will show the Alarm Control Panel page:
<<< ADD SCREENSHOT >>>> -You can change your alarm settings with a single click on the button related to the new state you want to set your alarm to, or close the page to go back to Home page. \ No newline at end of file +You can change your alarm settings with a single click on the button related to the new state you want to set your alarm to, or close the page to go back to Home page. + +### Description of states shown with the alarm icon + +State | Color | Icon | Icon name | Description +-- | -- | -- | -- | -- +disarmed | White |![shield-off-outline](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/5b1c8219-3958-4096-9100-0b4ef47e7dac)|mdi:shield-off-outline | The alarm is disarmed (off). +armed_home | Green |![shield-home-outline](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/1ed9347b-139a-4729-a795-b08934b56581)| mdi:shield-home-outline | The alarm is armed in home mode. +armed_away | Green |![shield-lock-outline](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/998db33c-3ec5-47dd-9686-c28eee81e9eb)| mdi:shield-lock-outline | The alarm is armed in away mode. +armed_night | Green |![shield-moon-outline](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/84528bca-577d-4a43-8366-e6f9e41bc7b4)| mdi:shield-moon-outline | The alarm is armed in night mode. +armed_vacation | Green |![shield-airplane-outline](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/067218de-ec8c-4fce-a427-7848a7ae9f27)| mdi:shield-airplane-outline | The alarm is armed in vacation mode. +armed_custom_bypass | Green |![shield-half-full](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/af7ed346-28eb-4796-b62b-2a51e9cb6272)| mdi:shield-half-full | The alarm is armed in bypass mode. +pending | Amber |![shield-outline](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/31bcd613-04d6-455a-a443-3299211d487e)| mdi:shield-outline | The alarm is pending (towards triggered). +arming | Amber |![shield-outline](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/31bcd613-04d6-455a-a443-3299211d487e)| mdi:shield-outline | The alarm is arming. +disarming | Amber |![shield-off-outline](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/37c02584-dd65-4575-8d95-c7346de599e4)| mdi:shield-off-outline | The alarm is disarming. +triggered | Red |![shield-alert-outline](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/ee1ec55b-e671-4aa0-9baa-77eb2a8c8c7f)| mdi:shield-alert-outline | The alarm is triggered. +unknown / unavailable | White |![shield-alert-outline](https://github.com/Blackymas/NSPanel_HA_Blueprint/assets/94725493/a382e5ab-2e16-453c-bc9b-b3dcd3825de7)| mdi:shield-alert-outline | The alarm state is unknown or unavailable diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 123a286..5262edf 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -7657,20 +7657,9 @@ action: friendly_name: '{{ state_attr(alarm_entity, "friendly_name") }}' supported_features: '{{ state_attr(alarm_entity, "supported_features") | int(0) }}' code_format: '{{ state_attr(alarm_entity, "code_format") }}' - icon: > - {% set icon_attr = state_attr(alarm_entity, "icon") | default("") %} - {{ - all_icons[icon_attr.split(":")[1]] | default(all_icons.shield) - if - icon_attr not in ["unavailable", "unknown", "", None] - and icon_attr is string - and icon_attr.split(":") | count > 0 - else all_icons.shield - }} - condition: '{{ alarm.supported_features > 0 }}' - service: '{{ nextion.command.alarm_settings }}' data: - page_icon: '{{ alarm.icon }}' page_title: '{{ alarm.friendly_name }}' state: '{{ alarm.state }}' supported_features: '{{ alarm.supported_features }}' diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index 147c89b..b7afd07 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -505,7 +505,7 @@ api: ## Alarm button - lambda: |- if (${verbose_log}) ESP_LOGD("service.global_settings", "Alarm button - Start"); - id(home_alarm) = (alarm_state != "" and not alarm_state.empty()); + id(home_alarm_state) = alarm_state; ## Wakeup page - lambda: |- @@ -527,7 +527,6 @@ api: #### Service to populate the alarm settings page ##### - service: alarm_settings variables: - page_icon: string page_title: string state: string supported_features: int @@ -547,7 +546,6 @@ api: - lambda: |- if (${verbose_log}) { - ESP_LOGD("service.alarm_settings", "page_icon: %s", page_icon.c_str()); 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); @@ -556,11 +554,9 @@ api: } - lambda: |- + id(home_alarm_state) = state; // Alarm page - Header - if (page_icon == "" or page_icon.empty()) - id(disp1).set_component_text_printf("icon_state", "%s", "\uE497"); //mdi:shield - else - id(disp1).set_component_text_printf("icon_state", "%s", page_icon.c_str()); + 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()); id(disp1).set_component_text_printf("entity", "%s", entity.c_str()); @@ -706,11 +702,11 @@ globals: restore_value: true initial_value: '0' - ##### Alarm is set ##### - - id: home_alarm - type: bool + ##### Alarm state ##### + - id: home_alarm_state + type: std::string restore_value: false - initial_value: 'false' + initial_value: '' ##### Entities pages button ##### - id: home_entities_pages @@ -1576,9 +1572,9 @@ script: // Show alarm button if (${verbose_log}) ESP_LOGD("script.update_page_home", "Show alarm button"); - if (id(home_alarm)) + if (id(home_alarm_state) != "" and not id(home_alarm_state).empty()) { - id(disp1).set_component_text_printf("button07_icon", "\uECCB"); + id(update_alarm_icon)->execute("button07_icon", id(home_alarm_state)); id(disp1).show_component("button07"); id(disp1).show_component("button07_icon"); } @@ -1671,6 +1667,82 @@ script: }); } + - id: update_alarm_icon + mode: restart + parameters: + component: string + state: string + then: + - logger.log: "script.update_alarm_icon: Starting" + - lambda: |- + std::string alarm_icon = "\uEECC"; //mdi:shield-alert-outline + int alarm_color = 65535; + // Standard colors: + // blue: '1055' # rgb(0, 128, 248) + // grey_dark: '10597' # rgb(40, 44, 40) + // grey_light: '33808' # rgb(128, 128, 128) + // grey_super_light: '52857' # rgb(200, 204, 200) + // grey_white: '59164' # rgb(225, 225, 225) + // red: '63488' # rgb(248, 0, 0) + // white: '65535' # rgb(255, 255, 255) + // yellow: '65472' # rgb(248, 248, 0) + // #### Colors from HA Style: + // green: '19818' # rgb(76, 175, 80) + // orange: '64704' # rgb(255, 152, 0) + // cyan: '1530' # rgb(0, 188, 212) + // deep-orange: '64164' # rgb(255, 87, 34) + // amber: '65024' # rgb(255, 193, 7) + // "off": '35921' #8a8a8a + // disabled: '48631' # rgb(189, 189, 189) + if (state == "disarmed") + { + alarm_icon = "\uE99B"; //mdi:shield-off-outline + alarm_color = 65535; + } + else if (state == "armed_home") + { + alarm_icon = "\uECCA"; //mdi:shield-home-outline + alarm_color = 19818; + } + else if (state == "armed_away") + { + alarm_icon = "\uECCB"; //mdi:shield-lock-outline + alarm_color = 19818; + } + else if (state == "armed_night") + { + alarm_icon = "\uF828"; //mdi:shield-moon-outline + alarm_color = 19818; + } + else if (state == "armed_vacation") + { + alarm_icon = "\uECC6"; //mdi:shield-airplane-outline + alarm_color = 19818; + } + else if (state == "armed_custom_bypass") + { + alarm_icon = "\uE77F"; //mdi:shield-half-full + alarm_color = 19818; + } + else if (state == "pending" or state == "arming") + { + alarm_icon = "\uE498"; //mdi:shield-outline + alarm_color = 65024; + } + else if (state == "disarming") + { + alarm_icon = "\uE99B"; //mdi:shield-off-outline + alarm_color = 65024; + } + else if (state == "triggered") + { + alarm_icon = "\uEECC"; //mdi:shield-alert-outline + alarm_color = 63488; + } + id(disp1).set_component_text_printf(component.c_str(), alarm_icon.c_str()); + id(disp1).set_component_font_color(component.c_str(), alarm_color); + - logger.log: "script.update_alarm_icon: Finished" + ##### ADD-ONS ############################################################ ##### Add-on - Climate ##### - id: addon_climate_service_call