Apple WeatherKit Smart-Home-Integration, kostenlos und Open Source

Unofficial connector: Apple WeatherKit weather, forecasts and alerts, with your Apple key.
Die Dokumentation dieser Integration wird von ihrem Autor geschrieben und ist bisher nur auf Englisch verfügbar.
Unofficial connector, not affiliated with Apple. It makes Apple WeatherKit the weather provider of Gladys: current conditions, 24-hour and 8-day forecasts, and the official alerts of the country you set. The weather widget, the assistant and the weather-alert scene triggers of Gladys use it directly.
This integration was never tested with a real Apple Developer account: it is written from the documentation of the WeatherKit REST API. Feedback is welcome.
What you need
- An Apple Developer Program membership of your own (paid: 99 USD a year). It includes 500,000 WeatherKit calls a month for the whole team; above that, Apple sells paid tiers in your developer account.
- Gladys 5.1 or later, and at least one located house (Settings → Houses) for the test button.
Getting the credentials
On developer.apple.com/account:
- Team ID: Membership details, 10 characters.
- Service ID: Certificates, Identifiers & Profiles → Identifiers → + → Services IDs, for example
com.example.weather. - Key: Keys → + → tick WeatherKit → register, then download
AuthKey_XXXXXXXXXX.p8(Apple gives it once). The 10 characters afterAuthKey_are the Key ID.
See also WeatherKit: get started.
Configuration
| Field | Purpose |
|---|---|
| Team ID, Key ID, Service ID | The identifiers above. |
| Private key (.p8) | The whole .p8 file, -----BEGIN/END PRIVATE KEY----- lines included (pasted on one line works too). Kept by Gladys in its database, never shown again, used only to sign the requests sent to Apple WeatherKit. It never appears in the logs, the status or /data. |
| Country for the alerts | Two-letter code (FR, BE, US...). WeatherKit gives alerts only with it. Empty: no alerts. |
| Weather alerts | On by default (when a country is set). |
| Refresh interval | 15 minutes by default (10 to 120). A location is read from Apple at most once per interval. |
| Monthly budget | 50,000 calls by default (1,000 to 500,000), per calendar month in UTC. |
Test WeatherKit makes one call (the data sets at your first located house, or at Cupertino when no house has a location): it says whether Apple accepts the credentials, whether alerts exist for your country, and the calls of the month. It runs at most once every 30 seconds, and not during a pause asked by Apple nor once the budget is reached.
Costs, quotas and pacing
- Gladys asks for the weather when a dashboard shows it, when the assistant answers, and every 30 minutes for the alerts. The integration answers from its kept copy while it is younger than the interval: with 15 minutes, count about 3,000 calls a month per location.
- Each call is counted in
/databefore it leaves. Once the budget is reached, nothing is sent until the 1st of the next month (UTC). Apple counts the calls of your other apps in the same quota. - HTTP 429: paused as long as
Retry-Aftersays (compared with Apple'sDateheader), between 60 s and 6 hours; without the header, 60 s then doubled. - Server error, unreadable, oversized (over 1 MB) or missing answer: 60 s pause, doubled at each failure up to 1 hour.
- Other 4xx (400, 404...): the location or the country is not served; only that location is held back for one refresh interval, the others go on.
- Gladys waits 15 s for an answer: a call (or its retry after a 401) that cannot end in time does not leave.
- During a pause or an outage, Gladys gets the last copy if it is under one hour old, with its own date (never presented as new); otherwise an error, and Gladys moves on to its next provider.
- Pauses, the counter and the copies are kept in
/data: a restart does not trigger a call.
Refused credentials
A single 401 or 403 stops nothing: the request is made once more with a new token. Refused twice in a row,
the credentials are recorded as refused and no request leaves with them any more. /data keeps only one
byte of a salted hash of the identifiers and of the public key: nothing secret, and nothing a reader could
check a guess against (one guess in 256 matches). Saving different credentials while the integration runs lifts
the refusal at once. After a restart only that byte is known: new credentials whose byte happens to be the same
(1 chance in 256) stay held back until a success of Test WeatherKit, which always makes its call.
What is sent to Apple
The coordinates of the house rounded to 3 decimals (about 100 m), the user's language (its base: pt-BR → pt),
the alert country, and a token signed for one hour. /data/state.json holds the month counter, the pause, one
byte marking refused credentials, and the last answers. The answers carry no coordinates, but each is filed under
a salted hash of the rounded location: with the salt beside it, the location can be found back by brute force,
and the alerts name their area. /data stays on your Gladys.
Mappings
| WeatherKit | Gladys |
|---|---|
| Clear, MostlyClear, Hot, Frigid | clear |
| PartlyCloudy / MostlyCloudy, Cloudy | partly-cloudy / cloud |
| Fog, Haze, Smoke | fog |
| Drizzle / Rain, Showers... / HeavyRain | drizzle / rain / pouring |
| FreezingDrizzle, FreezingRain | freezing-rain |
| Sleet, WintryMix, MixedRainAndSnow... | sleet |
| Snow, Flurries, Blizzard... | snow |
| Hail | hail |
| Thunderstorms, StrongStorms... | thunderstorm |
| Breezy, Windy / Dust, BlowingDust | wind / sandstorm |
| TropicalStorm, Hurricane / Tornado | hurricane / tornado |
| any other code | unknown |
Units: WeatherKit answers in metric; the integration converts to m/s and km (metric) or °F, mph, inches and miles (US); pressure stays in hPa; humidity, cloud cover and precipitation chance in percent. A missing value stays missing, never 0.
Alerts: Apple's CAP severity is kept; "unknown" becomes "minor" (the alert is kept). The phenomenon (storm, wind, snow...) is read from the title in English, French, German or Spanish; without a match the alert is shown with its title alone. The description gives the area and the source; the long text is not fetched (one more call per alert). Alerts expired by Apple's clock are removed.
Attribution
Apple asks to show the Apple Weather mark and a link to its data sources: https://weatherkit.apple.com/legal-attribution.html. The Gladys weather widget cannot show it yet: the link is on the configuration screen and here.
Statuses
- "Enter the Team ID...": nothing configured.
- "Invalid configuration: ...": names the wrong fields (never their value); nothing is sent.
- "Ready", then "WeatherKit answers".
- "Apple refused these credentials...", "WeatherKit asked to slow down...", "did not answer properly...", "Monthly budget reached...".
- "/data/state.json is unreadable": read again every 10 s, nothing is sent meanwhile (an unreadable file is not taken as empty).
- "The configuration could not be read": new try after 5 s, then doubled up to 5 minutes.
Limits
No minute-by-minute forecast, no radar image, no air quality. Apache-2.0 license.
Konfigurationseinstellungen
Diese Einstellungen fragt Apple WeatherKit in seinem Konfigurationsbildschirm in Gladys ab.
| Einstellung | Typ | Pflichtfeld | Beschreibung |
|---|---|---|---|
| Apple WeatherKit in Gladys | section | Nein | Unofficial connector, not affiliated with Apple. It makes Apple WeatherKit the weather provider of Gladys: current conditions, 24 hours, 8 days, and the official alerts of the country you set. It needs your own Apple Developer Program membership (paid, 99 USD a year, which includes 500,000 WeatherKit calls a month for the whole team): a WeatherKit key (.p8), its Key ID, your Team ID and a Service ID. Each location is read at most once per refresh interval, and a monthly budget stops the calls before your quota. Data: Apple Weather (see the attribution link). |
| Team ID | string | Ja | The 10 characters of your Apple Developer team (Membership details). |
| Key ID | string | Ja | The 10 characters of the WeatherKit key (Certificates, Identifiers & Profiles → Keys). |
| Service ID | string | Ja | The identifier of a Services ID registered with WeatherKit, in reverse-domain form. |
| Private key (.p8) | secret | Ja | The whole content of the AuthKey_XXXXXXXXXX.p8 file, header lines included. Kept by Gladys in its database, never shown again, used only to sign the requests sent to Apple WeatherKit. |
| Country for the alerts | string | Nein | Two-letter country code of your houses (FR, BE, US...). WeatherKit gives alerts only with it. Empty: no alerts. |
| Weather alerts | boolean | Nein | Asks WeatherKit for the official alerts of the country set above, shown by the weather widget and used by the weather-alert scene triggers of Gladys. |
| Refresh interval (minutes) | number | Nein | A location is read from Apple at most once per interval; Gladys gets the kept copy in between. 15 minutes is about 3,000 calls a month per location. |
| Monthly budget (calls) | number | Nein | Calls allowed per calendar month (UTC), counted by this integration only. Reached: no call until the next month. Apple counts the calls of all your apps in the same quota. |
So installierst du Apple WeatherKit in Gladys
- Öffne in Gladys Integrationen: Apple WeatherKit erscheint im Katalog neben den nativen Integrationen, mit einem Community-Badge.
- Klicke auf Installieren. Gladys lädt das Docker-Image (
ghcr.io/lm1lc3n7/gladys-apple-weatherkit:0.1.1) herunter, startet es in einer vom Kern isolierten Sandbox und erzeugt die Oberfläche der Integration (Geräte, Erkennung und Konfiguration). - Öffne den Bildschirm Konfiguration der Integration, fülle die Einstellungen aus und speichere.
- Du kannst sie auch direkt über die URL ihres Repositorys installieren: https://github.com/LM1LC3N7/gladys-apple-weatherkit.
Apple WeatherKit benötigt Gladys >=5.1.0. Der Katalog in Gladys wird stündlich aktualisiert, eine neue Version ist also spätestens eine Stunde nach ihrer Veröffentlichung verfügbar.
Du nutzt Gladys noch nicht? Es ist kostenlos und Open Source: folge der Installationsanleitung, um loszulegen.
Über externe Integrationen
Apple WeatherKit ist eine externe Integration: eine Community-Integration, die als Docker-Container verpackt und auf GitHub veröffentlicht wird. Gladys installiert sie mit einem Klick und führt sie in einer vom Kern isolierten Sandbox aus. Sie wird von LM1LC3N7 veröffentlicht und gepflegt, nicht vom Gladys-Kernteam.
- Alle Integrationen durchsuchen, native und aus der Community
- Deine eigene externe Integration bauen und veröffentlichen
- Quellcode auf GitHub — Quelle dieser Dokumentation