Mercurial > code > home > repos > homeauto
diff service/dpms/dpms_service.py @ 723:b87b6e9cedb2
whitespace
Ignore-this: c727f388f197a6fae88595fe6d455c7d
author | drewp@bigasterisk.com |
---|---|
date | Wed, 05 Feb 2020 00:29:13 -0800 |
parents | a93fbf0d0daa |
children | d6996175ea78 |
line wrap: on
line diff
--- a/service/dpms/dpms_service.py Wed Feb 05 00:23:06 2020 -0800 +++ b/service/dpms/dpms_service.py Wed Feb 05 00:29:13 2020 -0800 @@ -59,7 +59,7 @@ def get(self): self.set_header('content-type', 'text/plain') self.write(getMonitorState()) - + def put(self): body = self.request.body.strip() if body in ['on', 'off']: @@ -73,7 +73,7 @@ self.lastSent = None self.lastSentTime = 0 task.LoopingCall(self.poll).start(5) - + def poll(self): now = int(time.time()) state = getMonitorState() @@ -84,7 +84,7 @@ URIRef("http://bigasterisk.com/host/%s/monitor" % host), ROOM['powerStateMeasured'], ROOM[getMonitorState()]) - + if state != self.lastSent or (now > self.lastSentTime + 3600): influx.write_points([ {'measurement': 'power', @@ -92,13 +92,13 @@ 'fields': {'value': 1 if state == 'on' else 0}, 'time': now }], time_precision='s') - + self.lastSent = state self.lastSentTime = now masterGraph = PatchableGraph() poller = Poller() - + reactor.listenTCP(9095, cyclone.web.Application([ (r'/', Root), (r'/monitor', Monitor), @@ -107,5 +107,3 @@ ]), interface='::') reactor.run() - -