Skip to content

Commit

Permalink
Merge pull request #77 from Mimoja/main
Browse files Browse the repository at this point in the history
real_airtag: read identifier and model from plist for later resolving
  • Loading branch information
malmeloo authored Sep 18, 2024
2 parents f1cb07e + 4352099 commit 4e75e73
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions findmy/accessory.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ def keys_between(self, start: int | datetime, end: int | datetime) -> set[KeyPai
class FindMyAccessory(RollingKeyPairSource):
"""A findable Find My-accessory using official key rollover."""

def __init__(
def __init__( # noqa: PLR0913
self,
master_key: bytes,
skn: bytes,
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.
Expand All @@ -91,6 +93,28 @@ def __init__(
)

self._name = name
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
Expand Down Expand Up @@ -167,7 +191,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]):
Expand Down

0 comments on commit 4e75e73

Please sign in to comment.