[Share] Family "Nearest Cloudflare Colo" Tracker in Home Assistant (no location permissions needed!)

Wanted to share a fun little project I built over the past couple of days — a way to see which Cloudflare edge datacenter each family member’s phone is currently routing through when they open Home Assistant, displayed as a friendly city name (e.g. “Mumbai, India”) right on the dashboard.

Why?

I travel a lot for work (merchant navy), and my family and I all access our home Home Assistant instance remotely through a Cloudflare Tunnel. I got curious one day about where everyone’s connections were actually routing from — partly for fun, partly as a lightweight “who’s currently active / roughly where” indicator that doesn’t require GPS permissions or a location-tracking companion app feature.

How it works

Every HTTP request that passes through Cloudflare gets a CF-Ray header stamped on it by whichever edge datacenter (“colo”) answered the request — the last 3 letters are the colo’s airport code (e.g. BOM = Mumbai, SCL = Santiago). This is normally just used for Cloudflare’s own diagnostics, but it’s readable by anything sitting behind the tunnel.

The pipeline:

  1. A small standalone Python HTTP server (no framework, just http.server) runs on my Raspberry Pi, exposed via its own Cloudflare Tunnel hostname
  2. Each family member has an invisible iframe card on their Home Assistant dashboard (wrapped in a conditional card keyed to their HA user ID) pointing at this server
  3. When their session loads, the iframe silently fires a request → the script reads the CF-Ray header → looks up the colo code against a locally-cached list of ~300 Cloudflare colos (city + country) → pushes the result into an input_text helper via HA’s REST API
  4. A Mushroom card on the dashboard shows each person’s last-known colo + a live “X minutes ago” timestamp

Extra touches I added along the way

  • MQTT event publishing (with a 10-minute per-person cooldown) to a shared Events topic, so location changes get logged without spamming
  • A “dummy” HA user trick to filter out false triggers — since Home Assistant’s dashboard editor renders every conditional card at once (ignoring the actual visibility conditions) whenever you’re editing, I added a 5th fake conditional card tied to a never-used dummy account. If the dummy’s request shows up in the same short window as a real one, the script knows it’s just me editing the dashboard and suppresses the notification.
  • Full city names via a locally-cached lookup (avoids repeated external API calls)
  • A side benefit I didn’t originally plan for: Home Assistant doesn’t natively expose “last dashboard visit” per user anywhere — but since this fires every time someone’s session loads the dashboard, the timestamp on each person’s card doubles as an informal “who last opened HA, and when” log, which turned out to be genuinely useful on its own.

Caveats / things I learned

  • Colo assignment reflects network routing, not GPS — if someone’s on a VPN or a WARP-based exit node, it’ll show wherever that connection routes through, not their physical location. Learned this the hard way when my Vasai-based Pi’s WARP gateway kept showing South American colos!
  • Carrier routing quirks are real — one family member on plain Airtel 5G in Mumbai consistently landed on a Marseille, France colo. No VPN involved — just an interesting (unexplained) peering path.
  • If you want a true physical-location indicator, HA’s built-in device_tracker (GPS-based, via the companion app) is the right tool — this project is more of a fun network-routing curiosity than a precise locator.

Happy to share the full script/YAML if anyone’s interested in building something similar!