SOLVED: National Weather Service

I have literally no idea how to do that.

I think someone already did.

That is just the sensor portion of the alert system. From what I can see there’s not really any more benefit to using that component than using the custom component that was already made by @eracknaphobia that I’m already using in the above referenced thread.

It would still need all of the other automations and scripts there to do anything more with it.

and those scripts are running flawlessly thank you very much.

1 Like

Too bad we have so few votes on this feature request. We need a lot more so it gets developers’ attention and who knows, some of them decide to write a new component for weather based on this service.

I took initiative even though i have never made a HA component before or really did any programming in python. Here is my very early version of the sensor component https://github.com/dcshoecomp/noaa_alerts

https://community.home-assistant.io/t/noaa-weather-alerts-from-weather-gov-aka-us-national-weather-service/104519?u=dcshoecomp
I am using the noaa-sdk :slight_smile:

1 Like

I have a weather component working. See below. It probably needs to be updated to the new structure, but works in 0.89. I’ve hesitated to change it since no other weather platform had changed.

I also have modified the weather card to display day/night and precipitation probability.

image
https://github.com/MatthewFlamm/home-assistant/blob/nws/homeassistant/components/weather/nws.py

I was planning on submitting a PR for this after I laid some needed groundwork by adding necessary unit conversations first. But my pressure fix PR has been dead in the water for almost three weeks.

2 Likes

Looks great.

https://community.home-assistant.io/t/us-nws-weather-observations-and-forecast/

FWIW I was able to add the NWS current temperature (which is what I mainly care about) by using a simple REST sensor and json parsing value template. Here is my setup. Replace the weather station and you’re good to go. You can determine your stationId using lat,long, this is a good writeup on how to use the API: https://rhythmandbinary.com/2018/11/13/national-weather-service-api/

# NWS current outdoor temperature
  - platform: rest
    name: Outdoor temperature (nws)
    resource: https://api.weather.gov/stations/KOFP/observations/latest
    method: GET
    value_template: '{{ value_json.properties.temperature.value }}'
    headers:
      application: vnd.noaa.dwml+xml
      User-Agent: home-assistant
    unit_of_measurement: '°C'
    scan_interval: 20
1 Like

This is soon a default integration in the upcoming v0.99.0 release, you will not need the REST sensor for this.

2 Likes

Sorry but can you point in the right direction I can’t seem to find any integration for NWS.

Update: Sorry found it and in case anyone else can’t find the documentation for this AWESOME integration. https://www.home-assistant.io/integrations/nws/

1 Like

The forecasts for this integration can be 4-6 hours old. Is there anyway to increase the frequency of updating? I can’t seem to figure it out other than to maybe setup a REST sensor?

It updates every 10 minutes. You can increase your frequency by using the homeassistant.update_entity, but it will throttle you down to once a minute. This isn’t going to fix the problem I think however. Have you checked the timestamps in the dev tools page (these are in utc time) to make sure they start near the current time? Sometimes these time mismatches are caused by the system time on the browser you are using.

I switched to using openweathermap and it seems the same thing is happening as far as “Updated X minutes/hours ago”, but the temperature and humidity do seem to be updating despite that. So is the time in that message just how long ago it updated the actual state (i.e. from sunny to cloudy)? With NWS the current temperature was always way off so it didn’t give me much confidence.

I don’t know the answer to your question about x minutes ago, but I suspect you are correct that it is only when the state changes not when it is fetches new data. You can try a different nearby observation station and see if you get better data. Some stations are better than others.

I don’t have a problem with how often the NWS integration updates. My problem is that the relevant Lovelace card always shows the predicted weather from the previous 4 hours instead of the upcoming 4 hours. It’s about 9am right now as I write this and I’m being shown data from 4am to 8am. Note that when I inspect the “4-hour forecast” entity itself (by clicking the button which looks like an old-school equalizer), it contains hourly data several days into the future.

So I guess my issue is: how do I get the Lovelace card to display the next 4 hours’ worth of data instead of data from the past? I mean, it’s called a “forecast” and not an “aftcast”.

The NWS forecast should be a true forecast, so either the API is providing garbage data, there is some time zone conversion issue, or there is a bug. Can you provide one of the forecast timestamps in the datetime attribute from the tab on the developers page along with your local time and time zone?

Edit:. Please provide the first timestamp.

Here are the first several lines of data for the entity weather.kbfi_hourly (Boeing Field in Seattle). Let me know if that’s what you’re looking for:

temperature: 74
humidity: 33
pressure: 30.09
wind_bearing: 310
wind_speed: 9
visibility: 10
attribution: Data from National Weather Service/NOAA
forecast:
  - detailed_description: ''
    temperature: 70
    datetime: '2020-07-13T16:00:00-07:00'
    condition: sunny
    precipitation_probability: 0
    wind_bearing: 337.5
    wind_speed: 9

When did you grab this data? Around 5:45 Seattle time, or earlier? What did your frontend say at that time?

If you grabbed it at 5:45, it looks like the forecast is only 45 minutes stale since the timestamp in home assistant is the starting time of the forecast, and it is showing 4PM, which is valid from 4-5 PM.

Off by one hour like this could be caused by some changes I recently made that make the forecast more robust to brief server outages. I could reduce the occurrence of this, but at the expense of having unavailable data sometimes.

If you see this off by more than one hour, than it is likely the data source providing stale data. If true, then we could filter this out. But I’d want to confirm it occurs first.