Open WH3080 opened 3 months ago
Hey there @matthewflamm, @kamiyo, mind taking a look at this issue as it has been labeled with an integration (nws
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
nws documentation nws source (message by IssueLinks)
Logger: homeassistant.components.nws Source: helpers/update_coordinator.py:367 integration: National Weather Service (NWS)(documentation, issues) First occurred: August 14, 2024 at 14:51:12 (18occurrences) Last logged: 12:38:14
{ "correlationId": "a5420fe", "title": "Data Unavailable For Requested Point", "type": "https://api.weather.gov/problems/InvalidPoint", "status": 404, "detail": "Unable to provide data for requested point 52.3625,13.5019", "instance": "https://api.weather.gov/requests/a5420fe" }
This API would actually give us METRAR data: https://aviationweather.gov/data/api/#/Data/dataMetars
The Lat Lon version apparently only works in the US nowadays
The API is the NWS API. This error means that this lat/lon location is not supported by the API. EDDB is also not supported. See https://api.weather.gov/stations/EDDB
The API is the NWS API. This error means that this lat/lon location is not supported by the API. EDDB is also not supported. See https://api.weather.gov/stations/EDDB
Unless you want to restrict this integration to the US, which it was not before, it would make sense to switch the API to this one: https://aviationweather.gov/data/api/#/Data/dataMetars
And yes the NWS does provide METARs not just for EDDB ...
https://aviationweather.gov/api/data/metar?ids=EDDB&taf=true
... but virtually all airports in the world, i.e. accurate weather free of charge for almost any place in the world.
Switching to aviation weather for this integration doesn't seem like a good idea to me. For one, I don't think it gives forecasts, which imo a weather integration would need.
It is a really cool data source though, I could see it being a separate integration. Or your own rest sensor: https://www.home-assistant.io/integrations/sensor.rest/
Switching to aviation weather for this integration doesn't seem like a good idea to me. For one, I don't think it gives forecasts, which imo a weather integration would need.
It is a really cool data source though, I could see it being a separate integration. Or your own rest sensor: https://www.home-assistant.io/integrations/sensor.rest/
Well, you are the developers I am just an enthusiast who may know a thing or two about aviation.
METARs (Meteorological Terminal Aviation Routine Weather Report) are the most timely and accurate weather sources.
The METAR and TAF data pages provide access to raw, tabular, and decoded output that automatically refreshes every five minutes. The page is designed for quick lookups and printability.
METARs are updated at least once an hour or more frequently if anything changes (SPECI) as people's life depends on it while traveling by air. They actually include a lot more measured, not extrapolated weather detail.
And yes, they also include very accurate forecasts (TAF = Terminal Aerodrome Forecasts).
See here for METAR:
https://en.wikipedia.org/wiki/METAR
See here for TAF:
https://en.m.wikipedia.org/wiki/Terminal_aerodrome_forecast
https://www.dwd.de/EN/specialusers/aviation/download/products/metar_taf/metar_trend_taf.pdf
I see your point about separating aviation weather from the rest of NWS. However until 2023 this integration delivered both. Now there are two APIs.
If anything changed after 2023, it seems to me to be because of NWS. We really can't do anything about it as we only rely on api.weather.gov. You can maybe file a request/issue with them to reinstate the international stations. I think there's a link on their website: https://www.weather.gov/documentation/services-web-api
I hope I don't come across as dismissing the importance and accuracy of METAR and TAF. But this integration is focused, partially for maintainability, and partially for ease of use for a core integration, on using api.weather.gov. After researching a bit for the below solution using a custom rest sensor and weather template, it seems the TAF forecast data is not easily mapped to what homeassistant expects. Parsing the METAR and TAF would require implementation and extensive testing, it would beyond the scope of this integration, and frankly would require someone knowledgeable about the data (or an existing decoding library).
Maybe someone will see this and write a custom integration (or propose a core one) for aviation weather, which I agree has international applicability (as opposed to NWS which is US-centered). For what it's worth, there are other people on the weather-gov github discussion boards complaining about the consistency/stability of NWS compared to aviationweather.gov.
I would encourage you, if you have familiarity with python or know someone who does, to see if you can come up with an integration for the aviation weather.
In the meantime, while I'm no means an expert/power user of home assistant, I think I've come up with a sample (mostly untested) sensor that might help you get started:
rest:
- resource: "https://aviationweather.gov/api/data/metar?ids=EDDB&format=json"
scan_interval: 5 # update minutes
sensor:
- name: "EDDB METAR"
value_template: "{{ value_json[0]['rawOb'] }}"
- name: "EDDB Condition"
value_template: "{{ value_json[0]['wxString'] }}" # in the case of null, use clouds[0].cover?
- name: "EDDB Temperature"
value_template: "{{ value_json[0]['temp'] }}"
# ... etc for all the sensors you want to create
- resource: "https://aviationweather.gov/api/data/taf?ids=EDDB&format=json"
scan_interval: 5
sensor:
- name: "EDDB Forecast"
value_template: "{{ value_json[0]['name'] }}"
json_attributes_path: "$.[0]"
json_attributes:
- fcsts
# Then you do this to create a weather template
weather:
- platform: template
name: "Aviation Weather"
condition_template: "{{ states('sensor.eddb_condition') }}"
# ideally, parse code i.e. "-RA" to description "Light Rain"
temperature_template: "{{ states('sensor.eddb_temperature') }}"
# ... etc
forecast_hourly_template: "{{ state_attr('eddb_forecast', 'fcsts') }}"
# but need to transform data to match what the weather entity wants for forecasts.
# From what I understand, it will be a bit hard to parse the TAF to evenly-spaced time periods
# for either hourly, daily, or twice_daily forecasts.
# See https://www.home-assistant.io/integrations/weather.template/
So, the easiest way would be to use an existing METAR/TAF parsing library, and write an integration using that. But with lots of will, you can probably make it work using homeassistant's yaml.
That is very kind of you! I already tried to experiment with the RESTful component and NWS Aviation Weather API, but couldn't get it to work. Your template helps a great deal and once I have a possibly more interesting version I will share it. The US NWS is a fantastic resource for the entire world.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
The problem
I have been using NWS to pull METRARs for EDDB (Berlin Brandenburg Airport) for many years. NOAA (NWS) also continues to provide them: https://aviationweather.gov/data/metar/?id=EDDB&hours=0&decoded=yes&include_taf=yes But the home assistant has the integration no longer pulls them. They are reported as „unavailable“, but clearly that is not true. I have tried to delete and reinstall this integration several times. No like luck. US METAR codes work like a charm.
What version of Home Assistant Core has the issue?
core-2024.8.1
What was the last working version of Home Assistant Core?
?
What type of installation are you running?
Home Assistant OS
Integration causing the issue
https://www.home-assistant.io/integrations/nws/
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
No response