From 641d103ba43758443e34b4b9a69e6ec5b5715420 Mon Sep 17 00:00:00 2001 From: Johannes Date: Sat, 23 Jul 2022 14:57:05 +0200 Subject: [PATCH 1/2] Implement #295 --- apps/nspanel-lovelace-ui/luibackend/pages.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index e62d7b4f..e01e6a53 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -24,7 +24,14 @@ class LuiPagesGen(object): def get_entity_color(self, entity, overwrite=None): if overwrite is not None: - return rgb_dec565(overwrite) + if type(overwrite) is list: + return rgb_dec565(overwrite) + if type(overwrite) is dict: + state = entity.state + for overwrite_state, overwrite_val in overwrite.items(): + if overwrite_state == state: + return rgb_dec565(overwrite_val) + attr = entity.attributes default_color_on = rgb_dec565([253, 216, 53]) default_color_off = rgb_dec565([68, 115, 158]) From 8dce75aa0837cdca412222cf177bc4127a35ee16 Mon Sep 17 00:00:00 2001 From: Johannes Date: Sat, 23 Jul 2022 14:58:45 +0200 Subject: [PATCH 2/2] Update entities.md --- docs/entities.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/entities.md b/docs/entities.md index e5d7b551..2476a62d 100644 --- a/docs/entities.md +++ b/docs/entities.md @@ -36,6 +36,14 @@ It is also possible to configure different icon overwrites per state: "off": mdi:lightbulb ``` +It is also possible to configure different color overwrites per state: + +```yaml + color: + "on": [255,0,0] + "off": [0,0,255] +``` + It is also possible to use text instead of icons with `text:X` ```yaml