Battery Level and Temperature Offset for Tado

That’s a very good question! I think you’re right, it doesn’t apply the offset as my script does it through the Tado Api
I mostly use the Tado app, can you manually set the offset without using the app or without internet connection? If the answer is yes, then I think it’s possible

Currently the Homekit integration does not have the offset attribute and the offset can not be changed manually, only with the use of the app. I think the only possible way is if you’re familiar with python (and I think you are :slight_smile:) you could make an addition to the official HA Homekit climate component. Sadly I have no clue programming python.

What is the HA Homekit climate component, exactly? I think we might be talking about two different things here

Battery state should be supported after merging my PR:

Temperature offset will need this PyTado PR to be merged:


After that I can probably create a new PR adding support for temperature offset.
2 Likes

Hello,

I am closely following this thread as I’m looking to do the same on my Tado setup (a HA automation to correct valves offset using an external xiaomi zigbee sensor). I’ve seen that the PR by @north3221 has been accepted in the PyTado library. I am unsure what we need now, but I guess to add that support into the Tado integration in HA. Has anybody reported it to the Tado integration authors to include it?

Regards,

No sorry I haven’t yet. I have it working on mine as I already had the code written and loaded as a custom component to override the Tado integration pointing at my version of PyTado.

Now my pr had been accepted I’ll revert it to the official one and submit a pr to the ha integration.

I’ll try do this weekend

That will be excellent, thanks a lot. Let me know if you need any help with the testing!

PR created here: https://github.com/home-assistant/core/pull/45014

Taken a little longer as the code had moved on quite a bit from my local. So cloned latest HA dev branch and had to make some changes to how I did it previously. If you want to give it a go, stick the Tado folder in custom_components. Here is the code:

This only gives the ability to set the temp offset, not to see what it is. I had a quick look and think that needs a change to PyTado again, so it gets the info when updating. I’ll have a look at that another time, my set up I don’t need the current offset.

Hello!

I do not want to open a other topic a similar theme. Some release ago, on mobile app, it posssible to set that TRV-s able to start heating, or not (Independent mode)

What do you think, it possble to integrate to HA? (i don’t know, that is foundable in API)

image

Wow, many thanks @north3221 for the code and the fast reply. I have installed it in my HA instance and it works perfectly!

Now to figure how to do an automation that calls that service when the heating is on and the difference with an external sensor is greater than a threshold. No luck yet.

Thanks again!!

Hello again,

I need help setting up the automation to change the offset of vales with @north3221 update to Tado integration. My first attempt is this one: Trigger if offset is greater than 0.5 and then update the offset only if heating is on (to preserve battery life of valves).

alias: Tado set offset temperature
description: ''
mode: single
trigger:
  - platform: template
    value_template: >-
      {{ (states('sensor.cocina_external_temperature') | float -
      states('sensor.cocina_temperature') | float ) | abs > 0.5}}
condition:
  - condition: template
    value_template: '{{ states[''climate.cocina''].state == ''heat'' }}'
action:
  - service: tado.set_climate_temperature_offset
    data:  
      entity_id: climate.cocina
      offset: {{ ( states('sensor.cocina_external_temperature') | float - states('sensor.cocina_temperature') | float ) | round(2) }}

However, I am getting the following error when calling the service:

2021-01-11 09:12:50 ERROR (MainThread) [homeassistant.components.automation.tado_set_offset_temperature] Tado set offset temperature: Error executing script. Invalid data for call_service at pos 1: expected float for dictionary value @ data['offset']
2021-01-11 09:12:50 ERROR (MainThread) [homeassistant.components.automation.tado_set_offset_temperature] While executing automation automation.tado_set_offset_temperature

Is there a way to template the offset calling the tado service? Regards,

Hey

I am not sure, I suspect I would need to change the service code to accept a template, I’ll have a look when I get chance.

I’ll share what I do as you could use a similar approach for now as a work around. I am not quite using in the same way, as I use the external temp to change my offset not a separate thermostat in the room. The idea is the same though, external temp changes then call my python script to change the offset accordingly.

Here is the python script:

TEMP_BASE = 14
ENTITY_HEATING = {} #dict of climate entities you want to update create an entry for each one below
ENTITY_HEATING['climate.heating'] = {'default_offset': -1.2, 'rounding': 1}
ENTITY_HEATING['climate.bedroom'] = {'default_offset': -2, 'rounding': 0}
ENTITY_HEATING['climate.guest_bedroom'] = {'default_offset': 0, 'rounding': 0}

TEMP = float(data.get("temp", TEMP_BASE))
logger.info("Tado offset new temp received %d", TEMP)

# Added to fix bankers rounding without importing anything
if TEMP < TEMP_BASE:
    TEMP_BASE = TEMP_BASE + 0.01
else:
    TEMP_BASE = TEMP_BASE -0.01

for entity_id in ENTITY_HEATING:
    TEMP_OFFSET = float(round(((TEMP - TEMP_BASE) / 10) + ENTITY_HEATING[entity_id]['default_offset'], ENTITY_HEATING[entity_id]['rounding']))
    logger.info("Tado setting temp offset for %s to %s",entity_id, TEMP_OFFSET)
    SERVICE_DATA = {"entity_id": entity_id, "offset": TEMP_OFFSET}
    hass.services.call("tado", "set_climate_temperature_offset", SERVICE_DATA, False)

So basically you could send your temp to the python script and work out the offset and call the service…

fyi - I’ve added in the current offset as an attribute so you can get the current value in HA

@north3221 I cannot thank you enough. I have created a python script inspired in yours and I’ve got it running now.

I was using a “temporal” input_number entity to store it but it’ll be much better with that! I will update the component. Thanks again!!

For me, it makes more sense that HA already takes care of that and passes the processed data into the script but I don’t know anything about HA internals!!

No worries, glad I could help. Just trying to get all the stuff working right for HA so the PR can be accepted. Big learning curve for me :slight_smile:

With template for the service, in the code that registers the service you set the expected format, there must be something I would need to change there to accept template as well as float. It wasn’t obvious when I looked, but I only spent 30 secs on it, as don’t have much free time and the test wrappers and formatting for HA on the pr is more important right now

It takes a template now :slight_smile:

Thanks! Folllowing your PR to see it hopefully accepted! The python script versioned from yours works so well I am tempted to just leave it and not use the templating in HA… :sweat_smile:

btw @jrhbcn assume you saw it got accepted and have seen my write up of one automation to managed all Tado devices in the house?

Again, so many thanks @north3221 for sharing all this work. Time to switch the python script for full HA automation!

1 Like

Hello everyone. @north3221 that’s an awesome piece of work. I’m just wondering if this can be implemented with Tado using the Homekit controller not the Tado integration?

1 Like