Sync TRV with external tempature sensor

Unfortunately, I’ve found some serious mistakes in my blueprint. This is corrected version (I hope):

blueprint:
  name: Sync TRV tempature
  description: Sync external tempature sensor with TRV tempature
  domain: automation
  input:
    ieeeaddressoftrv:
      name: IEEE Address
      description: This is the address of the TRV found in your zigbee database example 0x459877fffe1f2e83
    external_temp:
      name: Select the external temp sensor
      description: This will be your external temp sensor
      selector:
        entity:
          domain: sensor
          device_class: temperature
    climate_name:
      name: Climate entry
      description: This will be the TRV it self in home assistant
      selector:
        entity:
          domain: climate 
alias: Calibrate Thermostat
description: ''

variables:
  target_device: !input 'ieeeaddressoftrv'
  climate_device: !input 'climate_name'
  external_temperature: !input 'external_temp'
  adjust: "{{state_attr(climate_device, 'current_temperature')}}"
trigger:
  - platform: state
    entity_id: !input 'external_temp'
    for:
      hours: 0
      minutes: 0
      seconds: 15
      milliseconds: 0
  - platform: state
    entity_id: !input 'climate_name'
    for:
      hours: 0
      minutes: 0
      seconds: 15
      milliseconds: 0
condition:
  condition: and
  conditions:
    - condition: template
      value_template: "{{ states(external_temperature) != 'unavailable' }}"
    - condition: template
      value_template: "{{ states(external_temperature) != 'unknown' }}"
    - condition: template
      value_template: "{{ state_attr(climate_device,'local_temperature_calibration')|float(0) | round(1, 'half') !=( states(external_temperature)|float(0) | round(1,'half') - state_attr(climate_device,'local_temperature')|float(0) | round(1, 'half') + state_attr(climate_device,'local_temperature_calibration')|float(0) | round(1, 'half')) }}"
action:      
  - service: mqtt.publish
    data_template:
      topic: zigbee2mqtt/{{ target_device }}/set/local_temperature_calibration
      payload_template: >-
        {{states(external_temperature)|float(0) | round(1,'half') - state_attr(climate_device,'local_temperature')|float(0) | round(1, 'half') + state_attr(climate_device,'local_temperature_calibration')|float(0) | round(1, 'half') }}
  - delay: 5
mode: single
max_exceeded: silent

1 Like

To be honest i started using ai_thermostat. So I am not using this any more (GitHub - KartoffelToby/ai_thermostat: This integration brings some smartness to your TRV Zigbee2MQTT setup. What does it? simplifies your TRVs modes, makes your TRVs full compatible to Google Home, adds a window open detection with an external open/close sensor, adds a summer shutdown with a weather entity or outdoor temperature sensor, adds "better" room temperature based calibration with an external room termperature sensor, because it works moste of the time not good on the TRV, adds a scheduler for valve maintanance to prevent the valve to get stucked or noisy, adds a night reduction mode)

Hello. I have the same error. Do you find a solution? Or anybody else?

Dear Beny_44,
maybe stupid question but i see you have programming mode weekday and Saturday and Sunday. I only see workdays_schedule. how can i make the schedule as you have in separate days?

I like to hear from you.

Regards,

Wilfried

i have the same problem only -6 to 6 but the automatisation dont know which range he can use.
Possible calibration values are: -6, -5, -4, -3, -2 ,-1 , 0,1,2,3,4,5,6
And no floating number

I revised the blueprint to make it work for my Moes BRT-100-TRV with a calibration range of -9 to 9 in full increments: https://gist.github.com/bklaesener/e836e1fbd37cdfb42d9b9672be29c92c

The original blueprint did not work with this device as it provided for adding the current value of the calibration to the newly measured temperature delta. This resulted in a “race to the bottom” where the calibration was continuously adjusted downward, and soon MQTT appeared overwhelmed with messages, resulting in my Zigbee devices becoming unresponsive. That behavior was observed by other users, as well. The optimized blueprint therefore does not add the current calibration value to the temperature delta.

The new calibration value is also capped at the -9 minimum. There is no cap at the maximum, as this does not appear to be a practical scenario.

In order to prevent excessive MQTT traffic caused by repeatedly setting the minimum calibration value (in case the actual temperature delta is lower than the minimum), the blueprint checks whether the minimum calibration setting of -9 has already been reached and in that case only proceeds if the new calibration setting would be above -9.

If your device has different valid calibration values, it should be easy to adjust on the basis of this revised blueprint.

1 Like

Thanks @bk1 for the change, I updated the gist :slight_smile:

@nivong: I was not sure my version would fit everybody since you will probably have had a reason for setting your blueprint up the way it was and different TRVs may behave differently. I assume you did not experience downward adjustment loops yourself, did you?

Here the same. My config:
-Saswell SEA801-Zigbee/SEA802-Zigbee control via MQTT | Zigbee2MQTT
-Xiaomi Bluetooth LYWSDCGQ Temp-Sensor via Passive BLE-Monitor

@nivong I try your blueprint because ai_thermostat/better_thermostat does not work on my setup.

Is there a chance to fix that. Would be cool for @alexw1982 @Icke_Bins and @gomble too.

Here is my error:

Logger: homeassistant.components.mqtt.number
Source: components/mqtt/number.py:191
Integration: MQTT (documentation, issues)
First occurred: 12:10:52 (44 occurrences)
Last logged: 12:20:32

Invalid value for number.valve_wz_local_temperature_calibration: 4294967273 (range -6.0 - 6.0)

EDIT: Wow, what a coding trip :smiley: But it was cool, I never know what it possible with the developer-area and how python works in case of variables etc.

I checked the blueprint yesterday. My SEA802 TRV has completely different attributes. It starts with the fact that the measured temperature on the adapter itself is addressed via ‘current_temperature’.

The calibration goes from a range of -6 to +6. In addition, the calibration is adjustable via a separate entity. In my case:
states(‘number.valve_wz_local_temperature_calibration’)

So this blueprint came out:
Sync TRV SEA802-Z01 with external sensor blueprint (github.com)

So this blueprint came out:
https://gist.github.com/sorryusernameisalreadytaken/f4947733eab9d8db8d245a664d82d7f6

sadly, the link does not work …

@alexw1982 THX. Is fixed. Sorry.

But I need to say that I am not 100% sure if its representate the original logic. Perhaps @nivong or @bk1 can tell me if I am on the right train to success SchuuuSchuuuuuu

On my SEA802-Z01 TRV I had 2 temperature attributes:

{{ state_attr('climate.yourvalveidentifier' ,'current_temperature')

→ is the current temperature, measured by the TRV

{{ state_attr('climate.yourvalveidentifier' ,'temperature')

→ is the target temperature the TRV should heat-up too

{{ states('number.yourvalveidentifier_local_temperature_calibration')|float|round - 0 }}

→ is the offset temperature range, going from -6 to +6 (including 0)

Hello @bk1 @JamieMe @nivong
i tried the blueprint. The function is given. It change the range only between -6 to 6. My problem is, that the change is to frequently and the TRV can´t handle it.

I have the same problem with another TRV (Eurotronic SPZB001)
Greetings

Please use this: GitHub - KartoffelToby/better_thermostat: This custom component for Home Assistant will add crucial features to your climate-controlling TRV (Thermostatic Radiator Valves) to save you the work of creating automations to make it smart. It combines a room-temperature sensor, window/door sensors, weather forecasts, or an ambient temperature probe to decide when it should call for heat and automatically calibrate your TRVs to fix the imprecise measurements taken in the radiator's vicinity.

1 Like

Hello,

I have Moes BRT-100 TRV and I wanted following stuff:

  • calibrate my TRVs with external temperature sensor
  • did not want to use too complicated external Home Assistant extension but rather just an automation

I inspired myself with blueprint mentioned here, but at the end it ended up in a different state.

Here it is, if you wanted to try (or even improve it):

It does:

  • supports multiple TRV (e.g. in same room) to be calibrated by single external temperature sensor
  • changes TRVs calibration by state stored directly in HA (not by mqtt call as in original blueprint).
  • may add (weighted) difference between target and actual temperature to the calibration

More info in the linked repository.

@LukasVyhlidka Hi! Just wanted to say THANK YOU! This is the best automation I tested so far for this scenario (I have 9 radiators). Better thermostat is too ambitious and unfortunately filled with bugs. I tested other blueprints but had problems here and there, your work is the best one by far!

Hey Lukas,

i got an BRT100 two and got some issues with the sync to an external sensor. I tried yours aswell and got the same result. The problem seams that the current temperature of the trv isnt reported to homeassistant that frequently.
Do you discovered this issue aswell?