diff --git a/pyschlage/lock.py b/pyschlage/lock.py index 27d9e9c..d3a7588 100644 --- a/pyschlage/lock.py +++ b/pyschlage/lock.py @@ -255,24 +255,22 @@ def last_changed_by( if self.lock_state_metadata is None: return None - if self.lock_state_metadata.action_type == "thumbTurn": - return "thumbturn" - + user_suffix = "" uuid = self.lock_state_metadata.uuid - - if self.lock_state_metadata.action_type == "AppleHomeNFC": - if uuid is not None and (user := self.users.get(uuid)): - return f"apple nfc device - {user.name}" - return "apple nfc device" - - if self.lock_state_metadata.action_type == "accesscode": - return f"keypad - {self.lock_state_metadata.name}" - - if self.lock_state_metadata.action_type == "virtualKey": - if uuid is not None and (user := self.users.get(uuid)): - return f"mobile device - {user.name}" - return "mobile device" - + if uuid is not None and (user := self.users.get(uuid)): + user_suffix = f" - {user.name}" + + match self.lock_state_metadata.action_type: + case "thumbTurn": + return "thumbturn" + case "1touchLocking": + return "1-touch locking" + case "accesscode": + return f"keypad - {self.lock_state_metadata.name}" + case "AppleHomeNFC": + return f"apple nfc device{user_suffix}" + case "virtualKey": + return f"mobile device{user_suffix}" return "unknown" def keypad_disabled(self, logs: list[LockLog] | None = None) -> bool: diff --git a/tests/test_lock.py b/tests/test_lock.py index 6b69fde..74b26aa 100644 --- a/tests/test_lock.py +++ b/tests/test_lock.py @@ -458,6 +458,11 @@ def test_thumbturn(self, wifi_lock: Lock) -> None: wifi_lock.lock_state_metadata.action_type = "thumbTurn" assert wifi_lock.last_changed_by() == "thumbturn" + def test_one_touch_locking(self, wifi_lock: Lock) -> None: + assert wifi_lock.lock_state_metadata is not None + wifi_lock.lock_state_metadata.action_type = "1touchLocking" + assert wifi_lock.last_changed_by() == "1-touch locking" + def test_nfc_device(self, wifi_lock: Lock) -> None: assert wifi_lock.lock_state_metadata is not None wifi_lock.lock_state_metadata.action_type = "AppleHomeNFC"