Skip to content

fix: replace hardcoded St. Petersburg weather with IP geolocation - #12

Merged
ethanplusai merged 1 commit into
mainfrom
fix/weather-geolocation
May 15, 2026
Merged

fix: replace hardcoded St. Petersburg weather with IP geolocation#12
ethanplusai merged 1 commit into
mainfrom
fix/weather-geolocation

Conversation

@ethanplusai

Copy link
Copy Markdown
Owner

Summary

The background context worker in `server.py` had Open-Meteo coordinates and a location label hardcoded to St. Petersburg, FL (lat 27.77, lon -82.64), so every JARVIS install — anywhere in the world — reported St. Pete weather. Embarrassing for anyone running this outside Tampa Bay. 🌴

What changed

  • Resolves location dynamically via ipwho.is (no API key required), cached for 15 minutes
  • New env overrides in `.env.example` for pinned locations:
    • `WEATHER_LATITUDE` / `WEATHER_LONGITUDE` (required pair)
    • `WEATHER_LOCATION_LABEL` (display string, optional)
    • `WEATHER_UNIT` (`fahrenheit` | `celsius`, default `fahrenheit`)
  • Defaults to Fahrenheit to preserve existing behavior for the original Floridian audience
  • Silent fallback to "Weather data unavailable." if both env override AND IP lookup fail — no behavior regression
  • Removes the dead `async def fetch_weather()` wttr.in helper that wasn't called from anywhere; the only live weather path was the background worker writing to `_ctx_cache`

Test plan

  • `python3 -m pytest tests/ -q` — all 26 existing tests pass
  • Live IP-geolocation smoke test: correctly resolves to the caller's actual city via ipwho.is
  • Live env-override smoke test: `WEATHER_LATITUDE=51.5074 WEATHER_LONGITUDE=-0.1278 WEATHER_LOCATION_LABEL=London WEATHER_UNIT=celsius` → `"Current weather in London: 8.0°C"`
  • No merge conflicts with `main`

Approach adapted from @devon7y's larger PR #4, extracted as a focused, standalone change.

🤖 Generated with Claude Code

The background context worker had Open-Meteo coordinates and a location
label hardcoded to St. Petersburg, FL, so every JARVIS install — anywhere
in the world — reported St. Pete weather. Embarrassing for anyone running
this outside Tampa Bay.

- Resolves location dynamically via ipwho.is (no API key required),
  cached for 15 minutes
- New env overrides for pinned locations:
    WEATHER_LATITUDE / WEATHER_LONGITUDE (required pair to pin)
    WEATHER_LOCATION_LABEL (display string, optional)
    WEATHER_UNIT (fahrenheit | celsius, defaults to fahrenheit)
- Defaults to Fahrenheit to preserve existing behavior
- Falls back to "Weather data unavailable." silently if both env
  override and IP lookup fail (no behavior regression)
- Removes the dead `async def fetch_weather()` wttr.in helper that
  wasn't called from anywhere; the only live weather path was the
  background worker in `_ctx_cache`

Tested live: IP-only path resolves to the caller's actual city,
env-override path correctly switches to specified lat/lon/unit.

Approach adapted from @devon7y's weather fix in PR #4.

Co-Authored-By: devon7y <devon7y@users.noreply.github.com>
@ethanplusai
ethanplusai force-pushed the fix/weather-geolocation branch from 8a52914 to df44e40 Compare May 15, 2026 02:40
@ethanplusai
ethanplusai merged commit 3954401 into main May 15, 2026
@ethanplusai
ethanplusai deleted the fix/weather-geolocation branch May 15, 2026 02:48
DavidN0809 referenced this pull request in Nichols-HomeLab/jarvis Aug 17, 2026
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