-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpolynest.py
executable file
·50 lines (40 loc) · 1.45 KB
/
polynest.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
#!/usr/bin/python
""" Nest Node Server for Polyglot
by Einstein.42(James Milne)
milne.james@gmail.com"""
from polyglot.nodeserver_api import SimpleNodeServer, PolyglotConnector
from polynest_types import NestControl
VERSION = "0.2.3"
class NestNodeServer(SimpleNodeServer):
""" Sonos Node Server """
controller = []
thermostats = []
def setup(self):
manifest = self.config.get('manifest',{})
self.controller = NestControl(self,'nestcontrol','Nest Control', True, manifest)
self.poly.logger.info("FROM Poly ISYVER: " + self.poly.isyver)
self.controller._discover()
self.update_config()
def poll(self):
pass
def long_poll(self):
if len(self.thermostats) >= 1:
for i in self.thermostats:
i.update_info()
def report_drivers(self):
if len(self.thermostats) >= 1:
for i in self.thermostats:
i.report_driver()
def main():
# Setup connection, node server, and nodes
poly = PolyglotConnector()
# Override shortpoll and longpoll timers to 5/30, once per second in unnessesary
nserver = NestNodeServer(poly, 5, 30)
poly.connect()
poly.wait_for_config()
poly.logger.info("Nest Interface version " + VERSION + " created. Initiating setup.")
nserver.setup()
poly.logger.info("Setup completed. Running Server.")
nserver.run()
if __name__ == "__main__":
main()