diff --git a/README.md b/README.md index f96011b5..0a34715f 100644 --- a/README.md +++ b/README.md @@ -443,12 +443,42 @@ key | optional | type | default | description key | optional | type | default | description -- | -- | -- | -- | -- `type` | False | string | `None` | Used by navigate items -`entities` | False | complex | `None` | contains entities of the card, applys only to cardEntities and cardGrid +`entities` | False | complex | `None` | contains entities of the card, only valid on cardEntities and cardGrid and cardQR `title` | True | string | `None` | Title of the Page `entity` | False | string | `None` | contains the entity of the current card, valid for cardThermo, cardAlarm and cardMedia `key` | True | string | `None` | Used by navigate items `mediaControl` | True | string | `None` | Only valid on cardMedia, contains the action executed on pressing the top left media icon. (useful to navigate to a hidden card or start a script) +#### Possible configuration values for entities key + +key | optional | type | default | description +-- | -- | -- | -- | -- +`name` | True | string | `None` | Used to override names +`icon` | True | string | `None` | Used to override icons +`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 + +##### Override Icons or Names + +To overwrite Icons or Names of entities you can configure an icon and/or name in your configuration, please see the following example. +Only the icons listed in the [Icon Cheatsheet](https://htmlpreview.github.io/?https://github.com/joBr99/nspanel-lovelace-ui/blob/main/HMI/icon-cheatsheet.html) are useable. + +```yaml + entities: + - entity: light.test_item + name: NameOverride + icon: mdi:lightbulb +``` + +It is also possible to configure different icon overwrites per state: + +```yaml + icon: + "on": mdi:lightbulb + "off": mdi:lightbulb + +``` + #### Possible configuration values for screensaver config @@ -556,26 +586,6 @@ The following example configuration does nothing during the day but at night, if brightness: 20 ``` -#### Override Icons or Names - -To overwrite Icons or Names of entities you can configure an icon and/or name in your configuration, please see the following example. -Only the icons listed in the [Icon Cheatsheet](https://htmlpreview.github.io/?https://github.com/joBr99/nspanel-lovelace-ui/blob/main/HMI/icon-cheatsheet.html) are useable. - -```yaml - entities: - - entity: light.test_item - name: NameOverride - icon: mdi:lightbulb -``` - -It is also possible to configure different icon overwrites per state: - -```yaml - icon: - "on": mdi:lightbulb - "off": mdi:lightbulb - -``` Also it is possible to configure a text or a character by using "text:" as a prefix instead of an icon. `icon: text:X` diff --git a/apps/nspanel-lovelace-ui/luibackend/config.py b/apps/nspanel-lovelace-ui/luibackend/config.py index 644ce87c..d6d7cf0d 100644 --- a/apps/nspanel-lovelace-ui/luibackend/config.py +++ b/apps/nspanel-lovelace-ui/luibackend/config.py @@ -3,12 +3,13 @@ class Entity(object): if type(entity_input_config) is not dict: #self._ha_api.log("Config error, not a dict check your entity configs") self.entityId = "error" - self.nameOverride = None - self.iconOverride = None else: - self.entityId = entity_input_config.get("entity", "unknown") - self.nameOverride = entity_input_config.get("name") - self.iconOverride = entity_input_config.get("icon") + self.entityId = entity_input_config.get("entity", "unknown") + self.nameOverride = entity_input_config.get("name") + self.iconOverride = entity_input_config.get("icon") + self.colorOverride = entity_input_config.get("color") + self.condState = entity_input_config.get("state") + self.condStateNot = entity_input_config.get("state_not") class Card(object): def __init__(self, card_input_config, pos=None): diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index 39f253eb..fe011a25 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -146,10 +146,10 @@ class LuiPagesGen(object): state = None self._send_mqtt_msg(get_screensaver_color_output(theme=theme, state=state)) - def generate_entities_item(self, entity, cardType): - entityId = entity.entityId - icon = entity.iconOverride - name = entity.nameOverride + def generate_entities_item(self, item, cardType): + entityId = item.entityId + icon = item.iconOverride + name = item.nameOverride # type of the item is the string before the "." in the entityId entityType = entityId.split(".")[0] @@ -176,6 +176,12 @@ class LuiPagesGen(object): # HA Entities entity = self._ha_api.get_entity(entityId) + # check state for if a condition is defined + if item.condState is not None and item.condState == entity.state: + return "" + if item.condStateNot is not None and item.condState != entity.state: + return "" + name = name if name is not None else entity.attributes.friendly_name if entityType == "cover":