Fix another bug in Danfoss Ally blueprint

This time we default to resetting the external temperature if the
trigger state is not numeric.
This commit is contained in:
Rune Juhl Jacobsen 2025-04-14 08:52:18 +02:00
parent 5624a6002b
commit 3de96fbdc5

View file

@ -2,11 +2,11 @@ blueprint:
author: runejuhl
homeassistant:
min_version: 2025.2.4
name: Radiator external temperature sensor control (0.0.3-alpha)
name: Radiator external temperature sensor control (0.0.4-alpha)
description: |-
## Radiator external temperature sensor control
Version `0.0.3-alpha`.
Version `0.0.4-alpha`.
Sets the `external_measured_room_sensor` value on Danfoss Ally TRV, enabling
the TRV to adjust the valve based on an external sensor.
@ -73,16 +73,19 @@ actions:
# which case we pull the temperature from the sensor instead of the trigger
# state.
external_temperature: |-
{% if (trigger.id is not defined) or (trigger.to_state.state in ['unavailable', 'unknown']) %}
{{ states(temperature_entity) }}
{%- if (trigger.id is not defined) -%}
{%- set new_temp = states(temperature_entity) | float(-1.0) %}
{% else %}
{{ trigger.to_state.state | float }}
{%- set new_temp = (trigger.to_state.state | float(-1.0)) -%}
{% endif %}
{%- if new_temp <= 0.0 -%}
-8000.0
{%- else -%}
{{ new_temp * 100 | int }}
{%- endif -%}
- action: number.set_value
target:
entity_id: number.{{ states[climate_entity].object_id }}_external_measured_room_sensor
data:
value: |-
{{
(external_temperature * 100) | int
}}
value: "{{ external_temperature }}"