I have no idea why I didn’t receive a notification, sorry for the uber late reply. But you should not use the ' in your ieee address. Remove it and it will work.
I made some revisions to the blueprint. Only calls the device when the temp change actually requires it - instead of calling it for no reason. I also changed the calculation logic. Hope this is ok.
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'
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
condition:
condition: and
conditions:
- condition: template
value_template: "{{ states(temperature) != 'unavailable' }}"
- condition: template
value_template: "{{ states(temperature) != 'unknown' }}"
- condition: template
value_template: "{{states(temperature)|float(0) | round(1,'half') - (state_attr(climate_device,'current_temperature')|float(0) | round(1, 'half') - state_attr(climate_device,'local_temperature_calibration')|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(temperature)|float(0) | round(1,'half') - (state_attr(climate_device,'current_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
I do not see a change in the trigger part only that you made the time shorter that it triggers. So it will call it more often now. Other than that you also removed the reset that resets the local calibration to 0. This was needed because sometimes it was adding the numbers instead of calculating it from 0… Could you adjust it ? Than I can merge it. I will also change to GitHub so people can do pull requests.
I do really like the added condition check btw ! So if you can adjust it I can merge it
Although it will trigger on a state change it won’t do anything else if there’s nothing to do. My maths doesn’t do the reset to 0 as if you look there’s no way it can be “out”
Basically I’m taking the (current external temp - zigbee temp) and then taking off the current adjustment. As it’s always using a set starting point it doesn’t ever need zeroing.
Added a 15 second “hold” on the state so it doesn’t trigger multiple times (because it was!)
Thanks Neil for the explanation. Last time I debugged this the firmware itself did the weird calculation but since I didn’t change much since April I am unsure if anything has changed. I will check it later this week!
The temperature is recorded from an external sensor, but the temperature is of course other than 87. And it should mainly be the difference between the external sensor and temperature measured by TRV.
I have the same or at least similar issue with my saswell trvs and an external temperature sensor. when running the automation, the offset gets set to something like 4294967285 degrees celsius - which the produces the error
2021-11-19 22:01:20 ERROR (MainThread) [homeassistant.components.mqtt.number] Invalid value for number.thermostat_arbeitszimmer_local_temperature_calibration: 4294967285 (range -6.0 - 6.0)
I dont really know what the issue is here and hope someone can help …
@Lukacs_Attila the problem could be the variable name “current_temperature”. In you setting is named “local_temperature”. I suggest to change the blue print from “current_temperature” to “local_temperature” and try again.
Hi Neil,
i foud that there is the need to trigger the action not only when the remote sensor change temp. but also the TRV internal temp change. For istance due to the radiator heating up while the remote sensor still does not read any change. I tried adding in the trigger the climate.trv but it is not working.