hass-blueprints/blueprints/danfoss_ally_trv_external_sensor.yaml
Rune Juhl Jacobsen 3de96fbdc5 Fix another bug in Danfoss Ally blueprint
This time we default to resetting the external temperature if the
trigger state is not numeric.
2025-04-14 08:52:18 +02:00

91 lines
2.6 KiB
YAML

blueprint:
author: runejuhl
homeassistant:
min_version: 2025.2.4
name: Radiator external temperature sensor control (0.0.4-alpha)
description: |-
## Radiator external temperature sensor control
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.
domain: automation
source_url: https://git.petardo.dk/runejuhl/hass-blueprints/raw/branch/dev/blueprints/danfoss_ally_trv_external_sensor.yaml
input:
radiator:
name: Radiator thermostat
selector:
entity:
filter:
- domain:
- climate
multiple: false
climate_sensor:
name: Climate sensor temperature entity
selector:
entity:
filter:
- device_class:
- temperature
multiple: false
mode: queued
variables:
climate_entity: !input radiator
temperature_entity: !input climate_sensor
triggers:
- entity_id: !input climate_sensor
trigger: state
conditions:
# 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 the temperature entity doesn't have a state, e.g. if it's powered off #}
{% if states(temperature_entity) is none %}
False
{# if the radiator has been unavailable #}
{% elif state_attr(climate_entity, 'external_measured_room_sensor') is none %}
True
{% else %}
{{
( (state_attr(climate_entity, 'external_measured_room_sensor')
- (trigger.to_state.state | float) * 100) | abs)
>= 10
}}
{% endif %}
actions:
- variables:
# If we don't have a trigger ID the automation has been run manually, in
# which case we pull the temperature from the sensor instead of the trigger
# state.
external_temperature: |-
{%- if (trigger.id is not defined) -%}
{%- set new_temp = states(temperature_entity) | float(-1.0) %}
{% else %}
{%- 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 }}"