changed color on state

This commit is contained in:
Johannes
2022-03-21 10:52:55 +01:00
parent bd64ba702a
commit 41c90f68ce

View File

@@ -484,15 +484,7 @@ class NsPanelLovelaceUI:
if item_type == "light": if item_type == "light":
switch_val = 1 if entity.state == "on" else 0 switch_val = 1 if entity.state == "on" else 0
icon_color = 17299 icon_color = getEntityColor(entity)
if "rgb_color" in entity.attributes:
color = entity.attributes.rgb_color
if "brightness" in entity.attributes:
color = rgb_brightness(color, entity.attributes.brightness)
icon_color = rgb_dec565(color)
elif "brightness" in entity.attributes:
color = rgb_brightness([253, 216, 53], entity.attributes.brightness)
icon_color = rgb_dec565(color)
return f",{item_type},{item},{get_icon_id('lightbulb')},{icon_color},{name},{switch_val}" return f",{item_type},{item},{get_icon_id('lightbulb')},{icon_color},{name},{switch_val}"
if item_type == "switch" or item_type == "input_boolean": if item_type == "switch" or item_type == "input_boolean":
@@ -630,22 +622,29 @@ class NsPanelLovelaceUI:
return f"entityUpd,|{item}|{heading}|{icon}|{title}|{author}|{volume}|{iconplaypause}" return f"entityUpd,|{item}|{heading}|{icon}|{title}|{author}|{volume}|{iconplaypause}"
def getEntityColor(self, entity):
attr = entity.attributes
default_color_on = rgb_dec565([253, 216, 53])
default_color_off = rgb_dec565([68, 115, 158])
icon_color = default_color_on if entity.state == "on" else default_color_off
if "rgb_color" in attr:
color = attr.rgb_color
if "brightness" in attr:
color = rgb_brightness(color, attr.brightness)
icon_color = rgb_dec565(color)
elif "brightness" in attr:
color = rgb_brightness([253, 216, 53], attr.brightness)
icon_color = rgb_dec565(color)
return icon_color
def generate_detail_page(self, page_type, entity): def generate_detail_page(self, page_type, entity):
if page_type == "popupLight": if page_type == "popupLight":
entity = self.api.get_entity(entity) entity = self.api.get_entity(entity)
switch_val = 1 if entity.state == "on" else 0 switch_val = 1 if entity.state == "on" else 0
icon_color = 17299 icon_color = getEntityColor(entity)
if "rgb_color" in entity.attributes:
color = entity.attributes.rgb_color
if "brightness" in entity.attributes:
color = rgb_brightness(color, entity.attributes.brightness)
icon_color = rgb_dec565(color)
elif "brightness" in entity.attributes:
color = rgb_brightness([253, 216, 53], entity.attributes.brightness)
icon_color = rgb_dec565(color)
brightness = "disable" brightness = "disable"
color_temp = "disable" color_temp = "disable"