From eb349b9a77b0c090b1422e60d70b41fcc8566141 Mon Sep 17 00:00:00 2001 From: illuzn <57167030+illuzn@users.noreply.github.com> Date: Tue, 24 May 2022 23:09:01 +0930 Subject: [PATCH] alternativeLayout fix --- apps/nspanel-lovelace-ui/luibackend/theme.py | 33 ++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/theme.py b/apps/nspanel-lovelace-ui/luibackend/theme.py index a7de37d2..06f9d107 100644 --- a/apps/nspanel-lovelace-ui/luibackend/theme.py +++ b/apps/nspanel-lovelace-ui/luibackend/theme.py @@ -47,26 +47,41 @@ default_weather_icon_color_mapping = { "windy-variant": "35957" #50% grey } -def get_screensaver_color_output(theme, state=None): +def get_screensaver_color_output(theme, state=None,alternativeEnable=None): color_output = "color" for key in default_screensaver_color_mapping: - color_output += f"~{map_color(key=key, theme=theme, state=state)}" + color_output += f"~{map_color(key=key, theme=theme, state=state, alternativeEnable=alternativeEnable)}" return color_output -def map_color(key, theme, state=None): +def map_color(key, theme, state=None, alternativeEnable=None): config_color = default_screensaver_color_mapping[key] # Use theme color if set if key in theme: config_color = rgb_dec565(theme[key]) # Use Autocolouring for weather elif state is not None: - if key in ["tMainIcon", "tF1Icon", "tF2Icon", "tF3Icon", "tF4Icon"]: - config_color = map_weather_icon_color(key=key, state=state) + if key in ["tMainIcon", "tF1Icon", "tF2Icon", "tF3Icon", "tF4Icon", "tMainIconAlt"]: + config_color = map_weather_icon_color(key=key, state=state, alternativeEnable=alternativeEnable) return config_color -def map_weather_icon_color(key, state): - if state[key] in default_weather_icon_color_mapping: - config_color = default_weather_icon_color_mapping[state[key]] +def map_weather_icon_color(key, state, alternativeEnable=None): + if alternativeEnable: +# Hack to make alternativelayout work. Do something better later. + if key in ["tMainIcon", "tF1Icon"]: +# Parse as if white for now. These may do something else in the future for alternativeLayout. + config_color = "65535" +# In alternativeLayout F2 is actually F1 and so on. tMainIconAlt replaces tMainIcon. Remap these + elif key == "tF2Icon": + config_color = default_weather_icon_color_mapping[state["tF1Icon"]] + elif key == "tF3Icon": + config_color = default_weather_icon_color_mapping[state["tF2Icon"]] + elif key == "tF4Icon": + config_color = default_weather_icon_color_mapping[state["tF3Icon"]] + elif key == "tMainIconAlt": + config_color = default_weather_icon_color_mapping[state["tMainIcon"]] else: - config_color = "65535" + if key in state and state[key] in default_weather_icon_color_mapping: + config_color = default_weather_icon_color_mapping[state[key]] + else: + config_color = "65535" return config_color