Last active
November 27, 2024 09:16
-
-
Save niklaszerozero/80a5d880660b127b7fe461ebfac9ddf0 to your computer and use it in GitHub Desktop.
When the local temperature of the TRV changes, update the calibration using an external temperature sensor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Sonoff TRVZB Calibration | |
author: Niklas Vlach | |
description: " | |
When the local temperature of the TRV changes, update the calibration using an external temperature sensor. | |
**Version**: 0.0.3 | |
" | |
source_url: https://gist.github.com/NiklasZeroZero/80a5d880660b127b7fe461ebfac9ddf0 | |
domain: automation | |
input: | |
climate_entity: | |
name: Climate Entity | |
description: The climate entity published by the Sonoff TRVZB | |
selector: | |
entity: | |
filter: | |
- domain: climate | |
multiple: false | |
local_temperature_calibration_entity: | |
name: Local Temperature Calibration Entity | |
description: The temperature calibration entity published by the Sonoff TRVZB | |
selector: | |
entity: | |
filter: | |
- domain: number | |
multiple: false | |
temperature_sensor_entity: | |
name: Temperature Sensor Entity | |
description: The external room temperature sensor entity. | |
selector: | |
entity: | |
filter: | |
- domain: sensor | |
multiple: false | |
mode: single | |
max_exceeded: silent | |
trigger: | |
- platform: state | |
entity_id: | |
- !input climate_entity | |
attribute: current_temperature | |
condition: | |
- condition: or | |
conditions: | |
- condition: numeric_state | |
entity_id: !input climate_entity | |
attribute: current_temperature | |
above: !input temperature_sensor_entity | |
- condition: numeric_state | |
entity_id: !input climate_entity | |
attribute: current_temperature | |
below: !input temperature_sensor_entity | |
action: | |
- variables: | |
climate_entity: !input climate_entity | |
local_temperature_calibration_entity: !input local_temperature_calibration_entity | |
temperature_sensor_entity: !input temperature_sensor_entity | |
trvtemp: "{{ state_attr(climate_entity, 'current_temperature') }}" | |
trvcalib: "{{ states(local_temperature_calibration_entity) }}" | |
roomtemp: "{{ states(temperature_sensor_entity) }}" | |
calibration: "{{ ([-7, (trvcalib - (trvtemp - roomtemp)) | float | round(2), 7] | sort)[1] }}" | |
- action: number.set_value | |
target: | |
entity_id: !input local_temperature_calibration_entity | |
data: | |
value: "{{calibration}}" |
I'm sorry but I cannot replicate this error.
I have found a few similar issues where the device configuration was causing this.
Could you verify or send me your device configuration from the inside of configuration.yaml (/homeassistant/zigbee2mqtt/configuration.yaml)?
Excuse me, there was a similar script generated by ChatGPT, which was triggered after HA was restarted.
The only log entry related to your script is:
error: zhc: Failed to apply calibration to 'device_temperature': 'device_temperature_calibration' is not a number, got string ()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The script is excellent, but errors occasionally appear in the logs.
Z2M