SOLVED: National Weather Service

Since we’re about to lose Weather Underground and now Yahoo Weather, this should be a good alternative.

Please see https://www.weather.gov/documentation/services-web-api

To anyone who might want to take this up, there is already a Python Rest API for this on pypi… should only be a few hours of work to get this into home assistant…NOAA/NWS would be a much better source than having users play API whack-a-mole with a nearly-core feature (weather). My python skills are like 3rd grade level, but I’d be happy to test/help out where I can…

1 Like

I don’t know if you’ve seen this or not:

It’s not an official component of HA but it works pretty good if I do say so myself…:smile:

1 Like

Awesome. You should turn this into a component.

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.