A python script to get geodata from a person entity in Home Assistant to Immich
- Python 99.1%
- Dockerfile 0.9%
|
All checks were successful
Build, Tag & Release / build-and-release (push) Successful in 2m13s
Reviewed-on: #26 |
||
|---|---|---|
| .forgejo/workflows | ||
| tests | ||
| .env-template | ||
| .gitignore | ||
| Containerfile | ||
| main.py | ||
| README.md | ||
| renovate.json | ||
| requirements.txt | ||
Homeassistant I mmich Geotagger
This is a small Python CLI tool to backfill missing GPS metadata on your Immich photo library by leveraging Home Assistant’s 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, you’d 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