implementes #539

This commit is contained in:
Johannes Braun
2022-12-25 15:36:48 +01:00
parent b9504a2ff0
commit 529b0516f4
3 changed files with 9 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
import colorsys
import math
import apis
def scale(val, src, dst):
"""
@@ -37,6 +38,8 @@ def rgb_brightness(rgb_color, brightness):
return [int(red), int(green), int(blue)]
def rgb_dec565(rgb_color):
if type(rgb_color) is str:
rgb_color = apis.ha_api.render_template(rgb_color)
red = rgb_color[0]
green = rgb_color[1]
blue = rgb_color[2]

View File

@@ -25,7 +25,7 @@ class LuiPagesGen(object):
def get_entity_color(self, entity, ha_type=None, overwrite=None):
if overwrite is not None:
if type(overwrite) is list:
if type(overwrite) in [str, list]:
return rgb_dec565(overwrite)
if type(overwrite) is dict:
state = entity.state

View File

@@ -45,6 +45,11 @@ It is also possible to configure different color overwrites per state:
"on": [255,0,0]
"off": [0,0,255]
```
Dynamic color overwrites using homeassistant templates:
```yaml
color: '{{iif(states("binary_sensor.test")=="on", "[0,255,0]", "[255,165,0]")}}'
```
It is also possible to use text instead of icons with `text:X`