From ba83781b0d829cdd9854e0bdf76c1caf7303e0dccb2d1a1e494bba7a2817dc05 Mon Sep 17 00:00:00 2001 From: Rune Juhl Jacobsen Date: Wed, 5 Mar 2025 09:06:17 +0100 Subject: [PATCH 1/2] Better error handling for Danfoss Ally TRV blueprint --- blueprints/danfoss_ally_trv_external_sensor.yaml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/blueprints/danfoss_ally_trv_external_sensor.yaml b/blueprints/danfoss_ally_trv_external_sensor.yaml index 80842cf..f5496fa 100644 --- a/blueprints/danfoss_ally_trv_external_sensor.yaml +++ b/blueprints/danfoss_ally_trv_external_sensor.yaml @@ -41,15 +41,21 @@ triggers: trigger: state conditions: -# We only want to execute the action if the temperature has changed by at least -# 0.1 degress C, according to the Zigbee2MQTT documentation for the device: -# https://www.zigbee2mqtt.io/devices/014G2461.html +# We only want to execute the action if +# +# * the temperature sensor is available, or +# +# * the temperature has changed by at least 0.1 degress C, according to the +# Zigbee2MQTT documentation for the device: +# https://www.zigbee2mqtt.io/devices/014G2461.html # # `external_measured_room_sensor` defaults to `-8000`, so this will work in all # cases. - condition: template value_template: |- - {% if state_attr(climate_entity, 'external_measured_room_sensor') == None %} + {% if state_attr(temperature_entity, 'temperature') is none %} + False + {% elif state_attr(climate_entity, 'external_measured_room_sensor') == None %} True {% else %} {{ @@ -65,7 +71,7 @@ actions: # which case we pull the temperature from the sensor instead of the trigger # state. external_temperature: |- - {% if trigger.id is not defined %} + {% if (trigger.id is not defined) or (trigger.to_state.state in ['unavailable', 'unknown']) %} {{ state_attr(temperature_entity, 'temperature') }} {% else %} {{ trigger.to_state.state | float }} From d71116761dd95e315d195b1be8f3bb1b7cef69e6cc9f7b342966db0f802fc5b0 Mon Sep 17 00:00:00 2001 From: Rune Juhl Jacobsen Date: Thu, 13 Mar 2025 22:50:48 +0100 Subject: [PATCH 2/2] Fix broken Danfoss Ally TRV automation Somehow I used the wrong variables last time around... --- blueprints/danfoss_ally_trv_external_sensor.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/blueprints/danfoss_ally_trv_external_sensor.yaml b/blueprints/danfoss_ally_trv_external_sensor.yaml index f5496fa..46325b8 100644 --- a/blueprints/danfoss_ally_trv_external_sensor.yaml +++ b/blueprints/danfoss_ally_trv_external_sensor.yaml @@ -53,9 +53,11 @@ conditions: # cases. - condition: template value_template: |- - {% if state_attr(temperature_entity, 'temperature') is none %} + {# if the temperature entity doesn't have a state, e.g. if it's powered off #} + {% if states(temperature_entity) is none %} False - {% elif state_attr(climate_entity, 'external_measured_room_sensor') == None %} + {# if the radiator has been unavailable #} + {% elif state_attr(climate_entity, 'external_measured_room_sensor') is none %} True {% else %} {{ @@ -72,7 +74,7 @@ actions: # state. external_temperature: |- {% if (trigger.id is not defined) or (trigger.to_state.state in ['unavailable', 'unknown']) %} - {{ state_attr(temperature_entity, 'temperature') }} + {{ states(temperature_entity) }} {% else %} {{ trigger.to_state.state | float }} {% endif %}