Skip to content

Fix accessory key drift - #160

Merged
malmeloo merged 15 commits into
mainfrom
fix/accessory-key-drift
Sep 7, 2025
Merged

malmeloo merged 15 commits into
mainfrom
fix/accessory-key-drift

Conversation

@malmeloo

@malmeloo malmeloo commented Aug 7, 2025

Copy link
Copy Markdown
Owner

closes #90

pajowu and others added 5 commits April 15, 2025 15:23
Sometimes the key generation diverges for example if the accessory has no power. FindMy solves this be re-aligning the key generation if a btle connection is established. FindMy.app stores there alignment records in the `KeyAlignmentRecord` directory.

This PR extends the FindMyAccessory class to read those records during `from_plist`-generation and re-sync the key generation by this
Add option to align FindMyAccessories key generation
@malmeloo
malmeloo force-pushed the fix/accessory-key-drift branch from 1bdd4cd to f771ad9 Compare August 7, 2025 19:07
BREAKING: due to fundamental issues with Apple's API, this commit also DEPRECATES the `fetch_[last_]reports` methods on Apple account instances. It has been replaced by a method named `fetch_location`, which only returns a single location report (the latest one) and does not support setting a date range.
@malmeloo

malmeloo commented Sep 4, 2025

Copy link
Copy Markdown
Owner Author

Current status: a key alignment algorithm has been implemented that will automatically find correct alignment parameters when attempting to fetch the location of an accessory. If your accessory is unaligned, the first fetch might take some time, as the library will iterate through a bunch of different indices in order to find the correct values. After the first fetch, the values will be stored in the accessory object, and the next fetch after that will immediately use the correct values, meaning that only ~3 API requests are necessary in order to obtain a location. It is possible to further optimize this number in the future. Additionally, the in-library accessory importer has been updated to synchronize its initial alignment values with the ones that MacOS is keeping track of, meaning that 'new' accessories will immediately benefit from the aforementioned speed boost. This will also survive restarts, but only if the accessory object is properly (de)serialized to and from disk. New example code will show how to do that.

This change comes with several API changes and deprecations, so it is currently not recommended to be used (yet). I will work on fixing any issues and updating the example scripts soon.

@malmeloo
malmeloo marked this pull request as ready for review September 7, 2025 22:50
@malmeloo
malmeloo merged commit d7af926 into main Sep 7, 2025
@malmeloo
malmeloo deleted the fix/accessory-key-drift branch September 7, 2025 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some official/compatible AirTags don't work

2 participants