Skip to content

Instantly share code, notes, and snippets.

@jfisbein
Last active January 14, 2024 11:02
Show Gist options
  • Save jfisbein/d7e0fb2e1501235479784179bff460fa to your computer and use it in GitHub Desktop.
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:
- platform: state
entity_id:
- !input external_temperature_sensor
action:
- service: number.set_value
target:
entity_id: !input trv_calibration_entity
data:
value: >-
{% set current_calibration = states(trv_calibration_entity_state) | int %}
{% set trv_calibrated = state_attr(thermostat_entity_state, 'current_temperature') |int %}
{% set th_real = states(external_temperature_sensor_state) | round(2) %}
{% set trv_real = trv_calibrated-current_calibration %}
{% set new_calibration = (th_real-trv_real) | round(0) %}
{% set min_calibration = state_attr(trv_calibration_entity_state, 'min') %}
{% set max_calibration = state_attr(trv_calibration_entity_state, 'max') %}
{{ [[new_calibration, min_calibration] | max, max_calibration] | min }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment