This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tado_reader.py
107 lines (81 loc) · 3.5 KB
/
Tado_reader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import base64
import urllib2
from interface.py import Tado
# -------------- START Configuration Section --------------------------------#
#Set login info Tado
t = Tado('<TADOUSERNAME>', '<TADOPASSWORD>')
#t.getClimate(1) # Get climate, zone 1.
#t.getPower(1) # Get climate, zone 1.
# Your Domoticz installation (usually localhost:8080, without http://)
domoticzURL = ""
# the username / password of your Domoticz installation (optional, if you
# enabled authentication
domoticzusername = ""
domoticzpassword = ""
# the IDX from the indoor Temp/Humid dummy device in Domoticz
domoticzIDXinttemp = ""
# the IDX from the outside Temp dummy device in Domoticz
domoticzIDXtemp = ""
# the IDX from the sunpower dummy device in Domoticz
domoticzIDXsun = ""
# the IDX from the boilerpower device in Domoticz
domoticzIDXbpow = ""
#Set to 1 for debugging
debug = 0
# -------------- END Configuration Section ----------------------------------#
# Getvalues
outsideTemp = t.getOutsideTemp()
power = t.getPower(1)
climate = t.getClimate(1)
if debug:
print outsideTemp
print power
print climate
#if debug:
# print "Retrieved HVAC info:"
# print json.dumps(json_climate, indent=4)
tadoinsideTemp = climate['temperature']
tadohumidity = climate['humidity']
tadoOutsideTemp = outsideTemp['outsideTemperature']
tadoSunPower = outsideTemp['solarIntensity']
tadoBoilerPower = power['power']
if debug:
print tadoinsideTemp
print tadohumidity
domoticzurlinttemp = ("http://" + domoticzURL + "/json.htm?type=command¶m=udevice&idx=" + domoticzIDXinttemp + "&nvalue=0&svalue=" + str(tadoinsideTemp) + ";" + str(tadohumidity) + ";0")
base64string = base64.encodestring('%s:%s' % (domoticzusername, domoticzpassword)).replace('\n', '')
if debug:
print "Complete URL for submission to Domoticz"
print domoticzurlinttemp
request1 = urllib2.Request(domoticzurlinttemp)
request1.add_header("Authorization", "Basic %s" % base64string)
res = urllib2.urlopen(request1)
if debug:
print tadoOutsideTemp
print tadoSunPower
domoticzurltemp = ("http://" + domoticzURL + "/json.htm?type=command¶m=udevice&idx=" + domoticzIDXtemp + "&nvalue=0&svalue=" + str(tadoOutsideTemp) + ";0")
base64string = base64.encodestring('%s:%s' % (domoticzusername, domoticzpassword)).replace('\n', '')
if debug:
print "Complete URL for submission to Domoticz"
print domoticzurltemp
request2 = urllib2.Request(domoticzurltemp)
request2.add_header("Authorization", "Basic %s" % base64string)
res = urllib2.urlopen(request2)
domoticzurlsun = ("http://" + domoticzURL + "/json.htm?type=command¶m=udevice&idx=" + domoticzIDXsun + "&nvalue=0&svalue=" + str(tadoSunPower) + ";0")
base64string = base64.encodestring('%s:%s' % (domoticzusername, domoticzpassword)).replace('\n', '')
if debug:
print "Complete URL for submission to Domoticz"
print domoticzurlsun
request3 = urllib2.Request(domoticzurlsun)
request3.add_header("Authorization", "Basic %s" % base64string)
res = urllib2.urlopen(request3)
if debug:
print tadoBoilerPower
domoticzurlbpow = ("http://" + domoticzURL + "/json.htm?type=command¶m=udevice&idx=" + domoticzIDXbpow + "&nvalue=0&svalue=" + str(tadoBoilerPower) + ";0")
base64string = base64.encodestring('%s:%s' % (domoticzusername, domoticzpassword)).replace('\n', '')
if debug:
print "Complete URL for submission to Domoticz"
print domoticzurlbpow
request4 = urllib2.Request(domoticzurlbpow)
request4.add_header("Authorization", "Basic %s" % base64string)
res = urllib2.urlopen(request4)