new alt screensaver

This commit is contained in:
Johannes Braun
2023-01-20 23:53:13 +01:00
parent 9089740425
commit d0294c97bb
3 changed files with 16 additions and 10 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -112,6 +112,9 @@ class LuiPagesGen(object):
state["tMainIcon"] = we.state state["tMainIcon"] = we.state
text_cur = convert_temperature(we.attributes.temperature, unit) text_cur = convert_temperature(we.attributes.temperature, unit)
if self._config._config_screensaver.raw_config.get("alternativeLayout", False):
text_cur = f"{get_icon_id('thermometer')}{text_cur}"
forecastSkip = self._config._config_screensaver.raw_config.get(f"forecastSkip")+1 forecastSkip = self._config._config_screensaver.raw_config.get(f"forecastSkip")+1
# check if the difference between the first 2 forecast items is less than 24h # check if the difference between the first 2 forecast items is less than 24h
difference = (dp.parse(we.attributes.forecast[forecastSkip]['datetime']) - dp.parse(we.attributes.forecast[0]['datetime'])) difference = (dp.parse(we.attributes.forecast[forecastSkip]['datetime']) - dp.parse(we.attributes.forecast[0]['datetime']))
@@ -177,11 +180,19 @@ class LuiPagesGen(object):
down = f"{entity.state} {unit_of_measurement}" down = f"{entity.state} {unit_of_measurement}"
weather_res+=f"~{up}~{icon}~{down}" weather_res+=f"~{up}~{icon}~{down}"
altLayout = "~~" altLayout = "~"
if self._config._config_screensaver.raw_config.get("alternativeLayout", False): if self._config._config_screensaver.raw_config.get("alternativeLayout", False):
altLayout = f"~{get_icon_id('water-percent')}~{we.attributes.humidity} %" indoorTemp = self._config._config_screensaver.raw_config.get("indoorTemp")
if indoorTemp is not None and apis.ha_api.entity_exists(indoorTemp.get("entity","")):
entity = apis.ha_api.get_entity(indoorTemp.get("entity"))
icon = get_icon_ha(indoorTemp.get("entity"), overwrite=indoorTemp.get("icon"))
unit_of_measurement = entity.attributes.get("unit_of_measurement", "")
altLayout = f"~{icon}{entity.state}{unit_of_measurement}"
else:
altLayout = f"~{get_icon_id('water-percent')}{we.attributes.humidity} %"
self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}")
# status icons def update_status_icons(self):
status_res = "" status_res = ""
altfont = "" altfont = ""
for i in range(1,3): for i in range(1,3):
@@ -197,13 +208,7 @@ class LuiPagesGen(object):
else: else:
status_res += "~~" status_res += "~~"
altfont += "~" altfont += "~"
self._send_mqtt_msg(f"statusUpdate{status_res}{altfont}")
self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}{status_res}{altfont}")
# send color if configured in screensaver
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))
def generate_entities_item(self, item, cardType="cardGrid", temp_unit=""): def generate_entities_item(self, item, cardType="cardGrid", temp_unit=""):
entityId = item.entityId entityId = item.entityId
@@ -706,6 +711,7 @@ class LuiPagesGen(object):
if card.cardType == "screensaver": if card.cardType == "screensaver":
theme = card.raw_config.get("theme") theme = card.raw_config.get("theme")
self.update_screensaver_weather(theme) self.update_screensaver_weather(theme)
self.update_status_icons()
return return
if card.cardType == "cardQR": if card.cardType == "cardQR":
qrcode = card.raw_config.get("qrCode", "") qrcode = card.raw_config.get("qrCode", "")