Apple WeatherKit integration

Apple announced WeatherKit at WWDC, including a REST API that is effectively an evolution of the Dark Sky service. Pricing is very competitive and data quality is very high. It would be great to migrate the Darksky integration to WeatherKit.

Just voted for this FR. I’m certainly not up to the task of porting and maintaining the integration, but I started looking into the specifics of how WeatherKit will work when it was announced. It seems you have to be a registered Apple developer in order to obtain the necessary IDs and keys to generate the necessary Bearer auth token when making API requests.

This is a high bar compared with the simple ‘secret key’ the Dark Sky API would generate for you when signing up with them. This will both require whoever might want to take on the task of porting to add the additional setup and operational code to support the WeatherKit auth scheme, and (if I understand this all correctly) for the end users to also be signed up in the Apple Developer Program (at $99 a year) so they get their own IDs/keys.

Alternatively, it might be possible for Nabu Casa to start providing WeatherKit data as part of a Nabu Casa subscription, which could be a much simpler end-user experience… no idea if that would be allowed under Apple’s TOS or if it’s something NC/HA devs would want to support.


Getting a WeatherKit token, and hooking Home Assistant into Apple’s REST API, is difficult but not insurmountable.

STEP 1: I’ve detailed the steps for getting a WeatherKit token via Python here:

STEP 2: I’ve also written up how to configure the Home Assistant REST sensor platform to pull in WeatherKit data, using the token you get with the script in step 1.

And so:


I tried following your script to get the token but I’m getting an error I can’t resolve.

NameError: name ‘token’ is not defined.

What’s causing that? I’m sure I’m doing something wrong on my end, but I can’t figure it out. :slight_smile:

there is a (python) library to authenticate against weatherkit (if you have the neccessary apple developer credentials).

it works quite nicely and you can pull all of the available data or partial data from weatherkit.

a theoretecal path froward would be to modify the dark-sky integration to use PyWeatherKit instead of python-forecastio. apple also provided a field mapping (Transitioning from Dark Sky), outlining how the names of the Dark Sky data fields changed in weatherkit and which data fields are missing (ozone, nearestStormDistance, summary, …).

1 Like

I fixed that a while ago, give it another shot!

Hi everyone — just created a custom component for WeatherKit; it provides current weather and a daily forecast. You can find it here:

Hope this helps :slight_smile:


I’m trying to use the integration that’s part of HA 10.1 beta. On the key section do I just use the letters of the key or does it need to have -----BEGIN PRIVATE KEY----- before the key letters. I keep getting an error: Unknown error occurred

i copy&pasted the contents of the .p8 file including the
and it works.