Page 1 of 9

Tado Thermostat Device Plugin

PostPosted: Tue May 31, 2016 8:32 am
by Colorado4Wheeler
Introduction

This plugin allows you to define a Tado Thermostat in Indigo as an actual Indigo thermostat. I do not own one of these thermostats and developed this as a request from a user who wanted to use Room-O-Matic but couldn't because his thermostat was entirely script controlled rather than being tied to an Indigo thermostat. The plugin is based on the basic information found online as well as a sample script written by Chockymonster in this thread.

This is most certainly a work in progress! The thermostat only supports polling from the Tado API and does not currently support changing any Tado settings in Indigo, you will still need to manually control the thermostat or use the apps provided by Tado to make any changes. This plugin will simply poll the Tado API every 30 seconds for changes.

Download and Installation

Install according to the Indigo documentation, then add the EPS - Tado Thermostat -> Tado Thermostat device into Indigo and you are done.

Download Plugin (Indigo File Library)

Release Notes

  • May 31, 2016 (1.0.0):
    • Initial release

Configuration and Use

The Tado is a foreign device to me (literally and figuratively) so the options are currently limited:

  • Username & Password: The same that you currently use to access your Tado device remotely
  • Supports Heat/Cool Setpoint: Select which is the case based on your model
  • Show Temps In: The model I was able to play with was a celsius model only so I added this to convert to Fahrenheit

Crowd Sourcing

Because I don't own one of these and was using someone else's information, any modifications to this plugin will require that someone with a different model and different needs can assist me in testing any changes or any new models. If you have some scripts that you know work with your device then please let me know and I'll see about incorporating it into the plugin.

Re: New Plugin: Tado Thermostat

PostPosted: Tue May 31, 2016 1:47 pm
by Londonmark
C4W,

Excellent - works perfectly. Many thanks. If I were able to add to your fine work to enable communication from Indigo to Tado, I would - but I'm not that good a programmer.

Two quick things:
- Right now I only have a single zone system, but I'm changing that. Is there any chance of supporting multiple zones?
- I can now select the Tado as a thermostat in the ACME CP plugin, but none of the values in my ACME CP device update. All of the custom states are empty. Perhaps this is something you're addressing in the ROM/CM updates? Or (more likely) I am doing something wrong.

Thanks once again. Love your work.

LM

Re: New Plugin: Tado Thermostat

PostPosted: Tue May 31, 2016 1:53 pm
by Londonmark
I can now select the Tado as a thermostat in the ACME CP plugin, but none of the values in my ACME CP device update. All of the custom states are empty. Perhaps this is something you're addressing in the ROM/CM updates? Or (more likely) I am doing something wrong.


Looking more closely, it may well be because I don't have a Weathersnoop station specified. I'm using the WUnderground plug-in instead (plus my own Oregon Scientific thermometer that talks to Indigo via an RFXCOM).

Re: New Plugin: Tado Thermostat

PostPosted: Tue May 31, 2016 2:45 pm
by Colorado4Wheeler
Londonmark wrote:
C4W,
Two quick things:
- Right now I only have a single zone system, but I'm changing that. Is there any chance of supporting multiple zones?
- I can now select the Tado as a thermostat in the ACME CP plugin, but none of the values in my ACME CP device update. All of the custom states are empty. Perhaps this is something you're addressing in the ROM/CM updates? Or (more likely) I am doing something wrong.

Thanks once again. Love your work.

LM


#1: Yes, that can easily be changed but I would need to see the JSON reply from Tado so I know how it is reported back
#2: I tested a Tado against ROM and made a few adjustments to make sure it worked, did you download the latest file (I just put 1.2.0 up today)? The prior version dumped a lot of errors about the Tado because some common parameters were missing (i.e., coolSetPoint), but I conditioned those in 1.2.0 so that if it's not part of the thermostat then it is ignored. However, I would expect errors in the log if you were using pre 1.2.0 release.

Londonmark wrote:
Looking more closely, it may well be because I don't have a Weathersnoop station specified. I'm using the WUnderground plug-in instead (plus my own Oregon Scientific thermometer that talks to Indigo via an RFXCOM)


Did you see any errors? I don't see why it would have issues with the thermostat module because the weather device is not saved, worse case is that it would cause errors when attempting to access an undefined weather station. That being said, the new ROM will be released soon and is NOT specific to device types, so you can use any weather station you desire and not be restricted to Weathersnoop.

Re: New Plugin: Tado Thermostat

PostPosted: Wed Jun 01, 2016 12:49 pm
by Londonmark
Thanks. I'm still having some problems with 1.20. I get this error in the log over and over:

Code: Select all
Traceback (most recent call last):
  File "plugin.py", line 69, in deviceUpdated
AttributeError: 'Plugin' object has no attribute 'th'

Re: New Plugin: Tado Thermostat

PostPosted: Wed Jun 01, 2016 1:59 pm
by Colorado4Wheeler
Do you have a thermostat defined in the Acme CP plugin? That error should only come up if the thermostat is not defined.

Here's a screenshot of my config using your thermostat and my Weathersnoop and I don't get any issues:

Screen Shot 2016-06-01 at 1.56.47 PM.png
Screen Shot 2016-06-01 at 1.56.47 PM.png (42.55 KiB) Viewed 11733 times


My log shows pretty solid as well:

Code: Select all
  Reloading plugin "Acme Future Home C-Panel System 1.2.0"
  Stopping plugin "Acme Future Home C-Panel System 1.2.0" (pid 23269)
  Stopped plugin "Acme Future Home C-Panel System 1.2.0"
  Starting plugin "Acme Future Home C-Panel System 1.2.0" (pid 55464)
  Started plugin "Acme Future Home C-Panel System 1.2.0"

Jun 1, 2016, 1:58:05 PM
  Reloading plugin "EPS - Tado Thermostat 1.0.0"
  Stopping plugin "EPS - Tado Thermostat 1.0.0" (pid 22243)
  Stopped plugin "EPS - Tado Thermostat 1.0.0"
  Starting plugin "EPS - Tado Thermostat 1.0.0" (pid 55494)
  Started plugin "EPS - Tado Thermostat 1.0.0"
  EPS - Tado Thermostat           received "Tado" heat setpoint update to 68.9°
  EPS - Tado Thermostat           received "Tado in C" heat setpoint update to 20.5°

Re: New Plugin: Tado Thermostat

PostPosted: Wed Jun 01, 2016 3:46 pm
by Londonmark
So I have the Tado thermostat defined, but nothing in the weather station field.

Re: New Plugin: Tado Thermostat

PostPosted: Wed Jun 01, 2016 4:12 pm
by Colorado4Wheeler
You may have to wait for the next ROM version then for those features. You can still use ROM for everything else, just not the thermostat stuff.

Re: New Plugin: Tado Thermostat

PostPosted: Wed Jun 01, 2016 4:57 pm
by Londonmark
Ok. No problem at all and thanks again for the Tado plugin.

Re: Tado Thermostat Device Plugin

PostPosted: Thu Aug 25, 2016 7:06 am
by Londonmark
Hi C4W,

I'm now up and running with my two zone Tado system (not that it's doing much as it's currently about as hot as London ever gets). You mentioned that 2 zone support would be possible, but you would need to see the JSON output. How can I get that to you?

LM

Re: Tado Thermostat Device Plugin

PostPosted: Thu Aug 25, 2016 7:29 am
by Colorado4Wheeler
How did you get the information before that you sent me?

Re: Tado Thermostat Device Plugin

PostPosted: Mon Aug 29, 2016 8:35 am
by Londonmark
Have PMd you.

Re: Tado Thermostat Device Plugin

PostPosted: Wed Sep 07, 2016 7:57 am
by Londonmark
OK, I've done some more digging and now have a script that pulls out the current temp, set temp and heating power level for both zones. It's not very elegant (and cobbles together stuff from elsewhere) but it seems to work. What I can't do is get the values into Indigo variables, but not sure how to modify the plugin to get them into device states. Ideally I would have two different devices representing my two zones...

Here's the script:
Code: Select all
import urllib
import urllib2
from cookielib import CookieJar
import json

class Tado:

    """Interacts with a Tado thermostat via public API.

    Example usage: t = Tado('me@somewhere.com', 'mypasswd')

                   t.getClimate(1) # Get climate, zone 1.

    """

    # Instance-wide constant info
    headers = { 'Referer' : 'https://my.tado.com/' }
    api2url = 'https://my.tado.com/api/v2/homes/'

    # 'Private' methods for use in class, Tado API V2.
    def _apiCall(self, cmd):
        url = '%s%i/%s' % (self.api2url, self.id, cmd)
        req = urllib2.Request(url, headers=self.headers)
        response = self.opener.open(req)
        data = json.loads(response.read())
        return data

    def _setOAuthHeader(self, data):
        access_token = data['access_token']
        self.headers['Authorization'] = 'Bearer ' + access_token

    def _loginV2(self, username, password):
        url='https://my.tado.com/oauth/token'
        data = { 'client_id' : 'tado-webapp',
                 'grant_type' : 'password',
                 'password' : password,
                 'scope' : 'home.user',
                 'username' : username }
        data = urllib.urlencode(data)
        url = url + '?' + data
        req = urllib2.Request(url, data={}, headers=self.headers)
        response = self.opener.open(req)
        self._setOAuthHeader(json.loads(response.read()))
        return response

    # Public interface
    def getMe(self):

        """Gets home information."""
        url = 'https://my.tado.com/api/v2/me'
        req = urllib2.Request(url, headers=self.headers)
        response = self.opener.open(req)
        data = json.loads(response.read())
        return data

    def getState(self, zone):
        """Gets current state of Zone zone."""
        cmd = 'zones/%i/state' % zone
        data = self._apiCall(cmd)
        return data

    def getCapabilities(self, zone):
        """Gets current capabilities of Zone zone."""
        cmd = 'zones/%i/capabilities' % zone
        data = self._apiCall(cmd)
        return data

    def getClimate(self, zone):
        """Gets temp (centigrade) and humidity (% RH) for Zone zone."""
        cmd = 'zones/%i/state' % zone
        data = self.getState(zone)['sensorDataPoints']
        return { 'temperature' : data['insideTemperature']['celsius'],
                 'humidity'    : data['humidity']['percentage'] }

    def getWeather(self):
        """Gets outside weather data"""
        cmd = 'weather'
        data = self._apiCall(cmd)
        return data


    # Ctor

    def __init__(self, username, password):

        """Performs login and save session cookie."""
        # HTTPS Interface
        cj = CookieJar()
        self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj),

                                      urllib2.HTTPSHandler())
        self._loginV2(username, password)
        self.id = self.getMe()['homes'][0]['id']


t = Tado('MYUSERNAME', 'MYPASSWORD')

tadohouseclimate2 = t.getClimate(2)
tadohousetemp2 = round(tadohouseclimate2['temperature'],1)

tadostate2 = t.getState(2)
tadosettemp2 = tadostate2['setting']['temperature']['celsius']
tadoMode2 = tadostate2['tadoMode']
tadoPower2 = tadostate2['activityDataPoints']['heatingPower']['percentage']

tadohouseclimate1 = t.getClimate(1)
tadohousetemp1 = round(tadohouseclimate1['temperature'],1)

tadostate1 = t.getState(1)
tadosettemp1 = tadostate1['setting']['temperature']['celsius']
tadoMode1 = tadostate1['tadoMode']
tadoPower1 = tadostate1['activityDataPoints']['heatingPower']['percentage']

indigo.variable.updateValue(1879001743, value=str(tadohousetemp2))
indigo.variable.updateValue(1691479346, value=str(tadosettemp2))
indigo.variable.updateValue(576439922, value=str(tadoMode2))
indigo.variable.updateValue(1629558637, value=str(tadoPower2))

indigo.variable.updateValue(1239631313, value=str(tadohousetemp1))
indigo.variable.updateValue(144820532, value=str(tadosettemp1))
indigo.variable.updateValue(1021117713, value=str(tadoMode1))
indigo.variable.updateValue(77399010, value=str(tadoPower1))

indigo.server.log("Zone 1 temp: " + str(tadohousetemp1))
indigo.server.log("Zone 2 temp: " + str(tadohousetemp2))

Re: Tado Thermostat Device Plugin

PostPosted: Mon Aug 21, 2017 3:02 am
by kelmk
Hi does this plugin still function? I just want to make sure they will work with Indigo before I purchase a tado thermostat.
Thanks!

Re: Tado Thermostat Device Plugin

PostPosted: Mon Aug 21, 2017 7:49 am
by agame
I have this up and running and reporting the status of zone one of my Tado reliably.

I actually have 3 tado devices however (two conventional heating thermostats, and one smart air conditioner controller), though I'd be pretty happy just getting the second heating zone going. I note the reference to two-zone support being feasible...any tips re enabling the second (or third) zone would be welcome...