Skip to content

Leave-by times from Apple Maps travel times (K660) - #29

Merged
mgilardi merged 1 commit into
mainfrom
feat/ek-eta
Nov 16, 2026
Merged

mgilardi merged 1 commit into
mainfrom
feat/ek-eta

Conversation

@mgilardi

Copy link
Copy Markdown
Collaborator

K660. Owner (Simon chat, 2026-11-15), on where travel times should come from: "yes but i already use the apple cal app and add all my accounts to that..."

What it adds

  • ek eta: Apple Maps travel time through MapKit MKDirections.calculateETA, with no key or account. Takes an address, a place name (falls back to MKLocalSearch when the address lookup doesn't know it) or LAT,LON for both ends. --arrive sets the arrival time so Apple predicts traffic. --transport car|walk|transit. Nothing is stored.
  • ek events now includes geo (the event's map location) when Calendar has one, so most lookups skip the address search.
  • engine/tools/eta.py day [--date] [--json]: leave-by times for the day's events with a place.
    • Skips all-day, declined and online events (links, "online", "call") and ones at the starting point.
    • Lookup budget: one lookup per event per day, refreshed in the two hours before an event if the answer is over an hour old. At most eta_daily_lookups (12) a day.
    • Buffer: eta_buffer_minutes (10).
    • Failures and the limit are reported, never guessed.
    • The cache keeps only hashed keys and minutes.
  • RULES §5 evening briefing: show its "Leave by" line under each event, and never estimate one.
  • Config: eta_from (required, so nothing is looked up until it's set), eta_transport, eta_buffer_minutes, eta_daily_lookups.

Live traffic test (two public places, Ferry Building to SFO, 22.7 km). Arrival times in this Mac's time zone:

Arrival Minutes
Tue 2026-11-17 18:45 34
Sun 2026-11-22 05:00 19
Leaving now (Sunday evening) 29
Transit, Tue 18:45 54

Same distance each time, so traffic is reflected, both predicted and current.

Tested: 12 tests in tests/test_eta.py (now in scripts/ci-checks.sh), with a stand-in for ek: the leave-by maths, the arrival time passed, map locations used, skip rules, no starting point means no lookups, the lookup budget, the daily limit, a new day, failed lookups reported, "leave now", and no places or titles in the cache. Real lookups by address, by place name, by coordinates and by transit.
Not tested: a real day's events from the owner's calendar. Every trip starts from eta_from, not from the event before; that's a stated limit.

Needs the owner: setting eta_from in config.json.

🤖 Generated with Claude Code

The owner keeps every calendar in Apple's Calendar app, so travel times come
from MapKit, with no key or account. ek eta asks Apple Maps for the trip,
with the arrival time so traffic is predicted for it. ek events now gives an
event's map location when it has one, and eta.py turns the day's events into
leave-by times with a buffer, a daily lookup limit, one refresh near the
start, and a cache that holds no places or titles. The briefing rule uses
only its times.

Tested: 12 tests with a stand-in for ek; real lookups between two public
places by address, place name, coordinates and transit. Traffic is
reflected: 34 minutes arriving at a weekday rush hour, 19 early on a Sunday,
same distance. Not tested: a real day's events.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mgilardi
mgilardi merged commit ee5f025 into main Nov 16, 2026
3 checks passed
@mgilardi
mgilardi deleted the feat/ek-eta branch November 16, 2026 02:32
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.

1 participant