diff --git a/pyschlage/lock.py b/pyschlage/lock.py index 16e9c44..054fb0e 100644 --- a/pyschlage/lock.py +++ b/pyschlage/lock.py @@ -274,6 +274,12 @@ def last_changed_by( if self.lock_state_metadata.action_type == "thumbTurn": return "thumbturn" + if self.lock_state_metadata.action_type == "AppleHomeNFC": + user = self.users.get(self.lock_state_metadata.uuid) + if user: + 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}" diff --git a/tests/test_lock.py b/tests/test_lock.py index 181f213..3e551ef 100644 --- a/tests/test_lock.py +++ b/tests/test_lock.py @@ -333,6 +333,16 @@ 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_nfc_device(self, wifi_lock: Lock) -> None: + wifi_lock.lock_state_metadata.action_type = "AppleHomeNFC" + wifi_lock.lock_state_metadata.uuid = "user-uuid" + assert wifi_lock.last_changed_by() == "apple nfc device - asdf" + + def test_nfc_device_no_uuid(self, wifi_lock: Lock) -> None: + wifi_lock.lock_state_metadata.action_type = "AppleHomeNFC" + wifi_lock.lock_state_metadata.uuid = None + assert wifi_lock.last_changed_by() == "apple nfc device" + def test_keypad(self, wifi_lock: Lock) -> None: wifi_lock.lock_state_metadata.action_type = "accesscode" wifi_lock.lock_state_metadata.name = "secret code"