Repository navigation
feat(weather): add Bright Sky provider - #4291
Draft
ms-zone-41 wants to merge 2 commits into
Draft
ms-zone-41 wants to merge 2 commits into
ms-zone-41 wants to merge 2 commits into
Conversation
Adds a server-side provider for Bright Sky (https://brightsky.dev), a free JSON API for the open data of the German Meteorological Service (DWD). It needs no API key and gives very good results for Germany, which so far has no dedicated provider. - current: latest station observation (/current_weather) - hourly: MOSMIX forecast records (/weather) - forecast/daily: hourly records aggregated into local calendar days. Bright Sky records describe the previous hour, so the 00:00 record counts towards the previous day. Today keeps its already elapsed hours, so min/max and precipitation cover the whole day and today does not disappear late in the evening. Builds on the WeatherProvider base class, uses the shared provider utilities (SunCalc sun times, km/h -> m/s) and requests the date range via urlFactory, so it stays current across midnight.
Bright Sky delivers the sunshine duration (in minutes) for every hourly record. The provider now returns it as sunshineHours: - forecast/daily: the sum of the records of each day - current: the sum of today's records (observations so far plus the forecast for the rest of the day). This needs an extra request, so it is only loaded when showSunshineHours is enabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Draft – please do not review yet. I am still doing my own final review of this change. I will mark this PR as ready for review when it is done.
This PR adds Bright Sky as a server-side provider for the default weather module.
Bright Sky is a free JSON API for the open data of the German Meteorological Service (DWD): station observations and MOSMIX forecasts. It needs no API key and gives very good results for Germany, which so far has no dedicated provider. Locations outside Germany are covered as well, but with fewer stations nearby.
Related issue
No related issue.
Changes
brightsky, based on theWeatherProviderbase class:current: the latest station observation (/current_weather)hourly: MOSMIX forecast records (/weather), past hours are skippedforecast/daily: the hourly records aggregated into local calendar days (min/max temperature, dominant daytime icon, max wind, precipitation sum, max precipitation probability)urlFactory), so the date range stays current across midnight.sunshineHours(sum of the hourly records per day; forcurrentthe sum of today, which needs an extra request and is therefore only loaded withshowSunshineHours). It is displayed by the option from feat(weather): add showSunshineHours option #4292. Without feat(weather): add showSunshineHours option #4292 the value is simply not shown, so I can also drop this commit if you prefer.brightskyandMOSMIXare added to the spelling dictionary, andbrightskyto the weather release-note labels.Example configuration:
I will open a PR for the documentation (
modules/weather.md) as soon as this one looks fine to you.Screenshot
Current weather and forecast with live data (the sunshine values are shown with
showSunshineHoursfrom #4292):Testing
npx vitest run tests/unit/modules/default/weather(all weather unit tests pass)node --run test:lintandnode --run test:spellingfor the changed filesI used an AI coding assistant to help prepare this change. I reviewed and tested it myself.