From 3b467591349ad125c7e6f05da9be0fbe70ad0a1f Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Tue, 6 Feb 2024 22:15:57 +0100 Subject: [PATCH] . --- nspanel-lovelace-ui/config.yaml | 2 +- .../rootfs/usr/bin/mqtt-manager/ha_control.py | 27 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/nspanel-lovelace-ui/config.yaml b/nspanel-lovelace-ui/config.yaml index ae244de9..f828bf9d 100644 --- a/nspanel-lovelace-ui/config.yaml +++ b/nspanel-lovelace-ui/config.yaml @@ -1,6 +1,6 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config name: NSPanel Lovelace UI Addon -version: "4.7.74" +version: "4.7.77" slug: nspanel-lovelace-ui description: NSPanel Lovelace UI Addon services: 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 95c9ef0a..958ba5d6 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 @@ -20,27 +20,32 @@ def calculate_dim_values(sleepTracking, sleepTrackingZones, sleepBrightness, scr dimmode = sleepBrightness 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 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): involved_entities.append(sleepBrightness) - dimmode = int(float(libs.home_assistant.get_entity_data(sleepBrightness).get('state', 10))) + try: + dimmode = int(float(libs.home_assistant.get_entity_data(sleepBrightness).get('state', 10))) + except ValueError: + print("sleepBrightness entity invalid") if screenBrightness: if isinstance(screenBrightness, int): dimValueNormal = screenBrightness 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 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): involved_entities.append(screenBrightness) - dimValueNormal = int(float(libs.home_assistant.get_entity_data(screenBrightness).get('state', 100))) - + try: + dimValueNormal = int(float(libs.home_assistant.get_entity_data(screenBrightness).get('state', 100))) + except ValueError: + print("screenBrightness entity invalid") # force sleep brightness to zero in case sleepTracking is active if sleepTracking: if libs.home_assistant.is_existent(sleepTracking):