added brightness

This commit is contained in:
Johannes
2022-03-19 21:24:03 +01:00
parent eac1095bbd
commit e5706d848f
2 changed files with 11 additions and 2 deletions

View File

@@ -19,6 +19,12 @@ def pos_to_color(x, y):
rgb = hsv2rgb(hsv[0],hsv[1],hsv[2])
return rgb
def rgb_brightness(rgb_color, brightness):
red = rgb_color[0]/255*brightness
green = rgb_color[1]/255*brightness
blue = rgb_color[2]/255*brightness
return [red, green, blue]
def rgb_dec565(rgb_color):
red = rgb_color[0]
green = rgb_color[1]

View File

@@ -1,7 +1,7 @@
import json
import datetime
import hassapi as hass
from color import pos_to_color, rgb_dec565
from color import pos_to_color, rgb_dec565, rgb_brightness
# check Babel
import importlib
@@ -367,7 +367,10 @@ class NsPanelLovelaceUI:
icon_color = 17299
if "rgb_color" in entity.attributes:
icon_color = rgb_dec565(entity.attributes.rgb_color)
color = entity.attributes.rgb_color
if "brightness" in entity.attributes:
color = rgb_brightness(color, entity.attributes.brightness)
icon_color = rgb_dec565(color)
return f",{item_type},{item},1,{icon_color},{name},{switch_val}"