diff --git a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/ha_control.py b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/ha_control.py index 903499f8..95c9ef0a 100644 --- a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/ha_control.py +++ b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/ha_control.py @@ -21,6 +21,7 @@ def calculate_dim_values(sleepTracking, sleepTrackingZones, sleepBrightness, scr elif isinstance(sleepBrightness, list): logging.error("list style config for sleepBrightness no longer supported") elif sleepBrightness.startswith("ha:"): + time.sleep(1) dimmode = int(float(libs.home_assistant.get_template(sleepBrightness)[3:])) involved_entities.extend(libs.home_assistant.get_template_listener_entities(sleepBrightness)) elif libs.home_assistant.is_existent(sleepBrightness): @@ -33,6 +34,7 @@ def calculate_dim_values(sleepTracking, sleepTrackingZones, sleepBrightness, scr elif isinstance(screenBrightness, list): logging.error("list style config for screenBrightness no longer supported") elif screenBrightness.startswith("ha:"): + time.sleep(1) dimValueNormal = int(float(libs.home_assistant.get_template(screenBrightness)[3:])) involved_entities.extend(libs.home_assistant.get_template_listener_entities(screenBrightness)) elif libs.home_assistant.is_existent(screenBrightness): diff --git a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/libs/home_assistant.py b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/libs/home_assistant.py index 28e2d59a..afd700fc 100644 --- a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/libs/home_assistant.py +++ b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/libs/home_assistant.py @@ -246,6 +246,8 @@ def execute_script(entity_name: str, domain: str, service: str, service_data: di return {} def cache_template(template): + if not template: + raise Exception("Invalid template") global next_id, response_buffer try: call_id = next_id diff --git a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/panel.py b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/panel.py index f531aab0..84177a35 100644 --- a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/panel.py +++ b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/panel.py @@ -76,8 +76,10 @@ class LovelaceUIPanel: ha_control.wait_for_ha_cache() #request templates on cards - libs.home_assistant.cache_template(self.settings.get("sleepBrightness")) - libs.home_assistant.cache_template(self.settings.get("screenBrightness")) + if self.settings.get("sleepBrightness").startswith("ha:"): + libs.home_assistant.cache_template(self.settings.get("sleepBrightness")) + if self.settings.get("screenBrightness").startswith("ha:"): + libs.home_assistant.cache_template(self.settings.get("screenBrightness")) for c in self.cards.values(): if hasattr(c, "qrcode"): if c.qrcode.startswith("ha:"):