mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-12 16:17:13 +01:00
@@ -115,11 +115,18 @@ class NsPanelLovelanceUI:
|
|||||||
entity = self.api.get_entity(msg[3])
|
entity = self.api.get_entity(msg[3])
|
||||||
switch_val = 1 if entity.state == "on" else 0
|
switch_val = 1 if entity.state == "on" else 0
|
||||||
# scale 0-255 brightness from ha to 0-100
|
# scale 0-255 brightness from ha to 0-100
|
||||||
brightness = int(self.scale(entity.attributes.brightness,(0,255),(0,100)))
|
if entity.state == "on":
|
||||||
if "color_temp" in entity.attributes.supported_color_modes:
|
if entity.attributes.get("brightness"):
|
||||||
# scale ha color temp range to 0-100
|
brightness = int(self.scale(entity.attributes.brightness,(0,255),(0,100)))
|
||||||
color_temp = self.scale(entity.attributes.color_temp,(entity.attributes.min_mireds, entity.attributes.max_mireds),(0,100))
|
else:
|
||||||
|
brightness = 255 # light can't be dimmed so show brightness as 100%
|
||||||
|
if "color_temp" in entity.attributes.supported_color_modes:
|
||||||
|
# scale ha color temp range to 0-100
|
||||||
|
color_temp = self.scale(entity.attributes.color_temp,(entity.attributes.min_mireds, entity.attributes.max_mireds),(0,100))
|
||||||
|
else:
|
||||||
|
color_temp = "disable"
|
||||||
else:
|
else:
|
||||||
|
brightness = 0
|
||||||
color_temp = "disable"
|
color_temp = "disable"
|
||||||
self.send_mqtt_msg("entityUpdateDetail,{0},{1},{2}".format(switch_val,brightness,color_temp))
|
self.send_mqtt_msg("entityUpdateDetail,{0},{1},{2}".format(switch_val,brightness,color_temp))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user