From 18c6cfd7b151ab59a038952ab6a41c74ecfb10fa Mon Sep 17 00:00:00 2001 From: Johannes Braun Date: Fri, 30 Dec 2022 13:59:57 +0100 Subject: [PATCH] implements #652 --- apps/nspanel-lovelace-ui/luibackend/config.py | 1 + apps/nspanel-lovelace-ui/luibackend/pages.py | 2 ++ docs/entities.md | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/apps/nspanel-lovelace-ui/luibackend/config.py b/apps/nspanel-lovelace-ui/luibackend/config.py index 12db0acf..3f2f1ff0 100644 --- a/apps/nspanel-lovelace-ui/luibackend/config.py +++ b/apps/nspanel-lovelace-ui/luibackend/config.py @@ -17,6 +17,7 @@ class Entity(object): self.status = entity_input_config.get("status") self.condState = entity_input_config.get("state") self.condStateNot = entity_input_config.get("state_not") + self.condTemplate = entity_input_config.get("state_template") self.assumedState = entity_input_config.get("assumed_state", False) self.data = entity_input_config.get("data", {}) self.entity_input_config = entity_input_config diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index bba32787..04153265 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -229,6 +229,8 @@ class LuiPagesGen(object): return "" if item.condStateNot is not None and item.condStateNot == state: return "" + if item.condTemplate is not None and apis.ha_api.render_template(item.condTemplate): + return "" # Internal types if entityType == "delete": diff --git a/docs/entities.md b/docs/entities.md index 2e6519be..be4a8eb4 100644 --- a/docs/entities.md +++ b/docs/entities.md @@ -88,6 +88,15 @@ This sensor will only be shown on the card if it's state is not equal to `on` state_not: "on" ``` +## Hide item based on HA Template + +The template must evaluate to `true` for the entity to hide. + +```yaml + - entity: binary_sensor.sensor_kueche_contact + state_template: '{{ state_attr("sun.sun","azimuth") < 200 }}' +``` + ## Calling service directly as button The following example shows how to call services directly, this enables you to call services on entities not (yet) supported by the backend and also to pass data to services.