I’ve been trying to pick the locks on https://api.met.no/ for a few days. Finally I cracked it, so in case anyone else wishes to look at longer forecasts, here are the details
I am using apexcharts-card to display the data. The nested JSON is tricky, so we need to import the data as a bulk JSON and then pick out the data at display time.
- platform: rest
name: YR5
resource: https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=55.47028&lon=8.45187&altitude=1
json_attributes_path: "$.properties"
json_attributes:
- timeseries
scan_interval: 600
value_template: "OK"
Let’s display the wind over the next ten days:
type: custom:apexcharts-card
graph_span: 240h
span:
start: day
now:
show: true
label: Now
header:
show: true
title: Vind m/s
series:
- entity: sensor.yr5
stroke_width: 3
type: area
show:
extremas: true
opacity: 0.5
color: '#730712'
data_generator: |
return entity.attributes.timeseries.map((record, index) => {
return [new Date(record.time).getTime(), record.data.instant.details.wind_speed];
}).sort((a, b) => { return a[0] - b[0] });
In case you’re using this example to learn from, loading https://api.met.no/weatherapi/locationforecast/2.0/complete?lat=55.47028&lon=8.45187&altitude=1
into the following tools :
Try inspecting the JSON layout with JSON Formatter & Validator
The look at the JSONPATH testers at JSONPath Expression Tester
First try JSONPATH $.properties.timeseries.*
The work your way to $.properties.timeseries..data..instant..details
Good luck!
Henrik