# HG changeset patch # User drewp # Date 1460618064 25200 # Node ID 34a2afdcef2f96aef11ed9b2d386431631c69003 # Parent 9a8897fac103de8c24dd0fe864292e31899f5374 'seesRecently30' in piNode Ignore-this: 551255c6d6eb3e791c5a61eb59f2aec8 darcs-hash:481643bc1a75c11d944e651a88422249a7a8fd92 diff -r 9a8897fac103 -r 34a2afdcef2f service/piNode/devices.py --- a/service/piNode/devices.py Thu Apr 14 00:13:06 2016 -0700 +++ b/service/piNode/devices.py Thu Apr 14 00:14:24 2016 -0700 @@ -146,23 +146,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']), ]