findmy.accessory#

Module to interact with accessories that implement Find My.

Accessories could be anything ranging from AirTags to iPhones.

Attributes#

Classes#

FindMyAccessoryMapping

JSON mapping representing state of a FindMyAccessory instance.

RollingKeyPairSource

A class that generates rolling :meth:`KeyPair`s.

FindMyAccessory

A findable Find My-accessory using official key rollover.

AccessoryKeyGenerator

KeyPair generator. Uses the same algorithm internally as FindMy accessories do.

Module Contents#

findmy.accessory.logger#
class findmy.accessory.FindMyAccessoryMapping#

Bases: TypedDict

Inheritance diagram of findmy.accessory.FindMyAccessoryMapping

JSON mapping representing state of a FindMyAccessory instance.

type: Literal['accessory']#
master_key: str#
skn: str#
sks: str#
paired_at: str#
name: str | None#
model: str | None#
identifier: str | None#
class findmy.accessory.RollingKeyPairSource#

Bases: abc.ABC

Inheritance diagram of findmy.accessory.RollingKeyPairSource

A class that generates rolling :meth:`KeyPair`s.

property interval: datetime.timedelta#
Abstractmethod:

KeyPair rollover interval.

abstractmethod keys_at(ind: int | datetime.datetime) set[findmy.keys.KeyPair]#

Generate potential key(s) occurring at a certain index or timestamp.

keys_between(start: int, end: int) set[findmy.keys.KeyPair]#
keys_between(start: datetime.datetime, end: datetime.datetime) set[findmy.keys.KeyPair]

Generate potential key(s) occurring between two indices or timestamps.

class findmy.accessory.FindMyAccessory(*, master_key: bytes, skn: bytes, sks: bytes, paired_at: datetime.datetime, name: str | None = None, model: str | None = None, identifier: str | None = None)#

Bases: RollingKeyPairSource, findmy.util.abc.Serializable[FindMyAccessoryMapping]

Inheritance diagram of findmy.accessory.FindMyAccessory

A findable Find My-accessory using official key rollover.

property master_key: bytes#

The private master key.

property skn: bytes#

The SKN for the primary key.

property sks: bytes#

The SKS for the secondary key.

property paired_at: datetime.datetime#

Date and time at which this accessory was paired with an Apple account.

property name: str | None#

Name of this accessory.

property model: str | None#

Model string of this accessory, as provided by the manufacturer.

property identifier: str | None#

Internal identifier of this accessory.

property interval: datetime.timedelta#

Official FindMy accessory rollover interval (15 minutes).

keys_at(ind: int | datetime.datetime) set[findmy.keys.KeyPair]#

Get the potential primary and secondary keys active at a certain time or index.

classmethod from_plist(plist: str | pathlib.Path | dict | bytes | IO[bytes], *, name: str | None = None) FindMyAccessory#

Create a FindMyAccessory from a .plist file dumped from the FindMy app.

to_json(path: str | pathlib.Path | None = None, /) FindMyAccessoryMapping#

Export the current state of the object as a JSON-serializable dictionary.

If an argument is provided, the output will also be written to that file.

The output of this method is guaranteed to be JSON-serializable, and passing the return value of this function as an argument to Serializable.from_json() will always result in an exact copy of the internal state as it was when exported.

You are encouraged to save and load object states to and from disk whenever possible, to prevent unnecessary API calls or otherwise unexpected behavior.

classmethod from_json(val: str | pathlib.Path | FindMyAccessoryMapping, /) FindMyAccessory#

Restore state from a previous Closable.to_json() export.

If given a str or Path, it must point to a json file from Serializable.to_json(). Otherwise, it should be the Mapping itself.

See Serializable.to_json() for more information.

class findmy.accessory.AccessoryKeyGenerator(master_key: bytes, initial_sk: bytes, key_type: findmy.keys.KeyType = KeyType.UNKNOWN)#

Bases: findmy.keys.KeyGenerator[findmy.keys.KeyPair]

Inheritance diagram of findmy.accessory.AccessoryKeyGenerator

KeyPair generator. Uses the same algorithm internally as FindMy accessories do.

property master_key: bytes#

The private master key.

property initial_sk: bytes#

The initial secret key.

property key_type: findmy.keys.KeyType#

The type of key this generator produces.

__iter__() findmy.keys.KeyGenerator#
__next__() findmy.keys.KeyPair#
__getitem__(val: int) findmy.keys.KeyPair#
__getitem__(val: slice) collections.abc.Generator[findmy.keys.KeyPair, None, None]