My heating is controlled by a tado intelligent thermostat, with a bit of digging (no public api available yet) I've found ways of interrogating the tado server to check basic status.
All I want to do is return that status into indigo as variables so I can add them to control pages and the like.
I've managed to do that by using this code:
- Code: Select all
import urllib2
import simplejson
f = urllib2.urlopen('https://my.tado.com/mobile/1.4/getCurrentState?username=usernam,e&password=password')
json_string = f.read()
parsed_json = simplejson.loads(json_string)
tadooperation = parsed_json['autoOperation']
tadocontrol = parsed_json['controlPhase']
tadohousetemp = parsed_json['insideTemp']
tadosettemp = parsed_json['setPointTemp']
tadobox = parsed_json['boxConnected']
tadogateway = parsed_json['gwConnected']
tadots = parsed_json['tsConnected']
indigo.variable.updateValue(354149951, value=str(tadocontrol))
indigo.variable.updateValue(741265018, value=str(tadooperation))
indigo.variable.updateValue(187002669, value=str(tadohousetemp))
indigo.variable.updateValue(1159023434, value=str(tadosettemp))
indigo.variable.updateValue(1364699512, value=str(tadobox))
indigo.variable.updateValue(1132971864, value=str(tadogateway))
indigo.variable.updateValue(973513067, value=str(tadots))
f.close()
It works perfectly and I can update my control page, the only problem I'm having is the way tado returns the temperature.
I want to report it as 21.2 degrees but tado returns 21.1599998474 now I'm all for accuracy but that's a bit much!
I can't see a way to control the format of the numbers (easily!)
Can anyone offer a suggestion?