diff --git a/apps/nspanel-lovelace-ui/luibackend/config.py b/apps/nspanel-lovelace-ui/luibackend/config.py index d6d7cf0d..546bc3e7 100644 --- a/apps/nspanel-lovelace-ui/luibackend/config.py +++ b/apps/nspanel-lovelace-ui/luibackend/config.py @@ -8,6 +8,7 @@ class Entity(object): self.nameOverride = entity_input_config.get("name") self.iconOverride = entity_input_config.get("icon") self.colorOverride = entity_input_config.get("color") + self.status = entity_input_config.get("status") self.condState = entity_input_config.get("state") self.condStateNot = entity_input_config.get("state_not") @@ -33,11 +34,16 @@ class Card(object): entityIds = [] if self.entity is not None: entityIds.append(self.entity.entityId) + if self.entity.status is not None: + entityIds.append(self.entity.status) else: for e in self.entities: entityIds.append(e.entityId) + if e.status is not None: + entityIds.append(e.status) + # additional keys to check - add_ent_keys = ['weatherOverrideForecast1', 'weatherOverrideForecast2', 'weatherOverrideForecast3', 'weatherOverrideForecast4', 'statusIcon1', 'statusIcon2'] + add_ent_keys = ['weatherOverrideForecast1', 'weatherOverrideForecast2', 'weatherOverrideForecast3', 'weatherOverrideForecast4', 'statusIcon1', 'statusIcon2', 'alarmControl'] for ent_key in add_ent_keys: val = self.raw_config.get(ent_key) if val is not None: diff --git a/apps/nspanel-lovelace-ui/luibackend/icons.py b/apps/nspanel-lovelace-ui/luibackend/icons.py index c81cc58a..d0042417 100644 --- a/apps/nspanel-lovelace-ui/luibackend/icons.py +++ b/apps/nspanel-lovelace-ui/luibackend/icons.py @@ -109,6 +109,8 @@ def map_to_mdi_name(ha_type, state=None, device_class=None, cardType=None): return sensor_mapping_off[device_class] if device_class in sensor_mapping_off else "alert-circle-outline" else: return sensor_mapping[device_class] if device_class in sensor_mapping else "alert-circle-outline" + elif ha_type == "alarm-arm-fail": + return "progress-alert" else: return "alert-circle-outline" diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index 84daaad5..24689ee7 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -163,7 +163,11 @@ class LuiPagesGen(object): name = name if name is not None else page_search_res.title text = get_translation(self._locale, "frontend.ui.card.button.press") icon_id = get_icon_id(icon) if icon is not None else get_icon_id("gesture-tap-button") - return f"~button~{entityId}~{icon_id}~17299~{name}~{text}" + if item.status is not None and self._ha_api.entity_exists(item.status): + icon_color = self.get_entity_color(self._ha_api.get_entity(item.status)) + else: + icon_color = 17299 + return f"~button~{entityId}~{icon_id}~{icon_color}~{name}~{text}" else: return f"~text~{entityId}~{get_icon_id('alert-circle-outline')}~17299~page not found~" if entityType == "iText": @@ -427,9 +431,14 @@ class LuiPagesGen(object): if "open_sensors" in entity.attributes and entity.attributes.open_sensors is not None: add_btn=f"{get_icon_id('progress-alert')}~{rgb_dec565([243,179,0])}~opnSensorNotify" if alarmBtn is not None and type(alarmBtn) is dict: - entity = alarmBtn.get("entity") - iconnav = alarmBtn.get("icon", "progress-alert") - add_btn=f"{get_icon_id(iconnav)}~{rgb_dec565([243,179,0])}~{entity}" + entity = alarmBtn.get("entity") + iconnav = get_icon_id_ha("alarm-arm-fail", overwrite=alarmBtn.get("icon")) + status = alarmBtn.get("status") + if status is not None and self._ha_api.entity_exists(status): + icon_color = self.get_entity_color(self._ha_api.get_entity(status)) + else: + icon_color = rgb_dec565([243,179,0]) + add_btn=f"{iconnav}~{icon_color}~{entity}" # add padding to arm buttons arm_buttons = ""