From 5adc529e3728e4113c97966a1e6fd4ba585f17ec Mon Sep 17 00:00:00 2001 From: illuzn <57167030+illuzn@users.noreply.github.com> Date: Tue, 24 May 2022 23:08:08 +0930 Subject: [PATCH 1/5] alternativeLayout Fix --- apps/nspanel-lovelace-ui/luibackend/pages.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index 45f00a59..f0275e4e 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -123,7 +123,8 @@ class LuiPagesGen(object): weather_res+=f"~{up}~{icon}~{down}" altLayout = "" - if self._config._config_screensaver.raw_config.get("alternativeLayout", False): + alternativeEnable = self._config._config_screensaver.raw_config.get("alternativeLayout", False) + if alternativeEnable: altLayout = f"~{get_icon_id('water-percent')}~{we.attributes.humidity} %" self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}") @@ -132,7 +133,7 @@ class LuiPagesGen(object): if theme is not None: if not ("AutoWeather" in theme and theme["AutoWeather"] == "auto"): state = None - self._send_mqtt_msg(get_screensaver_color_output(theme=theme, state=state)) + self._send_mqtt_msg(get_screensaver_color_output(theme=theme, state=state, alternativeEnable=alternativeEnable)) def generate_entities_item(self, entity, cardType): entityId = entity.entityId 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 2/5] 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 From c3e3d04673edb6910d7be6e7e4a98796b90199be Mon Sep 17 00:00:00 2001 From: illuzn <57167030+illuzn@users.noreply.github.com> Date: Tue, 24 May 2022 23:21:12 +0930 Subject: [PATCH 3/5] Change capitalisation and config of autoWeather `AutoWeather` -> `autoWeather` for consistency with your capitalisation now accepts `true` as argument instead of auto for consistency --- apps/nspanel-lovelace-ui/luibackend/pages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index f0275e4e..63756a53 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -131,7 +131,7 @@ class LuiPagesGen(object): # send color if configured in screensaver if theme is not None: - if not ("AutoWeather" in theme and theme["AutoWeather"] == "auto"): + if not ("autoWeather" in theme and theme["autoWeather"]): state = None self._send_mqtt_msg(get_screensaver_color_output(theme=theme, state=state, alternativeEnable=alternativeEnable)) From ee128b564131fccff71d35c2cf031b0f012c913b Mon Sep 17 00:00:00 2001 From: illuzn <57167030+illuzn@users.noreply.github.com> Date: Tue, 24 May 2022 23:22:05 +0930 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4ae9f25..6d47e2af 100644 --- a/README.md +++ b/README.md @@ -498,7 +498,7 @@ key | option | type | default | description `tMainTextAlt` | True | list | White | `[R, G, B]` `tMRIcon` | True | list | White | `[R, G, B]` `tMR` | True | list | White | `[R, G, B]` -`AutoWeather` | True | string | None | Set to `auto` to enable weather icons to change depending on state e.g. blue for rainy. Any custom colors in `tMainIcon` `tF1Icon` `tF2Icon` `tF3Icon` `tF4Icon` take precedence +`autoWeather` | True | string | None | Set to `true` to enable weather icons to change depending on state e.g. blue for rainy. Any custom colors in `tMainIcon` `tF1Icon` `tF2Icon` `tF3Icon` `tF4Icon` take precedence. Specify colours as red green and blue values from 0-255 e.g. `[255, 0, 0]` for red or `[0, 0, 255]` for blue. These are translated internally to RGB565 (note that this has lower color depth so the colours may not appear the same). Also note that the screen has a low contrast ratio, so colors look sigificantly different at full display brightness and lowest brightness. From 06c82374eebd36f3a0b92ea9dc8793942c0e0f40 Mon Sep 17 00:00:00 2001 From: Johannes Date: Tue, 24 May 2022 16:42:25 +0200 Subject: [PATCH 5/5] adjust to firmware change --- apps/nspanel-lovelace-ui/luibackend/pages.py | 5 ++- apps/nspanel-lovelace-ui/luibackend/theme.py | 33 ++++++-------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index 63756a53..c23df52f 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -123,8 +123,7 @@ class LuiPagesGen(object): weather_res+=f"~{up}~{icon}~{down}" altLayout = "" - alternativeEnable = self._config._config_screensaver.raw_config.get("alternativeLayout", False) - if alternativeEnable: + if self._config._config_screensaver.raw_config.get("alternativeLayout", False): altLayout = f"~{get_icon_id('water-percent')}~{we.attributes.humidity} %" 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 not ("autoWeather" in theme and theme["autoWeather"]): 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): entityId = entity.entityId diff --git a/apps/nspanel-lovelace-ui/luibackend/theme.py b/apps/nspanel-lovelace-ui/luibackend/theme.py index 06f9d107..33ff7b10 100644 --- a/apps/nspanel-lovelace-ui/luibackend/theme.py +++ b/apps/nspanel-lovelace-ui/luibackend/theme.py @@ -47,41 +47,26 @@ default_weather_icon_color_mapping = { "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" 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 -def map_color(key, theme, state=None, alternativeEnable=None): +def map_color(key, theme, state=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", "tMainIconAlt"]: - config_color = map_weather_icon_color(key=key, state=state, alternativeEnable=alternativeEnable) + if key in ["tMainIcon", "tF1Icon", "tF2Icon", "tF3Icon", "tF4Icon"]: + config_color = map_weather_icon_color(key=key, state=state) return config_color -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"]] +def map_weather_icon_color(key, state): + if key in state and state[key] in default_weather_icon_color_mapping: + config_color = default_weather_icon_color_mapping[state[key]] else: - 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" + config_color = "65535" return config_color