mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-21 06:54:24 +01:00
implement screensaver
This commit is contained in:
@@ -258,17 +258,15 @@ class PowerCard(HACard):
|
||||
result += f"~{speed}"
|
||||
return result
|
||||
|
||||
class Screensaver(panel_cards.Card):
|
||||
class Screensaver(HACard):
|
||||
def __init__(self, locale, config, panel):
|
||||
super().__init__(locale, config, panel)
|
||||
if "entities" in config:
|
||||
for e in config.get("entities"):
|
||||
# print(e)
|
||||
HAEntity(locale, e, panel)
|
||||
# elif "entity" in config:
|
||||
|
||||
def render(self):
|
||||
return ""
|
||||
result = ""
|
||||
for e in self.entities:
|
||||
result += e.render(cardType=self.type)
|
||||
return result[1:]
|
||||
|
||||
|
||||
def card_factory(locale, settings, panel):
|
||||
|
||||
@@ -28,3 +28,6 @@ def send_date(topic, date):
|
||||
|
||||
def entityUpd(topic, data):
|
||||
custom_send(topic, f"entityUpd~{data}")
|
||||
|
||||
def weatherUpdate(topic, data):
|
||||
custom_send(topic, f"weatherUpdate~{data}")
|
||||
|
||||
@@ -113,15 +113,14 @@ class LovelaceUIPanel:
|
||||
libs.panel_cmd.page_type(self.sendTopic, "screensaver")
|
||||
self.current_card = Screensaver(
|
||||
self.settings["locale"], self.settings["screensaver"], self)
|
||||
libs.panel_cmd.entityUpd(
|
||||
libs.panel_cmd.weatherUpdate(
|
||||
self.sendTopic, self.current_card.render())
|
||||
|
||||
if msg[1] == "sleepReached":
|
||||
self.privious_cards.append(self.current_card)
|
||||
libs.panel_cmd.page_type(self.sendTopic, "screensaver")
|
||||
self.current_card = Screensaver(
|
||||
self.settings["locale"], self.settings["screensaver"], self)
|
||||
libs.panel_cmd.entityUpd(
|
||||
libs.panel_cmd.weatherUpdate(
|
||||
self.sendTopic, self.current_card.render())
|
||||
if msg[1] == "buttonPress2":
|
||||
entity_id = msg[2]
|
||||
|
||||
Reference in New Issue
Block a user