Skip to content

Instantly share code, notes, and snippets.

@jfisbein
Last active January 23, 2026 13:58
Show Gist options
  • Select an option

  • Save jfisbein/d7e0fb2e1501235479784179bff460fa to your computer and use it in GitHub Desktop.

Select an option

Save jfisbein/d7e0fb2e1501235479784179bff460fa to your computer and use it in GitHub Desktop.
blueprint:
name: Calibrate TRV using external sensor
description: Calibrate radiator TRV temperature sensor using an external temperature sensor.
domain: automation
input:
external_temperature_sensor:
name: External Temperature Sensor
description: Temperature sensor with correct temperature, used to calibrate TRV one.
selector:
entity:
filter:
domain: sensor
device_class: temperature
trv_calibration_entity:
name: TRV calibration entity.
description: Calibration entity from the TRV.
selector:
entity:
filter:
domain: number
thermostat_entity:
name: TRV Thermostat entity
selector:
entity:
filter:
domain: climate
variables:
external_temperature_sensor_state: !input external_temperature_sensor
trv_calibration_entity_state: !input trv_calibration_entity
thermostat_entity_state: !input thermostat_entity
trigger:
- trigger: state
entity_id: !input external_temperature_sensor
- trigger: state
entity_id: !input thermostat_entity
for:
seconds: 30
action:
- variables:
current_calibration: "{{ states(trv_calibration_entity_state) | int(0) }}"
trv_temp: "{{ state_attr(thermostat_entity_state, 'current_temperature') | float(0) }}"
external_temp: "{{ states(external_temperature_sensor_state) | float(0) }}"
min_calibration: "{{ state_attr(trv_calibration_entity_state, 'min') | int(0) }}"
max_calibration: "{{ state_attr(trv_calibration_entity_state, 'max') | int(0) }}"
trv_real: "{{ trv_temp - current_calibration }}"
raw_calibration: "{{ (external_temp - trv_real) | round(0) }}"
new_calibration: "{{ [max_calibration, [min_calibration, raw_calibration] | max] | min }}"
- if:
- condition: template
value_template: >-
{{ trv_temp != 0
and external_temp != 0
and (new_calibration - current_calibration) | abs >= 1 }}
then:
- service: number.set_value
target:
entity_id: !input trv_calibration_entity
data:
value: "{{ new_calibration }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment