|
@@ -290,6 +290,7 @@ class leyk(object):
|
290
|
290
|
self._task_1s = task.periodic(1, self.task_1s)
|
291
|
291
|
self._task_1s.run()
|
292
|
292
|
self.sm_mode.register_state_change_callback(self.sm_mode.STATE_MANUAL, None, self._queue.clean_queue)
|
|
293
|
+ self.sm_day_state.register_state_change_callback(None, None, self.clean_queue)
|
293
|
294
|
self.sm_day_state.register_state_change_callback(self.sm_day_state.STATE_SLEEP, None, self.sm_day_state.report_sunset_sunrise)
|
294
|
295
|
self.sm_day_state.register_state_change_callback(self.sm_day_state.STATE_SLEEP, None, self.fill_sleep_queue)
|
295
|
296
|
self.sm_day_state.register_state_change_callback(self.sm_day_state.STATE_SUNRISE, None, self.sm_day_state.report_sunset_sunrise)
|
|
@@ -413,6 +414,11 @@ class leyk(object):
|
413
|
414
|
time.sleep(0.2)
|
414
|
415
|
cnt += 1
|
415
|
416
|
|
|
417
|
+ def clean_queue(self):
|
|
418
|
+ if self._queue.qsize() > 0:
|
|
419
|
+ logger.info('Cleaning up remaining %d elements from queue', self._queue.qsize())
|
|
420
|
+ self._queue.clean_queue()
|
|
421
|
+
|
416
|
422
|
def fill_wake_queue(self):
|
417
|
423
|
no_delay = self.sm_day_state.previous_state_was(self.sm_day_state.STATE_IDLE)
|
418
|
424
|
# WAKE
|