Skip to content

Add Open-Meteo forecast for a spot: swell, wind waves and wind - #27

Merged
xquantize merged 1 commit into
feature/conditionsfrom
agent/openmeteo-forecast-5635
Oct 14, 2026
Merged

xquantize merged 1 commit into
feature/conditionsfrom
agent/openmeteo-forecast-5635

Conversation

@xquantize

Copy link
Copy Markdown
Owner

Part of Stage 3 (#21). Targets feature/conditions.

swellsense forecast <spot-id> [--hours 12] fetches an hourly forecast for one spot and prints swell, wind waves and wind in Pacific/Auckland, plus Open-Meteo's credit.

  • Spot can carry an optional forecast_lat / forecast_lon. When they are omitted, the request uses the beach point.
  • fetch_forecast calls the Marine API (wave, swell, wind-wave height, period and direction) and the Forecast API (10 m wind speed, gusts and direction). Wind is requested with wind_speed_unit=kn, so knots are stored as returned.
  • Times are requested as GMT and converted to Pacific/Auckland in code, so a daylight-saving hour is UTC+13 and a winter hour is UTC+12.
  • Directions are where the swell or wind is coming from. The marine docs say wave direction is "the direction the waves come from" (0° from north, 90° from east). Wind uses the same convention: Open-Meteo derives it from U and V with u = -speed * sin(direction) and v = -speed * cos(direction), so 0° is a north wind.
  • If every marine value is null, the fetch raises and names the spot, and asks for forecast_lat / forecast_lon slightly offshore. That failure is not cached.
  • The combined response is cached under data/cache/forecast/ for one hour. The free API is non-commercial only. The credit constant is the licence-page wording: "Weather data by Open-Meteo.com", with the CC BY 4.0 link.

Live check of all 7 Bay of Plenty spots (2 hours each) returned marine data at the beach coordinates, so data/spots.yaml has no offshore points. swellsense forecast mount-main-beach --hours 6 printed a local-time table, for example swell 0.3 m at 6.2 s from 43° and wind 11 kn gusting 26 kn from 347° at 10:00 NZDT.

Tests use MockTransport only: the two APIs are joined by hour (wind timestamps reversed), January and July offsets differ, nulls become None, an all-null marine payload raises, and a cache younger than one hour does not call the network.

Open in Web Open in Cursor 

Combine the marine and wind APIs into Pacific/Auckland hours, cache the
pair for one hour, and print them from swellsense forecast.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
@xquantize
xquantize marked this pull request as ready for review October 14, 2026 22:02
@xquantize
xquantize merged commit 51f7ed1 into feature/conditions Oct 14, 2026
1 check passed
@xquantize
xquantize deleted the agent/openmeteo-forecast-5635 branch October 14, 2026 22:02
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.

2 participants