changeset 1072:34a2afdcef2f

'seesRecently30' in piNode Ignore-this: 551255c6d6eb3e791c5a61eb59f2aec8 darcs-hash:481643bc1a75c11d944e651a88422249a7a8fd92
author drewp <drewp@bigasterisk.com>
date Thu, 14 Apr 2016 00:14:24 -0700
parents 9a8897fac103
children 054fccde9a49
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']),
         ]