1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00

update nuki state handling

update state handling so that manual state changes of the nuki (key or
button press) are reflected to the internal doorlock state. Refactor
general state handling to support this

Signed-off-by: Thomas Schmid <tom@lfence.de>
This commit is contained in:
Thomas 2024-01-03 21:10:07 +01:00
parent 03e27930ce
commit e7955cab59
3 changed files with 6 additions and 6 deletions

View File

@ -37,7 +37,7 @@ __status__ = 'Development'
__maintainer__ = 'Ralf Ramsauer'
__version__ = '0.0'
log_level = logging.DEBUG
log_level = logging.INFO
date_fmt = '%Y-%m-%d %H:%M:%S'
log_fmt = '%(asctime)-15s %(levelname)-8s %(message)s'
log = logging.getLogger()

View File

@ -77,7 +77,7 @@ class DoorHandler:
raise RuntimeError
self.backend.set_state(self.state)
self.backend.register_state_changed_handler(self.update_state)
self.backend.register_state_changed_handler(self.backend_state_change_handler)
def backend_state_change_handler(self, new_state):
self.update_state(self.state, new_state, DoorlockResponse.Success)
@ -121,7 +121,7 @@ class DoorHandler:
elif state == DoorState.Open:
err = self.open()
self.update_state(old_state, self.state, err)
self.update_state(old_state, state, err)
return err

View File

@ -145,15 +145,15 @@ class NukiBridge(DoorlockBackend):
continue
if not NukiBridgeDevice.compare_device_state(dev_state, last_dev_state):
log.debug(f"Nuki changed state: {dev_state}")
log.info(f"Nuki changed state: {dev_state}")
if self.current_state != DoorState.Closed and dev_state["stateName"] == "locked":
self.current_state = DoorState.Closed
self.state_change_callback(self.current_state, DoorlockResponse.Success)
self.state_change_callback(self.current_state)
if self.current_state != DoorState.Open and dev_state["stateName"] == "unlocked":
self.current_state = DoorState.Open
self.state_change_callback(self.current_state, DoorlockResponse.Success)
self.state_change_callback(self.current_state)
last_dev_state = dev_state
time.sleep(10)