adjust to firmware change

This commit is contained in:
Johannes
2022-05-24 16:42:25 +02:00
parent ee128b5641
commit 06c82374ee
2 changed files with 11 additions and 27 deletions

View File

@@ -123,8 +123,7 @@ class LuiPagesGen(object):
weather_res+=f"~{up}~{icon}~{down}" weather_res+=f"~{up}~{icon}~{down}"
altLayout = "" altLayout = ""
alternativeEnable = self._config._config_screensaver.raw_config.get("alternativeLayout", False) if self._config._config_screensaver.raw_config.get("alternativeLayout", False):
if alternativeEnable:
altLayout = f"~{get_icon_id('water-percent')}~{we.attributes.humidity} %" altLayout = f"~{get_icon_id('water-percent')}~{we.attributes.humidity} %"
self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}") self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}")
@@ -133,7 +132,7 @@ class LuiPagesGen(object):
if theme is not None: if theme is not None:
if not ("autoWeather" in theme and theme["autoWeather"]): if not ("autoWeather" in theme and theme["autoWeather"]):
state = None state = None
self._send_mqtt_msg(get_screensaver_color_output(theme=theme, state=state, alternativeEnable=alternativeEnable)) self._send_mqtt_msg(get_screensaver_color_output(theme=theme, state=state))
def generate_entities_item(self, entity, cardType): def generate_entities_item(self, entity, cardType):
entityId = entity.entityId entityId = entity.entityId

View File

@@ -47,39 +47,24 @@ default_weather_icon_color_mapping = {
"windy-variant": "35957" #50% grey "windy-variant": "35957" #50% grey
} }
def get_screensaver_color_output(theme, state=None,alternativeEnable=None): def get_screensaver_color_output(theme, state=None):
color_output = "color" color_output = "color"
for key in default_screensaver_color_mapping: for key in default_screensaver_color_mapping:
color_output += f"~{map_color(key=key, theme=theme, state=state, alternativeEnable=alternativeEnable)}" color_output += f"~{map_color(key=key, theme=theme, state=state)}"
return color_output return color_output
def map_color(key, theme, state=None, alternativeEnable=None): def map_color(key, theme, state=None):
config_color = default_screensaver_color_mapping[key] config_color = default_screensaver_color_mapping[key]
# Use theme color if set # Use theme color if set
if key in theme: if key in theme:
config_color = rgb_dec565(theme[key]) config_color = rgb_dec565(theme[key])
# Use Autocolouring for weather # Use Autocolouring for weather
elif state is not None: elif state is not None:
if key in ["tMainIcon", "tF1Icon", "tF2Icon", "tF3Icon", "tF4Icon", "tMainIconAlt"]: if key in ["tMainIcon", "tF1Icon", "tF2Icon", "tF3Icon", "tF4Icon"]:
config_color = map_weather_icon_color(key=key, state=state, alternativeEnable=alternativeEnable) config_color = map_weather_icon_color(key=key, state=state)
return config_color return config_color
def map_weather_icon_color(key, state, alternativeEnable=None): def map_weather_icon_color(key, state):
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:
if key in state and state[key] in default_weather_icon_color_mapping: if key in state and state[key] in default_weather_icon_color_mapping:
config_color = default_weather_icon_color_mapping[state[key]] config_color = default_weather_icon_color_mapping[state[key]]
else: else: