From 83e3a6860d281aa9d4ce2160a986a34962ac4908 Mon Sep 17 00:00:00 2001 From: Sylvain Garcia Date: Mon, 22 Aug 2022 17:00:29 +0200 Subject: [PATCH 1/3] update doc assumed_state (#408) --- docs/entities.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/entities.md b/docs/entities.md index 2476a62d..4ed0aefa 100644 --- a/docs/entities.md +++ b/docs/entities.md @@ -15,6 +15,7 @@ key | optional | type | default | description `state` | True | string | `None` | Only displayed if Entity state is equal to this value `state_not` | True | string | `None` | Only displayed if Entity state is unequal to this value `status` | True | string | `None` | Only valid for navigate items, adds a entity to track state for the icon +`assumed_state` | True | string | `None` | Only for cover items, up, down and stop buttons are always shown ## Override Icons or Names From 7701f623b9ad48fa74d02ee36d2a4709bab2df0f Mon Sep 17 00:00:00 2001 From: WM Date: Wed, 24 Aug 2022 17:44:34 +0200 Subject: [PATCH 2/3] Possibility to overwrite in config `supported_features` of an Alarm Control Panel to resolve #352 Example: ``` cards: - type: cardAlarm title: Alarm Test 1 entity: alarm_control_panel.alarmo supportedFeatures: 14 ``` * add docs for suportedModes Co-authored-by: Johannes --- apps/nspanel-lovelace-ui/luibackend/pages.py | 26 +++++++++++--------- docs/card-alarm.md | 3 ++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index 875f9d80..dbfcd044 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -447,7 +447,7 @@ class LuiPagesGen(object): command = f"entityUpd~{heading}~{navigation}~{item}~{icon}~{title}~{author}~{volume}~{iconplaypause}~{source}~{speakerlist[:200]}~{onoffbutton}~{mediaBtn}" self._send_mqtt_msg(command) - def generate_alarm_page(self, navigation, entity, alarmBtn): + def generate_alarm_page(self, navigation, entity, overwrite_supported_modes, alarmBtn): item = entity.entityId if not self._ha_api.entity_exists(item): command = f"entityUpd~{item}~{navigation}~Not found~Not found~Check your~Check your~apps.~apps.~yaml~yaml~0~~0" @@ -462,15 +462,18 @@ class LuiPagesGen(object): icon = get_icon_id("shield-off") if not entity.attributes.get("code_arm_required", False): numpad = "disable" - bits = entity.attributes.supported_features - if bits & 0b000001: - supported_modes.append("arm_home") - if bits & 0b000010: - supported_modes.append("arm_away") - if bits & 0b000100: - supported_modes.append("arm_night") - if bits & 0b100000: - supported_modes.append("arm_vacation") + if overwrite_supported_modes is None: + bits = entity.attributes.supported_features + if bits & 0b000001: + supported_modes.append("arm_home") + if bits & 0b000010: + supported_modes.append("arm_away") + if bits & 0b000100: + supported_modes.append("arm_night") + if bits & 0b100000: + supported_modes.append("arm_vacation") + else: + supported_modes = overwrite_supported_modes else: supported_modes.append("disarm") @@ -556,7 +559,8 @@ class LuiPagesGen(object): self.generate_media_page(navigation, card.title, card.entity, mediaBtn) if card.cardType == "cardAlarm": alarmBtn = card.raw_config.get("alarmControl") - self.generate_alarm_page(navigation, card.entity, alarmBtn) + overwrite_supported_modes = card.raw_config.get("supportedModes") + self.generate_alarm_page(navigation, card.entity, overwrite_supported_modes, alarmBtn) if card.cardType == "screensaver": theme = card.raw_config.get("theme") self.update_screensaver_weather(theme) diff --git a/docs/card-alarm.md b/docs/card-alarm.md index a8a8b2b8..f18c1640 100644 --- a/docs/card-alarm.md +++ b/docs/card-alarm.md @@ -17,4 +17,5 @@ key | optional | type | default | description `title` | True | string | `None` | Title of the Page `entity` | False | string | `None` | contains the entity of the current card `key` | True | string | `None` | Used by navigate items -`alarmControl` | True | complex | `None` | overwrites the action executed on pressing the left bottom icon, by default this button is used to show a list of open sensors on a failed attempt to arm. \ No newline at end of file +`alarmControl` | True | complex | `None` | overwrites the action executed on pressing the left bottom icon, by default this button is used to show a list of open sensors on a failed attempt to arm. +`supportedModes` | True | list | `None` | Supply list of arm modes if you want to limit the modes on the card. Example `['arm_away', 'arm_night']` From 377caddf5585ec7097e07edbfd4833d99197d549 Mon Sep 17 00:00:00 2001 From: WM Date: Wed, 24 Aug 2022 18:51:52 +0200 Subject: [PATCH 3/3] Alarm Panel icon color with status entity (#411) --- apps/nspanel-lovelace-ui/luibackend/pages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index dbfcd044..437fcf36 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -192,7 +192,7 @@ class LuiPagesGen(object): if item.status is not None and self._ha_api.entity_exists(item.status): status_entity = self._ha_api.get_entity(item.status) icon_res = get_icon_id_ha(item.status.split(".")[0], state=status_entity.state, device_class=status_entity.attributes.get("device_class", "_"), overwrite=icon) - icon_color = self.get_entity_color(status_entity, overwrite=colorOverride) + icon_color = self.get_entity_color(status_entity, ha_type=item.status.split(".")[0], overwrite=colorOverride) if item.status.startswith("sensor") and cardType == "cardGrid": icon_res = status_entity.state[:4] if icon_res[-1] == ".":