Skip to content

feat: Add Pirate Weather with full integration (#477, #481, #482, #483)#479

Merged
Orinks merged 24 commits intodevfrom
eli/issue-477-pirate-weather
Mar 19, 2026
Merged

feat: Add Pirate Weather with full integration (#477, #481, #482, #483)#479
Orinks merged 24 commits intodevfrom
eli/issue-477-pirate-weather

Conversation

@Orinks
Copy link
Owner

@Orinks Orinks commented Mar 18, 2026

Summary

Adds Pirate Weather as a fourth weather data source alongside NWS, Open-Meteo, and Visual Crossing, with comprehensive integration across the entire app.

Core Features

Pirate Weather Provider (#477)

  • Full weather client: current conditions, daily forecast (7-day), hourly forecast (168h with extend=hourly), alerts, minutely precipitation
  • API key configuration in settings with Get Free API Key and Validate API Key buttons
  • Signup link: https://pirate-weather.apiable.io/signup
  • Unit support: US, SI, CA, UK
  • Daily forecast summary text (e.g. Light rain throughout the week)
  • Wind speed/gust values rounded to whole numbers

Global WMO Alerts

  • PW provides weather alerts worldwide via WMO (World Meteorological Organization)
  • Extends alert coverage beyond US-only NWS to any country
  • Alert parsing with severity mapping, onset/expiry, regions, description, URI

Minutely Precipitation Notifications (#483)

  • Parses PW 60-minute precipitation forecast
  • Detects precipitation transitions (dry to wet, wet to dry)
  • Generates notifications: Rain starting in 12 minutes, Precipitation ending in 25 minutes
  • Settings toggles: notify_minutely_precipitation_start and notify_minutely_precipitation_stop (default: enabled)
  • Wired into notification event manager with cooldown support

Extended Forecast Cleanup (#481)

  • When forecast_days > 7 and source is NWS or PW, uses Open-Meteo for the full range (up to 16 days)
  • Removes old NWS+Open-Meteo stitching hack

Onboarding and Portable Setup (#482)

  • PW API key step in onboarding wizard alongside VC
  • Readiness summary shows PW key status
  • Portable hint mentions both VC and PW keys
  • pirate_weather_api_key in PORTABLE_API_SECRET_KEYS

UI Changes

  • API key fields show/hide dynamically based on selected source
  • Fields labeled with provider names
  • AVWX key moved from settings to aviation dialog only
  • Validate API Key button for PW
  • Configurable hourly_forecast_hours (1-168, default 6)
  • Forecast order: overall summary then daily then hourly
  • Dynamic hourly header based on configured hours
  • Minutely precipitation toggles in notifications

Auto/Fusion Source Priority

  • US: NWS > Open-Meteo > VC > PW (Open-Meteo first for >7 day forecasts)
  • International: Open-Meteo > PW > VC
  • PW alerts included in auto mode for international locations

Testing

  • 10 VCR-cassette integration tests (NYC, London, Tromso with active WMO alerts)
  • API key auto-scrubbed from cassettes
  • PIRATE_WEATHER_API_KEY added to GitHub secrets
  • 46+ unit tests for error paths, config, fusion, display

Config Changes

  • pirate_weather_api_key (secure keyring)
  • hourly_forecast_hours (int, default 6)
  • notify_minutely_precipitation_start (bool, default True)
  • notify_minutely_precipitation_stop (bool, default True)
  • Source priority lists include pirateweather

Closes #477, closes #481, closes #482, closes #483

Orinks and others added 2 commits March 18, 2026 16:32
Integrates Pirate Weather (Dark Sky-compatible API) as a selectable data
source alongside NWS, Open-Meteo, and Visual Crossing.

- New `PirateWeatherClient` with full unit support (us/si/ca/uk2),
  alert parsing, and 8-day daily/hourly forecasts
- Adds `pirate_weather_api_key` to `AppSettings` with lazy keyring
  storage via `LazySecureStorage`; key survives portable-mode bundles
- `WeatherClient` routes `data_source="pirateweather"` to the new
  client, falls back to "auto" when no key is configured
- `ParallelFetchCoordinator` includes Pirate Weather in smart auto-
  source parallel gather; PW alerts preferred over VC for non-US
- Settings dialog: new "Pirate Weather" choice + API key field with
  "Get Free API Key" button
- `refresh_runtime_settings()` resets PW client on key change so new
  credentials take effect without app restart
- 45 new unit/async/integration tests; all 2785 tests pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add pirateweather to all default source priority lists used by the auto/
fusion weather mode:

- US priority: nws > openmeteo > visualcrossing > pirateweather
- International priority: openmeteo > pirateweather > visualcrossing
  (PW ranked above VC internationally for WMO global alert coverage)

Files changed:
- config/source_priority.py: update SourcePriorityConfig defaults and
  from_dict fallbacks
- models/config.py: update AppSettings field defaults, from_dict fallbacks,
  and _validate_setting fallbacks; valid_sources already included PW
- weather_client_fusion.py: update merge_forecasts and merge_hourly_forecasts
  preferred_order lists
- weather_client_base.py: update _fetch_smart_auto_source getattr fallbacks
- ui/dialogs/settings_dialog.py: update priority selection maps to handle
  new 4-element US lists and 3-element intl lists; retain backward-compat
  with legacy 3/2-element configs from existing user installs

PW alerts were already being merged in _fetch_smart_auto_source (preferred
over VC for international, skipped for US alongside NWS). No alert
aggregation changes needed.

Tests: add tests/test_source_priority_pirateweather.py (23 tests covering
SourcePriorityConfig defaults, AppSettings defaults, and fusion engine
preferred_order for forecast/hourly/current). Update existing
test_settings_dialog_source_priority.py to match new 4-element US lists.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Orinks added 13 commits March 18, 2026 19:38
- Add summary field to Forecast model
- Parse daily.summary from Pirate Weather response
- Display overall summary in forecast presentation
- Add pragma: no cover for UI-only app.py lines
- Add 46 tests for PW error paths, unit conversions, config validation,
  fusion integration, and forecast summary display
- Label VC field as 'Visual Crossing API Key:' instead of generic 'API Key:'
- Label PW field as 'Pirate Weather API Key:' instead of generic 'API Key:'
- Update PW signup link to direct registration page
- Auto mode: show both VC and PW key fields
- Visual Crossing selected: show only VC key field
- Pirate Weather selected: show only PW key field
- NWS/Open-Meteo selected: hide both key fields
- Dynamic update on source dropdown change
- Forecast order: overall summary → daily periods → hourly forecast
- Add hourly_forecast_hours setting (1-68, default 6)
- SpinCtrl in settings for user-configurable hourly count
- Hourly data was already fetched (168h with extend=hourly), just display-capped
- Fallback text header: 'Next N Hours:' instead of hardcoded 'Next 6 Hours:'
- HTML section: aria-label and heading reflect actual hour count
- Reads hourly_forecast_hours setting in build_forecast scope
…tching (#481)

- When forecast_days > 7 and source is NWS or PW, use Open-Meteo for full range
- Remove NWS 7-day + Open-Meteo tail stitching logic from fusion engine
- Open-Meteo supports up to 16 days, no API key needed
- Update tests to reflect cleaner extended forecast behavior
…tup (#482)

- Add PW API key step in onboarding wizard alongside VC
- Update readiness summary with PW key status
- Update portable setup hint to mention both VC and PW
- Add pirate_weather_api_key to PORTABLE_API_SECRET_KEYS
- Add/update tests for onboarding and portable flows
)

- Parse PW minutely block for per-minute precip intensity/probability
- Detect precipitation transitions (dry→wet, wet→dry)
- Generate notifications: 'Rain starting in X minutes', 'Precipitation ending in X minutes'
- Add settings: minutely_precip_alerts (on/off), minutely_precip_threshold_minutes
- Wire into notification event manager with cooldown support
- Screen reader friendly notification text
- Add comprehensive tests
Orinks added 8 commits March 18, 2026 22:11
Incorporates AVWX merge (#480) and extended forecast merge (#484).
Both PW and AVWX features coexist: dual API keys, dual properties,
combined portable/secure storage lists.
- Remove second 'Pirate Weather API Configuration' block (from merge)
- Consolidate to single pw_key control with proper label
- Remove duplicate handler and duplicate load code
AVWX key is only relevant when fetching aviation weather, so it belongs
in the aviation dialog where users actually need it — not buried in
general settings.
Tests key against PW API with a known location (NYC).
Reports success, invalid key, or rate limit status.
Raw PW API floats like 22.51 mph now display as whole numbers (23 mph)
in daily and hourly forecast periods.
- 10 integration tests: current conditions, forecast, hourly, alerts,
  minutely precipitation, daily summary, error handling
- Cassettes recorded for NYC, London, Tromsø (with active WMO alerts)
- API key scrubbed from cassettes and auto-filtered on future recordings
- PW API key added to GitHub secrets (PIRATE_WEATHER_API_KEY)
- conftest: added pirate_weather_api_key fixture, norway_location fixture,
  and URI-based key scrubbing for PW path-based auth
@Orinks Orinks changed the title feat(weather): add Pirate Weather as a fourth weather data source (#477) feat: Add Pirate Weather with full integration (#477, #481, #482, #483) Mar 18, 2026
- NWS: clarify 'forecast + alerts'
- Open-Meteo: 'Global forecast, no alerts, no API key'
- Visual Crossing: 'US/Canada/Europe alerts' not 'International'
- Pirate Weather: 'worldwide alerts' to distinguish from VC
@Orinks Orinks merged commit 2e47355 into dev Mar 19, 2026
3 checks passed
@Orinks Orinks deleted the eli/issue-477-pirate-weather branch March 19, 2026 01:14
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