From d7b0feea8a94a042dfb18fc5f0e19ca48536b60b Mon Sep 17 00:00:00 2001 From: illuzn <57167030+illuzn@users.noreply.github.com> Date: Mon, 23 May 2022 21:24:24 +0930 Subject: [PATCH] Update pages.py --- apps/nspanel-lovelace-ui/luibackend/pages.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index 268b8b05..ddfbf262 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -62,6 +62,7 @@ class LuiPagesGen(object): global babel_spec we_name = self._config._config_screensaver.entity.entityId unit = self._config._config_screensaver.raw_config.get("weatherUnit", "celsius") + state = {} if self._ha_api.entity_exists(we_name): we = self._ha_api.get_entity(we_name) @@ -70,6 +71,7 @@ class LuiPagesGen(object): return icon_cur = get_icon_id_ha("weather", state=we.state) + state["tMainIcon"] = we.state text_cur = convert_temperature(we.attributes.temperature, unit) forecastSkip = self._config._config_screensaver.raw_config.get(f"forecastSkip")+1 @@ -96,6 +98,14 @@ class LuiPagesGen(object): else: up = up.strftime('%a') icon = get_icon_id_ha("weather", state=we.attributes.forecast[fid]['condition']) + if i == 1: + state["tF1Icon"] = we.attributes.forecast[fid]['condition'] + elif i == 2: + state["tF2Icon"] = we.attributes.forecast[fid]['condition'] + elif i == 3: + state["tF3Icon"] = we.attributes.forecast[fid]['condition'] + elif i == 4: + state["tF4Icon"] = we.attributes.forecast[fid]['condition'] down = convert_temperature(we.attributes.forecast[fid]['temperature'], unit) else: up = "" @@ -117,6 +127,15 @@ class LuiPagesGen(object): altLayout = f"~{get_icon_id('water-percent')}~{we.attributes.humidity} %" self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}") + + # send color if configured in screensaver + theme = self._config.get("theme") + if theme is not None: + if "AutoWeather" in theme and theme["AutoWeather"] == "auto": + # do nothing + else: + state = None + self._send_mqtt_msg(get_screensaver_color_output(theme=theme, state=state)) def generate_entities_item(self, entity, cardType): entityId = entity.entityId