-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnest_temp.py
More file actions
executable file
·37 lines (30 loc) · 843 Bytes
/
Copy pathnest_temp.py
File metadata and controls
executable file
·37 lines (30 loc) · 843 Bytes
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
import nest_thermostat
import influxdb
nest = nest_thermostat.Nest("nick@shoresmedia.com", "4118nick")
nest.login()
nest.get_status()
temp = nest.temp_out(nest.status["shared"][nest.serial]["current_temperature"])
mode = nest.status["shared"][nest.serial]["hvac_ac_state"]
target = nest.temp_out(nest.status["shared"][nest.serial]["target_temperature"])
if mode is True:
# print("Mode is cool")
finalmode = 1
else:
# print("Mode is not cool")
finalmode = 0
from influxdb import client as influxdb
db = influxdb.InfluxDBClient("localhost", 8086, "", "", "cacti2")
data = [
{
"tags": {
"host": "nest",
},
"measurement": "temp",
"fields": {
"Float_value": temp,
"mode2": finalmode,
"target": target
}
}
]
db.write_points(data)