Mercurial > code > home > repos > homeauto
changeset 267:4685fbd208d1
'seesRecently30' in piNode
Ignore-this: 551255c6d6eb3e791c5a61eb59f2aec8
author | drewp@bigasterisk.com |
---|---|
date | Thu, 14 Apr 2016 00:14:24 -0700 |
parents | 1ae78fe6f36e |
children | 6103688dce6d |
files | service/piNode/devices.py |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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']), ]