X-Git-Url: https://git.ralfj.de/saartuer.git/blobdiff_plain/7d24ee0e013ba6d9442a4822f44818e10772e3d6..92e7d7b2f8cd46ea9043f8f3aa5f877d688130e0:/statemachine.py diff --git a/statemachine.py b/statemachine.py index 5226576..ca58e1d 100644 --- a/statemachine.py +++ b/statemachine.py @@ -30,7 +30,7 @@ ABOUTOPEN_NERVLIST = [(5, lambda : play_sound("flipswitch")), (5, lambda:play_so # Timeout we wait after the switch was switched to "Closed", until we assume nobody will open the door and we just lock it # ALso the time we wait after the door was opend, till we assume something went wrong and start nerving -LEAVE_TIMEOUT = 4 +LEAVE_TIMEOUT = 20 # play_sound constants SOUNDS_DIRECTORY = "/opt/tuer/sounds/" @@ -116,6 +116,9 @@ class StateMachine(): if not self.pins().door_locked: logger.info("Door unlocked, space is about to open") return StateMachine.StateAboutToOpen(self.state_machine) + if not self.old_pins().space_active and self.pins().space_active: + logger.info("Space toggled to active while it was closed - unlocking the door") + return StateMachine.StateUnlocking(self.state_machine) return super().handle_pins_event() class AbstractUnlockedState(AbstractNonStartState): @@ -127,7 +130,6 @@ class StateMachine(): if self.pins().door_locked: logger.info("Door locked, closing space") if self.pins().space_active: - # FIXME the same state can be reached by first locking the door, and then activating the space. What to do then? logger.warning("StateMachine: door manually locked, but space switch is still on - going to StateZu") play_sound("manual_lock") return StateMachine.StateZu(self.state_machine)