Skip to content

Instantly share code, notes, and snippets.

@mmackowiak
Last active September 10, 2024 18:20
Show Gist options
  • Save mmackowiak/84092d0863d3b7f6330b96bd64fcb267 to your computer and use it in GitHub Desktop.
Save mmackowiak/84092d0863d3b7f6330b96bd64fcb267 to your computer and use it in GitHub Desktop.
# based on: https://community.home-assistant.io/t/tuya-radiator-valve-ts0601-calibration-from-external-sensor-via-zigbee2mqtt/337991
# alternative: https://community.home-assistant.io/t/sync-trv-with-external-tempature-sensor/298024
blueprint:
name: Temperature Calibration
description: Temperature calibration for Zigbee valve TS0601, according to external temperature sensor
domain: automation
input:
valve:
name: Smart Valve
selector:
entity:
domain: climate
temp_sensor:
name: Temperature Sensor
selector:
entity:
domain: sensor
device_class: temperature
variables:
valve: !input valve
temp_sensor: !input temp_sensor
trigger:
- platform: time_pattern
minutes: "/10"
- platform: template
value_template: "{{ ( state_attr('valve', 'current_temperature')|float(0) - states('temp_sensor')|float(0))|abs > 0.25 }}"
for: '00:00:02'
condition:
condition: and
conditions:
- condition: template
value_template: "{{ states(temp_sensor) != 'unavailable' }}"
- condition: template
value_template: "{{ states(temp_sensor) != 'unknown' }}"
- condition: template
value_template: "{{states(temp_sensor)|float(0) | round(1,'half') - (state_attr(valve,'current_temperature')|float(0) | round(1, 'half') - state_attr(valve,'local_temperature_calibration')|float(0) | round(1, 'half')) != state_attr(valve, 'local_temperature_calibration')|float(0) | round(1, 'half')}}"
action:
- service: mqtt.publish
data_template:
topic: "zigbee2mqtt/{{state_attr(valve,'friendly_name')}}/set/local_temperature_calibration"
payload: >-
{{states(temp_sensor)|float(0) | round(1,'half') - (state_attr(valve,'current_temperature')|float(0) | round(1, 'half') - state_attr(valve,'local_temperature_calibration')|float(0) | round(1, 'half'))}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment