Mercurial > code > home > repos > homeauto
comparison service/wifi/wifi.py @ 1369:42f4fed9cd25
no more immediateUpdate since we push patch events now. and the code was broken for py3 anyway
Ignore-this: 54edfd3885f749aa5ef3be2051c2f40f
darcs-hash:0f1ccb011e9cf29bf9e2389de3833cbda3550631
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sun, 05 May 2019 17:09:12 -0700 |
parents | b287950fbcf4 |
children | 517cbb905d4c |
comparison
equal
deleted
inserted
replaced
1368:140d8d419cf0 | 1369:42f4fed9cd25 |
---|---|
31 from scrape import Wifi, SeenNode | 31 from scrape import Wifi, SeenNode |
32 | 32 |
33 AST = Namespace("http://bigasterisk.com/") | 33 AST = Namespace("http://bigasterisk.com/") |
34 DEV = Namespace("http://projects.bigasterisk.com/device/") | 34 DEV = Namespace("http://projects.bigasterisk.com/device/") |
35 ROOM = Namespace("http://projects.bigasterisk.com/room/") | 35 ROOM = Namespace("http://projects.bigasterisk.com/room/") |
36 reasoning = "http://bang:9071/" | |
37 | 36 |
38 class Index(PrettyErrorHandler, cyclone.web.RequestHandler): | 37 class Index(PrettyErrorHandler, cyclone.web.RequestHandler): |
39 def get(self): | 38 def get(self): |
40 age = time.time() - self.settings.poller.lastPollTime | 39 age = time.time() - self.settings.poller.lastPollTime |
41 if age > 10: | 40 if age > 10: |
133 for addr in newWithSignal: | 132 for addr in newWithSignal: |
134 points.append(self.influxPoint(now, addr.mac.lower(), 1)) | 133 points.append(self.influxPoint(now, addr.mac.lower(), 1)) |
135 | 134 |
136 influx.write_points(points, time_precision='s') | 135 influx.write_points(points, time_precision='s') |
137 self.lastWithSignal = newWithSignal | 136 self.lastWithSignal = newWithSignal |
138 if actions: # this doesn't currently include signal strength changes | |
139 fetch(reasoning + "immediateUpdate", | |
140 method='PUT', | |
141 timeout=2, | |
142 headers={'user-agent': ['wifi']}).addErrback(log.warn) | |
143 self.lastAddrs = newAddrs | 137 self.lastAddrs = newAddrs |
144 self.lastPollTime = now | 138 self.lastPollTime = now |
145 | 139 |
146 self.updateGraph(masterGraph) | 140 self.updateGraph(masterGraph) |
147 | 141 |
148 def influxPoint(self, now, address, value): | 142 def influxPoint(self, now, address, value): |
149 return { | 143 return { |
150 'measurement': 'presence', | 144 'measurement': 'presence', |
151 'tags': {'sensor': 'wifi', 'address': address,}, | 145 'tags': {'sensor': 'wifi', 'address': address,}, |
152 'fields': {'value': value}, | 146 'fields': {'value': value}, |