--- blueprint: domain: automation name: Ally Temp Update Min Delay description: Update Danfoss Ally TRV external temperature with min refresh rate source_url: https://github.com/mdeweerd/zha-toolkit/blob/master/blueprints/danfoss_ally_remote_temperature_min_delay.yaml 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 (corresponding to °C) selector: entity: device_class: temperature min_update_minutes: name: Minimum update interval description: > Updates will not be sent if time from last update is less than minimum interval. Normally 30 min for uncovered, 5 min for covered. default: 30 selector: number: max: 299 min: 1 unit_of_measurement: minutes mode: box temperature_offset: name: Temperature offset to apply to temperature measured by sensor description: > When the offset is -1.5 and the value measured by the sensor is 20 °C, then the temperature provide to the TRV will be 18.5 °C. default: 0 selector: number: max: 4.0 min: -4.0 step: 0.1 unit_of_measurement: °C mode: box 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 temp_offset: !input temperature_offset temperature: "{{ states(temp_sensor_id) }}" triggers: - triggers: state entity_id: - !input temp_sensor_id - triggers: event event_type: homeassistant_start id: ha_restart condition: - condition: template value_template: "{{ temperature != -32768 }}" action: - alias: Store ZHA reported temperature in state attribute action: zha_toolkit.ha_set_state data: state_id: "{{ temp_sensor_id }}" state_attr: best_val attr_val: "{{ (temperature|round(2)) }}" - alias: Try to get more precise temperature (should work if zigbee temperature sensor) action: zha_toolkit.attr_read data: ieee: "{{ temp_sensor_id }}" use_cache: true cluster: 1026 attribute: 0 state_id: "{{ temp_sensor_id }}" state_attr: best_val state_value_template: value/100 - alias: Fake small change in temperature so that the next sensor update triggers an update/change event in case the write fails action: zha_toolkit.ha_set_state data: state_id: "{{ temp_sensor_id }}" attr_val: "{{ (temperature|round(2)) - 0.001 }}" - alias: Write remote temperature to Danfoss Ally action: zha_toolkit.attr_write data: ieee: "{{ ieee }}" cluster: 0x0201 attribute: 0x4015 manf: 0x1246 attr_val: '{{ (((state_attr(temp_sensor_id, "best_val")|float) + temp_offset) * 100) | round(0) }}' read_before_write: false write_if_equal: true fail_exception: true tries: 3 - alias: Wait until the minimum update delay expires (the automation blocks itself because it is in single mode) delay: minutes: !input min_update_minutes - alias: Set slightly changed temperature if it is valid to force update. Otherwise, a valid temperature will trigger anyway. if: - condition: not conditions: - condition: state entity_id: !input temp_sensor_id state: "-32768" then: - alias: Fake small change in temperature so that the next sensor update triggers an update/change event action: zha_toolkit.ha_set_state data: state_id: "{{ temp_sensor_id }}" attr_val: "{{ (states(temp_sensor_id)|round(2)) + 0.001 }}" mode: single max_exceeded: silent