actions:
- choose:
  - conditions:
    - condition: template
      value_template: '{{ diff | abs >= 0.1 }}

        '
    - condition: device
      device_id: 07f0004e1c00fca1c04e55489c5513ac
      domain: binary_sensor
      entity_id: 56cf793c98d1fbc391b674ffd8555e4b
      for:
        hours: 0
        minutes: 1
        seconds: 0
      type: is_not_open
    sequence:
    - action: number.set_value
      data:
        value: '{{ new_cal }}

          '
      target:
        entity_id: number.heatertymkatrv10_local_temperature_calibration
  default: []
alias: Set heaterTymkaTRV10 temperature calibration for heater steering
conditions: []
description: ''
id: '1765817937658'
mode: single
triggers:
- seconds: /45
  trigger: time_pattern
variables:
  current_cal: '{% set current_correction = states(''number.heatertymkatrv10_local_temperature_calibration'') | float(0) %} {{ current_correction }}

    '
  diff: '{{ [1.5, [room_temp - trv_temp, -1.5] | max] | min }}

    '
  new_cal: '{% set raw = current_cal + diff %}

    {{ ([5, [raw, -5] | max] | min) | round(1) }}

    '
  room_temp: '{{ (room_temp_1 + room_temp_2)/ 2 | float(0) }}

    '
  room_temp_1: '{{ states(''sensor.thtuyatymka_temperature'') | float(0) }}

    '
  room_temp_2: '{{ states(''sensor.zhimi_mb3_af95_temperature'') | float(0) }}

    '
  trv_temp: '{{ state_attr(''climate.heatertymkatrv10'', ''current_temperature'') | float(0) }}

    '
