This is my take on the automation to send external temperature to Danfoss Ally TRV. These are my first attempts at creating a blueprint.
It differs from others with:
- ZHA and Zigbee2MQTT variants
- Uses a timer helper to trigger next start (when external sensor does not update for a long time)
- Does not use a delay/restart, as it can cause situation when attribute is not updated too long
- (Zigbee2MQTT only) Automatically detects correct timings based on radiator covered/uncovered setting
To use, you have to create a separate timer helper for each automation created from the blueprint.
For ZHA, you have to set the timer for the correct maximum update interval, according to radiator mode (30 min for covered, 3h for uncovered), and in blueprint input specify the minimum interval (5 min for covered, 30 min for uncovered)
blueprint:
domain: automation
name: Ally Temperature Update
description: Update Danfoss Ally TRV external temperature with min/max refresh rate
input:
ally_device:
name: Ally TRV Device
description: Temperature reading will be sent to this device
selector:
device:
manufacturer: Danfoss
entity:
domain: climate
min_update_minutes:
name: Minimum update interval
description: >
Updates will not be sent if time from last update is less than minimum interval.
Normally 30min for uncovered, 5min for covered.
selector:
number:
max: 360
min: 1
unit_of_measurement: minutes
mode: box
temp_sensor_id:
name: Temperature Sensor
description: External sensor from which the temperature will be read. Expects data format 12.3
selector:
entity:
domain: sensor
device_class: temperature
max_update_timer_id:
name: Timer entity
description: >
Timer that will be (re)started on update.
Set this timer to slowest interval you want the device to update at.
Normally 3h for uncovered, 30m for covered.
Use separate timer for each automation.
selector:
entity:
domain: timer
variables:
device: !input ally_device
ieee: "{{(device_attr(device, 'identifiers')|list)[0][1]}}"
min_update_minutes: !input min_update_minutes
temp_sensor_id: !input temp_sensor_id
trigger:
- platform: state
entity_id:
- !input temp_sensor_id
- platform: event
event_type: timer.finished
event_data:
entity_id: !input max_update_timer_id
condition:
- condition: template
value_template: >
{{ as_timestamp(now()) - as_timestamp(state_attr(this.entity_id,'last_triggered'),0)|int
> (60 * min_update_minutes) }}
action:
- service: zha.set_zigbee_cluster_attribute
data:
ieee: '{{ ieee }}'
endpoint_id: 1
cluster_id: 513
cluster_type: in
attribute: 16405
value: '{{ (states(temp_sensor_id) | float * 100) | round(0) }}'
- service: timer.start
target:
entity_id: !input max_update_timer_id
mode: single
For Zigbee2MQTT you still have to create a separate timer helper for each automation, but you donât have to set the intervals as they are decided automatically based on radiator_covered state. You can also change the covered/uncovered mode, and automation will use new timings on next run.
blueprint:
domain: automation
name: Danfoss Ally Ext Temp Z2M
description: Update Danfoss Ally TRV external temperature with min/max refresh rate, via zigbee2mqtt
input:
ally_device:
name: Ally TRV Device
description: Temperature reading will be sent to this device
selector:
device:
manufacturer: Danfoss
entity:
domain: climate
temp_sensor_id:
name: Temperature Sensor
description: External sensor from which the temperature will be read. Expects data format 12.3
selector:
entity:
domain: sensor
device_class: temperature
max_update_timer_id:
name: Timer entity
description: >
Timer that will trigger at maximum update interval
if source sensor has not changed.
Sets automatically to 30min for covered, 3h for uncovered
Use separate timer for each automation.
selector:
entity:
domain: timer
variables:
device: !input ally_device
temp_sensor_id: !input temp_sensor_id
radiator_covered_state: >
{{ states(
device_entities(device)
|select('match', '.*radiator_covered$')|first) }}
min_update_minutes: >
{% if radiator_covered_state == 'off' %}
30
{% else %}
5
{% endif %}
max_update_minutes: >
{% if radiator_covered_state == 'off' %}
180
{% else %}
30
{% endif %}
trigger:
- platform: state
entity_id: !input temp_sensor_id
- platform: event
event_type: timer.finished
event_data:
entity_id: !input max_update_timer_id
condition:
- condition: template
value_template: >
{{ as_timestamp(now())
- as_timestamp(state_attr(this.entity_id,'last_triggered'),0)
> 60 * min_update_minutes }}
action:
- service: mqtt.publish
data:
topic: "zigbee2mqtt/{{ device_attr(device, 'name') }}/set/external_measured_room_sensor"
payload_template: "{{ (states(temp_sensor_id) | float * 100) | round(0) }}"
- service: timer.start
target:
entity_id: !input max_update_timer_id
data:
duration: "{{ max_update_minutes * 60 }}"
mode: single
I hope these are helpful to someone.