A python script to get geodata from a person entity in Home Assistant to Immich
  • Python 99.1%
  • Dockerfile 0.9%
Find a file
fredrik 15bee9c2e8
All checks were successful
Build, Tag & Release / build-and-release (push) Successful in 2m13s
Merge pull request 'Update all Python dependencies' (#26) from renovate/all-python-dependencies into main
Reviewed-on: #26
2026-03-02 13:01:21 +01:00
.forgejo/workflows Update python Docker tag to v3.14 2026-02-05 12:21:00 +00:00
tests Full send openAI tests++ 2025-05-21 09:31:44 +02:00
.env-template added webgui and SSO 2026-02-27 15:39:53 +01:00
.gitignore Full send openAI tests++ 2025-05-21 09:31:44 +02:00
Containerfile added webgui and SSO 2026-02-27 15:39:53 +01:00
main.py added webgui and SSO 2026-02-27 15:39:53 +01:00
README.md webhook option 2025-06-05 12:41:47 +02:00
renovate.json Migrate config renovate.json 2025-05-19 06:39:49 +00:00
requirements.txt Update all Python dependencies 2026-03-02 08:02:01 +00:00

Homeassistant I mmich Geotagger

This is a small Python CLI tool to backfill missing GPS metadata on your Immich photo library by leveraging Home Assistants location history. Photos taken without embedded GPS data are matched to the nearest HA location event in a configurable time window and updated via the Immich API.


Features

  • Fetches your Home Assistant device tracker history for the past N days
  • Searches Immich for photos missing GPS data (with optional camera-model filter)
  • Finds the closest location point within a configurable time window
  • Tags photos in Immich with latitude, longitude, and original timestamp
  • Dry-run mode to preview actions without making any changes
  • Automatic retry and rate-limit handling
  • Run continuously at configurable intervals (--interval or INTERVAL env var)
  • HTTP webhook endpoint for triggering runs-on-demand (--webhook or WEBHOOK env var)

Prerequisites

  • Python 3.8+
  • A running Home Assistant instance with a long-lived access token
  • An Immich server and API token

Testing

This project uses pytest for unit testing. To install pytest and run the tests, run:

pip install pytest
pytest

Flags:

--days-back <N> lets you specify how many days into the past to search for GPS-missing photos (defaults to the DAYS_BACK setting in your .env, usually 7).
--model "<camera model>" restricts tagging to photos shot with the given EXIF model (if you leave this off, all cameras are considered).
--dry-run will print out which photos would be tagged without actually sending any updates to Immich, so you can preview changes safely.
--interval <interval>   run at set intervals, e.g. '1h', '30m', '1d' (or via INTERVAL env var)
--webhook               start HTTP server listening for POST /run to trigger tagging (or via WEBHOOK env var)
--host <host>           webhook server host (default 0.0.0.0)
--port <port>           webhook server port (default 5000)

For example, to preview how many Nikon Z6 photos from the last 3 days would be backfilled, youd run:

python main.py --days-back 3 --model "NIKON Z6" --dry-run

You can also schedule or run as a webhook server:

# Run every hour:
python main.py --interval 1h

# Start webhook server on default port (5000):
python main.py --webhook