From 8ef5774cdaf63a00bd1c2c354e725d70931088a4 Mon Sep 17 00:00:00 2001 From: Mimoja Date: Tue, 17 Sep 2024 01:43:21 -0600 Subject: [PATCH 1/3] real_airtag: read identifier and model from plist for later resolving Signed-off-by: Mimoja --- findmy/accessory.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/findmy/accessory.py b/findmy/accessory.py index 230239a..50740f7 100644 --- a/findmy/accessory.py +++ b/findmy/accessory.py @@ -65,6 +65,7 @@ def keys_between(self, start: int | datetime, end: int | datetime) -> set[KeyPai class FindMyAccessory(RollingKeyPairSource): """A findable Find My-accessory using official key rollover.""" + # pylint: disable=too-many-arguments def __init__( self, master_key: bytes, @@ -72,6 +73,8 @@ def __init__( sks: bytes, paired_at: datetime, name: str | None = None, + model: str | None = None, + identifier: str | None = None, ) -> None: """ Initialize a FindMyAccessory. These values are usually obtained during pairing. @@ -91,6 +94,8 @@ def __init__( ) self._name = name + self._model = model + self._identifier = identifier @property @override @@ -167,7 +172,10 @@ def from_plist(cls, plist: IO[bytes]) -> FindMyAccessory: # "Paired at" timestamp (UTC) paired_at = device_data["pairingDate"].replace(tzinfo=timezone.utc) - return cls(master_key, skn, sks, paired_at) + model = device_data["model"] + identifier = device_data["identifier"] + + return cls(master_key, skn, sks, paired_at, None, model, identifier) class AccessoryKeyGenerator(KeyGenerator[KeyPair]): From 42aba786094e6c26c1e1fda72d3996e15ab06674 Mon Sep 17 00:00:00 2001 From: "Mike A." Date: Tue, 17 Sep 2024 23:49:18 +0200 Subject: [PATCH 2/3] chore: Fix linter --- findmy/accessory.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/findmy/accessory.py b/findmy/accessory.py index 50740f7..16840ae 100644 --- a/findmy/accessory.py +++ b/findmy/accessory.py @@ -65,8 +65,7 @@ def keys_between(self, start: int | datetime, end: int | datetime) -> set[KeyPai class FindMyAccessory(RollingKeyPairSource): """A findable Find My-accessory using official key rollover.""" - # pylint: disable=too-many-arguments - def __init__( + def __init__( # noqa: PLR0913 self, master_key: bytes, skn: bytes, From d25a7292a58af552c9fc1d2d639ec38f6e12d4b5 Mon Sep 17 00:00:00 2001 From: "Mike A." Date: Wed, 18 Sep 2024 00:01:06 +0200 Subject: [PATCH 3/3] accessory: Add more properties to retrieve values --- findmy/accessory.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/findmy/accessory.py b/findmy/accessory.py index 16840ae..f704d7e 100644 --- a/findmy/accessory.py +++ b/findmy/accessory.py @@ -96,6 +96,26 @@ def __init__( # noqa: PLR0913 self._model = model self._identifier = identifier + @property + def paired_at(self) -> datetime: + """Date and time at which this accessory was paired with an Apple account.""" + return self._paired_at + + @property + def name(self) -> str | None: + """Name of this accessory.""" + return self._name + + @property + def model(self) -> str | None: + """Model string of this accessory, as provided by the manufacturer.""" + return self._model + + @property + def identifier(self) -> str | None: + """Internal identifier of this accessory.""" + return self._identifier + @property @override def interval(self) -> timedelta: