X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=track-presence.py;h=532f5e0ae00e7e13ef181ae0aa8855ef87ae1c14;hb=cd3f667ea477e15aa1ac14fa6b56f08164eed850;hp=77784069312ef6f255e2124f04a315152f5541cd;hpb=d4dafceb7708db89f5261edac11a108343fbc538;p=svn42.git diff --git a/track-presence.py b/track-presence.py index 7778406..532f5e0 100755 --- a/track-presence.py +++ b/track-presence.py @@ -302,6 +302,7 @@ class StatusTracker: #(threading.Thread): self.presence_notify_lock=threading.Lock() #timer self.timer=None + self.timer_timeout=0 def doorOpen(self,who,how): self.uwscfg.checkConfigUpdates() @@ -364,12 +365,13 @@ class StatusTracker: #(threading.Thread): def checkAgainIn(self, sec): - #~ if not self.timer is None: - #~ logging.debug("checkAgainIn: canceled previous running Timer") - #~ self.timer.cancel() - logging.debug("checkAgainIn: starting Timer with timeout %fs" % sec) - self.timer=threading.Timer(sec, self.checkPresenceStateChangeAndNotify) - self.timer.start() + if self.timer_timeout < time.time(): + logging.debug("checkAgainIn: starting Timer with timeout %fs" % sec) + self.timer=threading.Timer(sec, self.checkPresenceStateChangeAndNotify) + self.timer.start() + self.timer_timeout = time.time() + sec + else: + logging.debug("checkAgainIn: not starting timer, already one scheduled in %fs" % (time.time() - self.timer_timeout)) def somebodyPresent(self): with self.lock: @@ -381,10 +383,9 @@ class StatusTracker: #(threading.Thread): else: return False elif self.door_manual_switch_used and time.time() - self.last_door_operation_unixts <= float(self.uwscfg.tracker_sec_wait_after_manual_close): - #start timer, checkPresenceStateChangeAndNotify after tracker_sec_wait_movement self.checkAgainIn(float(self.uwscfg.tracker_sec_wait_after_manual_close)) + return self.last_somebody_present_result elif not self.door_manual_switch_used and time.time() - self.last_door_operation_unixts <= float(self.uwscfg.tracker_sec_necessary_to_move_through_door): - #start timer, checkPresenceStateChangeAndNotify after tracker_sec_wait_movement self.checkAgainIn(float(self.uwscfg.tracker_sec_necessary_to_move_through_door)) return self.last_somebody_present_result elif self.last_movement_unixts > self.last_door_operation_unixts - float(self.uwscfg.tracker_sec_movement_before_manual_switch) and self.door_manual_switch_used: