Mercurial > code > home > repos > homeauto
comparison service/piNode/devices.py @ 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 | de541d0697b8 |
comparison
equal
deleted
inserted
replaced
1071:9a8897fac103 | 1072:34a2afdcef2f |
---|---|
144 self.lastRead = motion | 144 self.lastRead = motion |
145 | 145 |
146 return {'latest': [ | 146 return {'latest': [ |
147 (self.uri, ROOM['sees'], | 147 (self.uri, ROOM['sees'], |
148 ROOM['motion'] if motion else ROOM['noMotion']), | 148 ROOM['motion'] if motion else ROOM['noMotion']), |
149 self.recentMotionStatement(motion), | 149 ] + self.recentMotionStatements(motion), |
150 ], 'oneshot': oneshot} | 150 'oneshot': oneshot} |
151 | 151 |
152 def recentMotionStatement(self, motion): | 152 def recentMotionStatements(self, motion): |
153 if not hasattr(self, 'lastMotionTime'): | 153 if not hasattr(self, 'lastMotionTime'): |
154 self.lastMotionTime = 0 | 154 self.lastMotionTime = 0 |
155 now = time.time() | 155 now = time.time() |
156 if motion: | 156 if motion: |
157 self.lastMotionTime = now | 157 self.lastMotionTime = now |
158 recentMotion = now - self.lastMotionTime < 60 * 10 | 158 dt = now - self.lastMotionTime |
159 return (self.uri, ROOM['seesRecently'], | 159 return [(self.uri, ROOM['seesRecently'], |
160 ROOM['motion'] if recentMotion else ROOM['noMotion']) | 160 ROOM['motion'] if (dt < 60 * 10) else ROOM['noMotion']), |
161 (self.uri, ROOM['seesRecently30'], | |
162 ROOM['motion'] if (dt < 30) else ROOM['noMotion'])] | |
161 | 163 |
162 def watchPrefixes(self): | 164 def watchPrefixes(self): |
163 return [ | 165 return [ |
164 (self.uri, ROOM['sees']), | 166 (self.uri, ROOM['sees']), |
165 (self.uri, ROOM['seesRecently']), | 167 (self.uri, ROOM['seesRecently']), |
168 (self.uri, ROOM['seesRecently30']), | |
166 ] | 169 ] |
167 | 170 |
168 | 171 |
169 @register | 172 @register |
170 class RgbStrip(DeviceType): | 173 class RgbStrip(DeviceType): |