diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index 1531b9fa..0bfaa14a 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -96,16 +96,17 @@ class LuiPagesGen(object): if state == "sunny": icon_color = 65504 #bright-yellow - if "rgb_color" in attr: + if "rgb_color" in attr and attr.rgb_color: color = attr.rgb_color - if "brightness" in attr: + if "brightness" in attr and attr.brightness: color = rgb_brightness(color, attr.brightness) icon_color = rgb_dec565(color) - elif "brightness" in attr: + elif "brightness" in attr and attr.brightness: color = rgb_brightness([253, 216, 53], attr.brightness) icon_color = rgb_dec565(color) return icon_color + def update_time(self, kwargs): time = datetime.datetime.now().strftime(self._config.get("timeFormat")) addTemplate = self._config.get("timeAdditionalTemplate") @@ -787,13 +788,13 @@ class LuiPagesGen(object): if "onoff" not in entity.attributes.supported_color_modes: brightness = 0 if entity.state == "on": - if "brightness" in entity.attributes: + if "brightness" in entity.attributes and entity.attributes.brightness: # scale 0-255 brightness from ha to 0-100 brightness = int(scale(entity.attributes.brightness,(0,255),(0,100))) else: brightness = "disable" - if "color_temp" in entity.attributes.supported_color_modes: - if "color_temp" in entity.attributes: + if "color_temp" in entity.attributes.supported_color_modes and entity.attributes.supported_color_modes: + if "color_temp" in entity.attributes and entity.attributes.color_temp: # scale ha color temp range to 0-100 color_temp = int(scale(entity.attributes.color_temp,(entity.attributes.min_mireds, entity.attributes.max_mireds),(0,100))) else: