Continuing the discussion from Wunderground not working:
I am creating RESTful integrations to Weather Underground. I have the current state report and history running perfectly. I am really struggling with the forecast. This URL
https://api.weather.com/v3/wx/forecast/daily/5day?geocode=MyLatLon&format=json&units=m&language=en-US&apiKey=myAPIkey
produces these results, which I have formatted for ease of reading:
{
"calendarDayTemperatureMax":[24,22,22,22,23,23],
"calendarDayTemperatureMin":[19,19,19,18,19,19],
"dayOfWeek":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"],
"expirationTimeUtc":[1631451439,1631451439,1631451439,1631451439,1631451439,1631451439],
"moonPhase":["Waxing Crescent","First Quarter","Waxing Gibbous","Waxing Gibbous","Waxing Gibbous","Waxing Gibbous"],
"moonPhaseCode":["WXC","FQ","WXG","WXG","WXG","WXG"],
"moonPhaseDay":[6,7,8,9,10,11],
"moonriseTimeLocal":["2021-09-12T13:21:45+0100","2021-09-13T14:34:41+0100","2021-09-14T15:42:25+0100","2021-09-15T16:43:29+0100","2021-09-16T17:34:33+0100","2021-09-17T18:17:34+0100"],
"moonriseTimeUtc":[1631449305,1631540081,1631630545,1631720609,1631810073,1631899054],
"moonsetTimeLocal":["2021-09-12T23:18:02+0100","","2021-09-14T00:05:14+0100","2021-09-15T01:00:31+0100","2021-09-16T02:03:29+0100","2021-09-17T03:11:03+0100"],
"moonsetTimeUtc":[1631485082,null,1631574314,1631664031,1631754209,1631844663],
"narrative":[
"Mix of sun and clouds. Highs 22 to 24C and lows 17 to 19C.",
"Thunderstorms. Highs 21 to 23C and lows 18 to 20C.",
"Thunderstorms. Highs 21 to 23C and lows 17 to 19C.",
"Showers. Highs 21 to 23C and lows 18 to 20C.",
"A few clouds. Highs 22 to 24C and lows 18 to 20C.",
"A few clouds. Highs 21 to 23C and lows 17 to 19C."
],
"qpf":[4.4,18.31,6.9,1.46,0.0,0.0],
"qpfSnow":[0.0,0.0,0.0,0.0,0.0,0.0],
"sunriseTimeLocal":["2021-09-12T07:16:27+0100","2021-09-13T07:17:19+0100","2021-09-14T07:18:12+0100","2021-09-15T07:19:05+0100","2021-09-16T07:19:58+0100","2021-09-17T07:20:51+0100"],
"sunriseTimeUtc":[1631427387,1631513839,1631600292,1631686745,1631773198,1631859651],
"sunsetTimeLocal":["2021-09-12T19:50:29+0100","2021-09-13T19:48:53+0100","2021-09-14T19:47:16+0100","2021-09-15T19:45:40+0100","2021-09-16T19:44:03+0100","2021-09-17T19:42:26+0100"],
"sunsetTimeUtc":[1631472629,1631558933,1631645236,1631731540,1631817843,1631904146],
"temperatureMax":[23,22,22,22,23,23],
"temperatureMin":[19,19,18,19,19,18],
"validTimeLocal":["2021-09-12T07:00:00+0100","2021-09-13T07:00:00+0100","2021-09-14T07:00:00+0100","2021-09-15T07:00:00+0100","2021-09-16T07:00:00+0100","2021-09-17T07:00:00+0100"],
"validTimeUtc":[1631426400,1631512800,1631599200,1631685600,1631772000,1631858400],
"daypart":[
{"cloudCover":[46,84,84,83,83,68,51,29,29,18,30,26],
"dayOrNight":["D","N","D","N","D","N","D","N","D","N","D","N"],
"daypartName":["Today","Tonight","Tomorrow","Tomorrow night","Tuesday","Tuesday night","Wednesday","Wednesday night","Thursday","Thursday night","Friday","Friday night"],
"iconCode":[30,4,4,4,4,4,11,29,34,33,34,33],
"iconCodeExtend":[3000,7200,400,400,400,400,1100,2900,3400,3300,3400,3300],
"narrative":[
"A mix of clouds and sun. High 23C. Winds S at 10 to 15 km/h.",
"Cloudy skies this evening followed by thunderstorms late. Low 18C. Winds S at 15 to 25 km/h. Chance of rain 80%.",
"Thunderstorms likely. Not as hot. High 22C. Winds SSE at 15 to 30 km/h. Chance of rain 90%.",
"Thunderstorms likely. Low 19C. Winds S at 15 to 25 km/h. Chance of rain 90%.",
"Thunderstorms likely. High 22C. Winds S at 15 to 25 km/h. Chance of rain 90%.",
"Thunderstorms. Low 18C. Winds light and variable. Chance of rain 80%.",
"Light rain early...then remaining cloudy with showers in the afternoon. High 22C. Winds NNE at 10 to 15 km/h. Chance of rain 60%.",
"Partly cloudy skies. Low 19C. Winds N at 10 to 15 km/h.",
"Sun and a few passing clouds. High 23C. Winds N at 15 to 30 km/h.",
"Mostly clear. Low 19C. Winds NNW at 15 to 30 km/h.",
"A few clouds early, otherwise mostly sunny. High 22C. Winds NNW at 15 to 30 km/h. Winds could occasionally gust over 65 km/h.",
"Mostly clear skies. Low 18C. Winds NNW at 15 to 30 km/h."
],
"precipChance":[2,84,92,91,87,75,63,24,24,17,12,6],
"precipType":["rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain"],
"qpf":[0.0,4.4,11.28,7.03,4.85,2.05,1.46,0.0,0.0,0.0,0.0,0.0],
"qpfSnow":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
"qualifierCode":[null,null,"Q765",null,null,null,null,null,null,null,"Q1021",null],
"qualifierPhrase":[null,null,"Not as hot.",null,null,null,null,null,null,null,"Winds could occasionally gust over 65 km/h.",null],
"relativeHumidity":[73,90,86,90,85,88,80,85,79,85,76,83],
"snowRange":["","","","","","","","","","","",""],
"temperature":[23,19,22,19,22,18,22,19,23,19,23,18],
"temperatureHeatIndex":[23,22,23,22,22,21,22,22,23,22,23,21],
"temperatureWindChill":[22,20,19,19,19,19,18,19,19,19,19,19],
"thunderCategory":["No thunder","Thunder expected","Thunder expected","Thunder expected","Thunder expected","Thunder expected","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder"],
"thunderIndex":[0,2,2,2,2,2,0,0,0,0,0,0],
"uvDescription":["High","Low","Moderate","Low","Moderate","Low","High","Low","High","Low","High","Low"],
"uvIndex":[7,0,5,0,5,0,7,0,7,0,7,0],
"windDirection":[189,170,157,174,171,161,31,352,349,345,344,348],
"windDirectionCardinal":["S","S","SSE","S","S","SSE","NNE","N","N","NNW","NNW","NNW"],
"windPhrase":[
"Winds S at 10 to 15 km/h.",
"Winds S at 15 to 25 km/h.",
"Winds SSE at 15 to 30 km/h.",
"Winds S at 15 to 25 km/h.",
"Winds S at 15 to 25 km/h.",
"Winds light and variable.",
"Winds NNE at 10 to 15 km/h.",
"Winds N at 10 to 15 km/h.",
"Winds N at 15 to 30 km/h.",
"Winds NNW at 15 to 30 km/h.",
"Winds NNW at 15 to 30 km/h.",
"Winds NNW at 15 to 30 km/h."
],
"windSpeed":[15,18,22,17,20,9,17,16,24,25,27,26],
"wxPhraseLong":["Partly Cloudy","Thunderstorms Late","Thunderstorms","Thunderstorms","Thunderstorms","Thunderstorms","Showers","Partly Cloudy","Mostly Sunny","Mostly Clear","Mostly Sunny","Mostly Clear"],
"wxPhraseShort":["P Cloudy","T-Storms","T-Storms","T-Storms","T-Storms","T-Storms","Showers","P Cloudy","M Sunny","M Clear","M Sunny","M Clear"]
}
]
}
I have defined the RESTful sensor as
- platform: rest
name: pws_forecast
json_attributes:
- calendarDayTemperatureMax
- calendarDayTemperatureMin
- dayOfWeek
- expirationTimeUtc
- moonPhase
- moonPhaseCode
- moonPhaseDay
- moonriseTimeLocal
- moonriseTimeUtc
- moonsetTimeLocal
- moonsetTimeUtc
- narrative
- qpf
- qpfSnow
- sunriseTimeLocal
- sunriseTimeUtc
- sunsetTimeLocal
- sunsetTimeUtc
- temperatureMax
- temperatureMin
- validTimeLocal
- validTimeUtc
- daypart
value_template: '{{ value_json["daypart"] }}'
resource: !secret wu_forecast_url
scan_interval: 03:00:00
I checked that the config is valid and restart HA.
I then went to Developer Tools and entered this code:
{{ states('sensor.pws_forecast') }}
I get the result ‘unknown’. I get the expected results for pws_report and pws_history.
The pws_report and pws_history sensors are defined as:
- platform: rest
name: pws_report
json_attributes:
- observations
value_template: '{{ value_json["observations"][0]["obsTimeLocal"].title() }}'
resource: !secret wu_report_url
scan_interval: 00:05:00
- platform: rest
name: pws_history
json_attributes:
- summaries
value_template: '{{ value_json["summaries"][0]["obsTimeLocal"].title() }}'
resource: !secret wu_history_url
scan_interval: 00:15:00
I simply cannot see what I am doing incorrectly, though it must be something obvious that a newbie like me cannot pick up.
UPDATE:
I got it to work by simply changing the value_template for the forecast to:
value_template: '{{ value_json["validTimeLocal"][0] }}'