fjxmlzn / FindMyHistory

Track your Apple devices and look up their past location, battery levels, and more
MIT License
308 stars 34 forks source link

FindMyHistory for Apple Devices

Apple's FindMy app only shows the current location and information of your Apple devices. Want to track your Apple devices and look up their past location, battery levels, and more? FindMyHistory can help you!

How to use it

The only thing you need is an Apple computer (e.g., MacBook (Air/Pro), iMac), which is running macOS Ventura or earlier (<=13.7) with your Apple ID logged in and with Python3 installed. To use FindMyHistory, you only need to follow the three steps:

git clone https://github.com/fjxmlzn/FindMyHistory.git
cd FindMyHistory
pip3 install -r requirements.txt
python3 main.py

After that, FindMyHistory keeps logging the information of your Apple devices as long as FindMy app is active.

In the Terminal, FindMyHistory shows the list of your Apple devices with their most recent update time, and the number of history records: alt text

In log folder you can find all the history information of your devices. The logs of each day will be grouped in a subfolder. In the subfolders, you can find the logs in CSV files for each of your Apple devices, including locations, battery levels, and so on.

Advanced functions

You can configure the refresh time, log folder, and many more in FindMyHistory. To look up all the options, you can run python3 main.py --help:

python3 main.py --help
usage: main.py [-h] [--refresh REFRESH] [--name_keys NAME_KEYS] [--store_keys STORE_KEYS] [--timestamp_key TIMESTAMP_KEY]
               [--log_folder LOG_FOLDER] [--no_date_folder] [--log_location LOG_LOCATION] [--influx_host INFLUX_HOST]
               [--influx_token INFLUX_TOKEN] [--influx_org INFLUX_ORG] [--influx_bucket INFLUX_BUCKET]

Record Apple findmy history for Apple devices.

options:
  -h, --help            show this help message and exit
  --refresh REFRESH     Refresh interval (ms).
  --name_keys NAME_KEYS
                        Keys used to construct the filename for each device.
  --store_keys STORE_KEYS
                        Keys to log.
  --timestamp_key TIMESTAMP_KEY
                        The key of timestamp in findmy JSON
  --log_folder LOG_FOLDER
                        The path of log folder.
  --no_date_folder      By default, the logs of each day will be saved in a separated folder. Use this option to turn it off.
  --log_location LOG_LOCATION
                        Location to log findmy data. Default: local
  --influx_host INFLUX_HOST
                        InfluxDB Host (required when --log_location is set to influx)
  --influx_token INFLUX_TOKEN
                        InfluxDB Token (required when --log_location is set to influx)
  --influx_org INFLUX_ORG
                        InfluxDB Organization (required when --log_location is set to influx)
  --influx_bucket INFLUX_BUCKET
                        InfluxDB Bucket (required when --log_location is set to influx)

Alternate Logging Locations

By default, FindMyHistory will log locally to a CSV file on your machine. Alternatively, you can choose to log to other remote locations with the --log_location flag.

While FindMy is running, it stores the information of your devices in temporary files ~/Library/Caches/com.apple.findmy.fmipcore/Items.data ~/Library/Caches/com.apple.findmy.fmipcore/Devices.data in JSON format. FindMyHistory periodically reads these files and stores a new record for each device if there is an update.

Contributing

If you find bugs/problems or want to add more features to this library, feel free to submit issues or make pull requests.