Hello
Since I’ve used Dark sky for a lot of my automations, and they’ve decided to close the API, I was trying to set up the NWS integration.
I’ve got it pulling in Data, but it comes in one gigantic blob of data, instead of in seperate days.
Does anyone have any templates to separate the data out in usable chunks?
Next year. They announced the API will continue to be available (to existing customers) until the end of 2021.
Our API service for existing customers is not changing today, but we will no longer accept new signups. The API will continue to function through the end of 2021.
You’re certainly free to stop using their API immediately but there’s still over a year left.
What NWS integration are you using? The built-in integration structures the data like all the other weather platforms and it does separate out the forecast into twice a day, unless you are using hourly, and then it separates it out into hourly forecasts.
Ah ok, this clears it up, you were using the sensor platform for dark sky. There is no comparable platform for NWS, although it could be added with some work in the backend or you can use templates like you suggest. Hopefully someone can come along to help you on templates. I’m not sure how to do it myself.
In this, I’d love to get the current and daily daily High temp, low temp, humidity, condition, and the daily detailed description.
In dark sky it would give me a current, 0d (today,) 1day (tomorrow,) and a 2 day (day after tomorrow) for each of of those.
If you could give me a couple of examples, I’m sure I could figure the rest out myself.
temperature: 50
humidity: 39
pressure: 29.77
wind_bearing: 360
wind_speed: 11
visibility: 10
attribution: Data from National Weather Service/NOAA
forecast:
- detailed_description: 'Mostly sunny, with a high near 50. North wind around 9 mph.'
temperature: 50
datetime: '2020-04-01T13:00:00-04:00'
daytime: true
condition: partlycloudy
precipitation_probability: 0
wind_bearing: 0
wind_speed: 9
- detailed_description: 'Partly cloudy, with a low around 34. North wind 5 to 8 mph.'
temperature: 34
datetime: '2020-04-01T18:00:00-04:00'
daytime: false
condition: partlycloudy
precipitation_probability: 0
wind_bearing: 0
wind_speed: 6
- detailed_description: >-
A chance of rain after 3pm. Partly sunny, with a high near 51. Northwest
wind 9 to 16 mph, with gusts as high as 33 mph. Chance of precipitation is
30%.
temperature: 51
datetime: '2020-04-02T06:00:00-04:00'
daytime: true
condition: rainy
precipitation_probability: 30
wind_bearing: 315
wind_speed: 12
- detailed_description: >-
A chance of rain. Cloudy, with a low around 40. North wind 10 to 16 mph,
with gusts as high as 33 mph. Chance of precipitation is 50%. New rainfall
amounts less than a tenth of an inch possible.
temperature: 40
datetime: '2020-04-02T18:00:00-04:00'
daytime: false
condition: rainy
precipitation_probability: 50
wind_bearing: 0
wind_speed: 13
- detailed_description: >-
A chance of rain before 8am, then a chance of rain showers and patchy fog.
Cloudy, with a high near 51. North wind around 13 mph, with gusts as high
as 23 mph. Chance of precipitation is 40%.
temperature: 51
datetime: '2020-04-03T06:00:00-04:00'
daytime: true
condition: rainy
precipitation_probability: 40
wind_bearing: 0
wind_speed: 13
- detailed_description: 'Mostly cloudy, with a low around 38. North wind around 9 mph.'
temperature: 38
datetime: '2020-04-03T18:00:00-04:00'
daytime: false
condition: cloudy
precipitation_probability: 0
wind_bearing: 0
wind_speed: 9
- detailed_description: 'Partly sunny, with a high near 52. Northeast wind 3 to 8 mph.'
temperature: 52
datetime: '2020-04-04T06:00:00-04:00'
daytime: true
condition: cloudy
precipitation_probability: 0
wind_bearing: 45
wind_speed: 6
- detailed_description: 'Partly cloudy, with a low around 38. South wind around 2 mph.'
temperature: 38
datetime: '2020-04-04T18:00:00-04:00'
daytime: false
condition: partlycloudy
precipitation_probability: 0
wind_bearing: 180
wind_speed: 2
- detailed_description: 'Partly sunny, with a high near 56. Southwest wind around 3 mph.'
temperature: 56
datetime: '2020-04-05T06:00:00-04:00'
daytime: true
condition: cloudy
precipitation_probability: 0
wind_bearing: 225
wind_speed: 3
- detailed_description: >-
A slight chance of rain showers before 5am. Mostly cloudy, with a low
around 40. West wind around 3 mph.
temperature: 40
datetime: '2020-04-05T18:00:00-04:00'
daytime: false
condition: rainy
precipitation_probability: 0
wind_bearing: 270
wind_speed: 3
- detailed_description: 'Mostly sunny, with a high near 58. Northwest wind around 3 mph.'
temperature: 58
datetime: '2020-04-06T06:00:00-04:00'
daytime: true
condition: partlycloudy
precipitation_probability: 0
wind_bearing: 315
wind_speed: 3
- detailed_description: 'Mostly cloudy, with a low around 42. Northwest wind around 2 mph.'
temperature: 42
datetime: '2020-04-06T18:00:00-04:00'
daytime: false
condition: cloudy
precipitation_probability: 0
wind_bearing: 315
wind_speed: 2
- detailed_description: 'Partly sunny, with a high near 58. East wind around 2 mph.'
temperature: 58
datetime: '2020-04-07T06:00:00-04:00'
daytime: true
condition: cloudy
precipitation_probability: 0
wind_bearing: 90
wind_speed: 2
- detailed_description: >-
Patchy fog and a slight chance of rain showers after 4am. Mostly cloudy,
with a low around 40. South wind around 2 mph.
temperature: 40
datetime: '2020-04-07T18:00:00-04:00'
daytime: false
condition: rainy
precipitation_probability: 0
wind_bearing: 180
wind_speed: 2
friendly_name: KMMK
It seems like the information you want is buried in the forecast attribute.
That attribute appears to be a multi-day forecast. The attribute’s data is a list and each item in the list represents a daily forecast. Each item’s data is structured as a dictionary. In JSON format it looks something like this:
[ { "detailed_description": "Mostly sunny, with a high near 50. North wind around 9 mph.",
"temperature": 50,
"datetime": "2020-04-01T13:00:00-04:00",
"daytime": true,
"condition": "partlycloudy"
"precipitation_probability": 0
"wind_bearing": 0
"wind_speed": 9 },
{next day's forecast},
{next day's forecast},
{next day's forecast},
... etc ...
{last day's forecast} ]
Go to Developer Tools > Template and paste the following template in the Template Editor (be sure to change the entity’s name to whatever you are using):
{{ state_attr('weather.nws', 'forecast')[0] }}
Let me know if it returns the first day’s forecast (or an error message).
EDIT
I created a simulated sensor for testing purposes. Here are some results to show you how to extract information:
Please mark my previous post with the Solution tag. Only you, the author of this topic, can do that. It will automatically place a check-mark next to the topic’s title which signals to others that this topic has an accepted solution. It will also automatically place a link beneath your first post that leads to the Solution. All of this helps others, who may have a similar question, find the answer.
So here is my working template setup for 2 days. If someone wanted to adapt this to their own setup, the would just need to change the ‘weather.kmmk’ to whatever their nws location is. I could probably add Friendly Names to everything in the next revision,
I thought i understood what you were saying initially, but trying to work my brain around it just confused me. Can you give an example of what you are talking about?
For example, right now forecast[0] is today, forecast[1] is tonight, and forecast[2] is tomorrow day. In about 8 hrs, it will be night, then forecast[0] is the night forecast, forecast[1] is tomorrow day, and forecast[2] is tomorrow night.
This works if you do not care about the weather forecast at night except for the temperature. If you have a snowstorm only at night, you’ll never see it in your forecast.
If there is strong appetite for this, we could add a third mode, daily, that does something like this. I still don’t know what to do with the condition and detailed description in this case, unless they are discarded. Also doesn’t seem great.
The ideal situation IMO is to get day and night supported on the frontend.
As @firstof9’s code shows, it is a somewhat fairly small change to add the low temperature to get home assistant to recognize it as daily. However, more than half the forecast is still discarded this way. What to do with it? If it is simply discarded, important weather info may be lost.