mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-21 06:54:24 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
529b0516f4 | ||
|
|
b9504a2ff0 |
@@ -1,5 +1,6 @@
|
|||||||
import colorsys
|
import colorsys
|
||||||
import math
|
import math
|
||||||
|
import apis
|
||||||
|
|
||||||
def scale(val, src, dst):
|
def scale(val, src, dst):
|
||||||
"""
|
"""
|
||||||
@@ -37,6 +38,8 @@ def rgb_brightness(rgb_color, brightness):
|
|||||||
return [int(red), int(green), int(blue)]
|
return [int(red), int(green), int(blue)]
|
||||||
|
|
||||||
def rgb_dec565(rgb_color):
|
def rgb_dec565(rgb_color):
|
||||||
|
if type(rgb_color) is str:
|
||||||
|
rgb_color = apis.ha_api.render_template(rgb_color)
|
||||||
red = rgb_color[0]
|
red = rgb_color[0]
|
||||||
green = rgb_color[1]
|
green = rgb_color[1]
|
||||||
blue = rgb_color[2]
|
blue = rgb_color[2]
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class LuiPagesGen(object):
|
|||||||
|
|
||||||
def get_entity_color(self, entity, ha_type=None, overwrite=None):
|
def get_entity_color(self, entity, ha_type=None, overwrite=None):
|
||||||
if overwrite is not None:
|
if overwrite is not None:
|
||||||
if type(overwrite) is list:
|
if type(overwrite) in [str, list]:
|
||||||
return rgb_dec565(overwrite)
|
return rgb_dec565(overwrite)
|
||||||
if type(overwrite) is dict:
|
if type(overwrite) is dict:
|
||||||
state = entity.state
|
state = entity.state
|
||||||
@@ -455,16 +455,16 @@ class LuiPagesGen(object):
|
|||||||
|
|
||||||
icon_res = "".join(icon_res_list)
|
icon_res = "".join(icon_res_list)
|
||||||
|
|
||||||
if len(icon_res_list) == 1:
|
if len(icon_res_list) == 1 and not self._config.get("model") == "us-p":
|
||||||
icon_res = "~"*4 + icon_res_list[0] + "~"*4*6
|
icon_res = "~"*4 + icon_res_list[0] + "~"*4*6
|
||||||
elif len(icon_res_list) == 2:
|
elif len(icon_res_list) == 2 and not self._config.get("model") == "us-p":
|
||||||
icon_res = "~"*4*2 + icon_res_list[0] + "~"*4*2 + icon_res_list[1] + "~"*4*2
|
icon_res = "~"*4*2 + icon_res_list[0] + "~"*4*2 + icon_res_list[1] + "~"*4*2
|
||||||
elif len(icon_res_list) == 3:
|
elif len(icon_res_list) == 3 and not self._config.get("model") == "us-p":
|
||||||
icon_res = "~"*4*2 + icon_res_list[0] + "~"*4 + icon_res_list[1] + "~"*4 + icon_res_list[2] + "~"*4
|
icon_res = "~"*4*2 + icon_res_list[0] + "~"*4 + icon_res_list[1] + "~"*4 + icon_res_list[2] + "~"*4
|
||||||
elif len(icon_res_list) == 4:
|
elif len(icon_res_list) == 4 and not self._config.get("model") == "us-p":
|
||||||
icon_res = "~"*4 + icon_res_list[0] + "~"*4 + icon_res_list[1] + "~"*4 + icon_res_list[2] + "~"*4 + icon_res_list[3]
|
icon_res = "~"*4 + icon_res_list[0] + "~"*4 + icon_res_list[1] + "~"*4 + icon_res_list[2] + "~"*4 + icon_res_list[3]
|
||||||
elif len(icon_res_list) >= 5:
|
elif len(icon_res_list) >= 5 or self._config.get("model") == "us-p":
|
||||||
icon_res = "~"*4 + "".join(icon_res_list) + "~"*4*(7-len(icon_res_list))
|
icon_res = "".join(icon_res_list) + "~"*4*(8-len(icon_res_list))
|
||||||
|
|
||||||
currently_translation = get_translation(self._locale, "frontend.ui.card.climate.currently")
|
currently_translation = get_translation(self._locale, "frontend.ui.card.climate.currently")
|
||||||
state_translation = get_translation(self._locale, "frontend.ui.panel.config.devices.entities.state")
|
state_translation = get_translation(self._locale, "frontend.ui.panel.config.devices.entities.state")
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ It is also possible to configure different color overwrites per state:
|
|||||||
"on": [255,0,0]
|
"on": [255,0,0]
|
||||||
"off": [0,0,255]
|
"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`
|
It is also possible to use text instead of icons with `text:X`
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user