# HG changeset patch # User drewp # Date 1460618095 25200 # Node ID 054fccde9a49ea6e1c01c377584df35822357325 # Parent 34a2afdcef2f96aef11ed9b2d386431631c69003 'seesRecently30' in arduinoNode Ignore-this: f89899de0374c9f2b2606d331213465 darcs-hash:1215e55dde94e1afa6c51355897ba57f499a7966 diff -r 34a2afdcef2f -r 054fccde9a49 service/arduinoNode/devices.py --- a/service/arduinoNode/devices.py Thu Apr 14 00:14:24 2016 -0700 +++ b/service/arduinoNode/devices.py Thu Apr 14 00:14:55 2016 -0700 @@ -205,23 +205,26 @@ return {'latest': [ (self.uri, ROOM['sees'], ROOM['motion'] if motion else ROOM['noMotion']), - self.recentMotionStatement(motion), - ], 'oneshot': oneshot} + ] + self.recentMotionStatements(motion), + 'oneshot': oneshot} - def recentMotionStatement(self, motion): + def recentMotionStatements(self, motion): if not hasattr(self, 'lastMotionTime'): self.lastMotionTime = 0 now = time.time() if motion: self.lastMotionTime = now - recentMotion = now - self.lastMotionTime < 60 * 10 - return (self.uri, ROOM['seesRecently'], - ROOM['motion'] if recentMotion else ROOM['noMotion']) + dt = now - self.lastMotionTime + return [(self.uri, ROOM['seesRecently'], + ROOM['motion'] if (dt < 60 * 10) else ROOM['noMotion']), + (self.uri, ROOM['seesRecently30'], + ROOM['motion'] if (dt < 30) else ROOM['noMotion'])] def watchPrefixes(self): return [ (self.uri, ROOM['sees']), (self.uri, ROOM['seesRecently']), + (self.uri, ROOM['seesRecently30']), ] @register