Skip to content

Instantly share code, notes, and snippets.

@sanderma
Last active April 1, 2024 00:13
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save sanderma/1e9163c690e23bc8d32a8c9e9d89a910 to your computer and use it in GitHub Desktop.
Save sanderma/1e9163c690e23bc8d32a8c9e9d89a910 to your computer and use it in GitHub Desktop.
Homeassistant blueprint to set Tado offset using separate temperature sensor
blueprint:
name: Tado temperature offset
description: Ensure the Tado smart valve has the temp of a separate sensor
domain: automation
input:
source_temp_sensor:
name: Source Temperature sensor
description: This sensor will be used as the source.
selector:
entity:
domain: sensor
device_class: temperature
target_tado:
name: Tado
description: The Tado to set the offset on.
selector:
entity:
domain: climate
variables:
target_tado: !input target_tado
source_temp_sensor: !input source_temp_sensor
tado_temp: "{{ state_attr(target_tado, 'current_temperature') | float }}"
current_offset: "{{ state_attr(target_tado, 'offset_celsius') }}"
actual_temp: "{{ states(source_temp_sensor) | float }}"
offset: "{{ ( actual_temp - tado_temp ) | round }}"
calculated_offset: "{{ ( ( actual_temp - tado_temp ) + current_offset ) | round }}"
trigger:
- platform: state
entity_id: !input target_tado
attribute: current_temperature
- platform: state
entity_id: !input source_temp_sensor
condition:
- condition: template
value_template: "{{ offset != 0 }}"
- condition: template
value_template: "{{ actual_temp != 0 }}"
action:
- service: system_log.write
data:
message: >
{{ target_tado }} has temp difference of {{ offset }}. Setting offset to {{ calculated_offset }}
level: info
logger: blueprints.tado.offset
- service: system_log.write
data:
message: >
target: {{ target_tado }}
source: {{ source_temp_sensor }}
temp difference: {{ offset }}
actual_temp: {{ actual_temp }}
tado_temp: {{ tado_temp }}
current_offset: {{ current_offset }}
calculated_offset: {{ calculated_offset }}
level: debug
logger: blueprints.tado.offset
- service: tado.set_climate_temperature_offset
data:
offset: "{{ calculated_offset }}"
entity_id: "{{ target_tado }}"
mode: single
@justcop
Copy link

justcop commented Mar 18, 2021

This is working very well for me except that when there are big temperature jumps when an offset is changed, it causes the open window detection to be triggered.

Is it possible to check the open window status and turn it back to off. I'm guessing it takes a few seconds for the apparent temperature drop to activate the open window setting so maybe add it 10 seconds after the offset has been triggered?

@sanderma
Copy link
Author

This is working very well for me except that when there are big temperature jumps when an offset is changed, it causes the open window detection to be triggered.

Is it possible to check the open window status and turn it back to off. I'm guessing it takes a few seconds for the apparent temperature drop to activate the open window setting so maybe add it 10 seconds after the offset has been triggered?

I'd rather not build that in, as it is not needed in most cases.
What you could do though, is have a separate automation that triggers when the offset is changed and pauses the open window detection.
I'm testing right now how to pause intelligently using the 'other' temperature sensor, or (as I use) a door/window sensor.
The latter is easy, stop the Tado if the window sensor detects that the window is open.
The former I'm going to play with.

Bottom line: if you want something now, trigger an automation on a change of the attribute offset of the Tado. (Couch typing now, if you'd like an example I can provide one later)

@justcop
Copy link

justcop commented Mar 22, 2021

Yeah, any hints you can provide would be much appreciated. I get your principles but can't see an easy way through the integration to turn off the open window, so guessing would need to go back to the api. I'm still nowhere near confident with home assistant syntax that this would be something I could manage in less than a few days.

@sanderma
Copy link
Author

Yeah, any hints you can provide would be much appreciated. I get your principles but can't see an easy way through the integration to turn off the open window, so guessing would need to go back to the api. I'm still nowhere near confident with home assistant syntax that this would be something I could manage in less than a few days.

Hmm, you are right. I don't see an easy way either to disable it from HA.
I do have some automations that disable Tado if a window is open (using openclose Xiaomi sensors) but will conjure something up using temp sensors detecting fast drop in temp.

Perhaps someone else has already thought of some smart way to do that 🤓

@justcop
Copy link

justcop commented Mar 24, 2021 via email

@sanderma
Copy link
Author

What you're saying is that the valve opens or closes every time due to the offset change?
That would be wrong behavior of the Tado.
Is it possible that the temp offset causes the Tado to know it should heat?

I live in the Netherlands and my bedroom heating periodically turns on at night (keeps it at 18°C) but that was also the case before the offset.

I'll check my logs to look for weird behavior as well.

@justcop
Copy link

justcop commented Mar 24, 2021 via email

@sanderma
Copy link
Author

Ha! Now I notice it here as well. Super annoying indeed.
Hope that will be fixed by Tado. It's obviously nonsense.

@justcop
Copy link

justcop commented Mar 26, 2021 via email

@justcop
Copy link

justcop commented Apr 8, 2021 via email

@marcnaus
Copy link

Hi! First of all thanks for a great blueprint. I am now using it with an ESP32 temp sensor and it works well but I indeed notice the same, a lot of opening and closing of the valve. And after a day the battery warning pops us, so indeed a significant drain of the battery. @justcop You have updated the script so it prevents the turning on/off of the valve every time offset changes?

I also updated the rounding, addded a decimal. You can see it in the plot. Left side with no decimals, right side with one decimal. So now they are both more alligned. (Blue ESP32 external reader / purple Tado) Will not help with the frequency of opening/closing off course so I hope this gets fixed :)

Screenshot 2021-12-14 at 10 09 10

@justcop
Copy link

justcop commented Dec 14, 2021

I suggest you have a look at this script from a different author who has done something similar.

https://github.com/north3221/home-assistant-config

My script is mostly stolen from there but merged with this one

Mine turns on and off less frequently by only triggering when a change would cause the heating to turn from on to off or vice versa and only when I am home and only when the difference is greater than the set tolerance.

I still find the number of changes too frequent, I'd like to edit it to allow for the expectation that if the target temperature is a lot more than the actual temperature it should expect that the thermostat temperature is also going to increase above the actual temperature more significantly, it could therefore increase the offset in larger increments to anticipate this.

The other problem I'm having is that changes in offsets can trigger open window detection. I'd like to temporarily turn this off prior to a change but this isn't possible with the home assistant integration, would need to access the tado api directly.

@marcnaus
Copy link

thanks a lot. I will have a look at that scripts as well.

I would think that if you are geting acces to the tado api then it would probably, if possible, be a lot easier just to have the external temp reader act as the leading temp reader, similar as adding another (70 euro) wireless tado temp unit ?

@justcop
Copy link

justcop commented Dec 14, 2021

Unfortunately the api doesn't allow for that, or else none of this would be necessery.

The api has more features than the HA integration but doesn't go as far as that.

HA intergrations are just a shell around apis but as its laborious, they only include the features that the maker of the integration has translated from the API.

@justcop
Copy link

justcop commented Dec 14, 2021

Actually, just looked at the API and you can't change open window detection mode from there. I wonder though if you could just read the mode (manual/scheduled etc) prior to the offset change and then reset that afterwards, would that override the open window detection, I think so.

@ilpantera
Copy link

Does anybody have the issue that this does not work when a room as more than one thermostat? The script works fine on one thermostat for me, but for rooms with more than one, the offset is not set.

@justcop
Copy link

justcop commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment