MrBartusek / MeteoalarmCard

Meteoalarm, Météo-France and DWD severe weather warnings card for Home Assistant Lovelace UI ⛈️
MIT License
134 stars 49 forks source link

Add support for all weatheralerts event types #243

Closed andrea-fantini closed 3 months ago

andrea-fantini commented 7 months ago

Is your feature request related to a problem? Please describe. The list of supported alert types for the integration weatheralerts is not comprehensive. This leads to a game of wack-a-mole with multple reports of unsupported alert types as they occur. (ex. https://github.com/MrBartusek/MeteoalarmCard/issues/240 https://github.com/MrBartusek/MeteoalarmCard/issues/233)

Describe the solution you'd like Expand the current list of supported alert types to be more comprehensive. To facilitate the job I did my best to collect and organize the relevant events and levels.

Event Types

'911 Telephone Outage': MeteoalarmEventType.Unknown,
'Administrative': MeteoalarmEventType.Unknown,
'Air Quality': MeteoalarmEventType.AirQuality,
'Air Stagnation': MeteoalarmEventType.AirQuality,
'Arroyo And Small Stream Flood': MeteoalarmEventType.Flooding,
'Ashfall': MeteoalarmEventType.Volcanic,
'Avalanche': MeteoalarmEventType.Avalanches,
'Beach Hazard': MeteoalarmEventType.CoastalEvent,
'Blizzard': MeteoalarmEventType.SnowIce,
'Blowing Dust': MeteoalarmEventType.Dust,
'Brisk Wind': MeteoalarmEventType.Wind,
'Child Abduction': MeteoalarmEventType.Unknown,
'Civil Danger': MeteoalarmEventType.Unknown,
'Civil Emergency': MeteoalarmEventType.Unknown,
'Coastal Flood': MeteoalarmEventType.Flooding,
'Dense Fog': MeteoalarmEventType.Fog,
'Dense Smoke': MeteoalarmEventType.Fog,
'Dust': MeteoalarmEventType.Dust,
'Dust Storm': MeteoalarmEventType.Dust,
'Earthquake': MeteoalarmEventType.Earthquake,
'Excessive Heat': MeteoalarmEventType.HighTemperature,
'Extreme Cold': MeteoalarmEventType.LowTemperature,
'Extreme Fire': MeteoalarmEventType.ForestFire,
'Extreme Wind': MeteoalarmEventType.Wind,
'Fire': MeteoalarmEventType.ForestFire,
'Fire Weather': MeteoalarmEventType.ForestFire,
'Flash Flood': MeteoalarmEventType.Flooding,
'Flood': MeteoalarmEventType.Flooding,
'Freeze': MeteoalarmEventType.LowTemperature,
'Freezing Fog': MeteoalarmEventType.LowTemperature,
'Freezing Rain': MeteoalarmEventType.LowTemperature,
'Freezing Spray': MeteoalarmEventType.LowTemperature,
'Frost': MeteoalarmEventType.LowTemperature,
'Gale': MeteoalarmEventType.SeaEvent,
'Hard Freeze': MeteoalarmEventType.LowTemperature,
'Hazardous Materials': MeteoalarmEventType.Unknown,
'Hazardous Seas': MeteoalarmEventType.SeaEvent,
'Hazardous Weather': MeteoalarmEventType.Unknown,
'Heat': MeteoalarmEventType.HighTemperature,
'Heavy Freezing Spray': MeteoalarmEventType.SnowIce,
'High Surf': MeteoalarmEventType.CoastalEvent,
'High Wind': MeteoalarmEventType.Wind,
'Hurricane Force Wind': MeteoalarmEventType.Hurricane,
'Hurricane Local': MeteoalarmEventType.Hurricane,
'Hurricane': MeteoalarmEventType.Hurricane,
'Hydrologic': MeteoalarmEventType.Unknown,
'Ice Storm': MeteoalarmEventType.SnowIce,
'Lake Effect Snow': MeteoalarmEventType.SnowIce,
'Lake Wind': MeteoalarmEventType.Wind,
'Lakeshore Flood': MeteoalarmEventType.Flooding,
'Law Enforcement': MeteoalarmEventType.Unknown,
'Local Area': MeteoalarmEventType.Unknown,
'Low Water': MeteoalarmEventType.CoastalEvent,
'Marine Weather': MeteoalarmEventType.SeaEvent,
'Nuclear Power Plant': MeteoalarmEventType.Unknown,
'Radiological Hazard': MeteoalarmEventType.Unknown,
'Red Flag': MeteoalarmEventType.ForestFire,
'Rip Current': MeteoalarmEventType.CoastalEvent,
'River Flood': MeteoalarmEventType.Flooding,
'Severe Thunderstorm': MeteoalarmEventType.Thunderstorms,
'Severe Weather': MeteoalarmEventType.Unknown,
'Shelter In Place': MeteoalarmEventType.Unknown,
'Short Term': MeteoalarmEventType.Unknown,
'Small Craft': MeteoalarmEventType.Wind,
'Small Stream Flood': MeteoalarmEventType.Flooding,
'Snow Squall': MeteoalarmEventType.SnowIce,
'Special Marine': MeteoalarmEventType.SeaEvent,
'Special Weather': MeteoalarmEventType.Unknown,
'Storm Surge': MeteoalarmEventType.CoastalEvent,
'Storm': MeteoalarmEventType.Thunderstorms,
'Tornado': MeteoalarmEventType.Tornado,
'Tropical Depression Local': MeteoalarmEventType.Hurricane,
'Tropical Storm Local': MeteoalarmEventType.Hurricane,
'Tropical Storm': MeteoalarmEventType.Hurricane,
'Tsunami': MeteoalarmEventType.Tsunami,
'Typhoon Local': MeteoalarmEventType.Hurricane,
'Typhoon': MeteoalarmEventType.Hurricane,
'Urban And Small Stream Flood': MeteoalarmEventType.Flooding,
'Volcano': MeteoalarmEventType.Volcano,
'Wind': MeteoalarmEventType.Wind,
'Wind Chill': MeteoalarmEventType.LowTemperature,
'Winter Storm': MeteoalarmEventType.SnowIce,
'Winter Weather': MeteoalarmEventType.SnowIce,

Event Levels

'Warning': MeteoalarmEventType.Red,
'Watch': MeteoalarmEventType.None,
'Statement': MeteoalarmEventType.Yellow,
'Advisory': MeteoalarmEventType.Yellow,
'Warning': MeteoalarmEventType.Red,
'Watch': MeteoalarmEventType.Orange,
'Statement': MeteoalarmEventType.Orange,
'Immediate': MeteoalarmEventType.Red,
'Danger': MeteoalarmEventType.Red,
'Outlook': MeteoalarmEventType.Yellow,
'Forecast': MeteoalarmEventType.None,

Additional context I started from the realization that the Hydrologic Outlook in my area was not handled properly and I ended up going down a massive rabbit hole. I feel like the feature is 90% there but I honestly don't know and understand the codebase enough to know if the remaining 10% is within my reach, therefore instead of a PR here is a feature request with hopefully most of the leg work done.

I grabbed and cleaned a list of possible event types from the weather.gov website and provided the spreadsheet that I used for most of the string manipulations.

Here are the steps I performed:

Please let me know if there are any questions.

inguy24 commented 5 months ago

Great job @andrea-fantini ! So I was working on the same thing but you beat me to it! FYI There is official documentation of the NOAA CAP standards for emergency alerts at: NOAA CAP

Here are some minor suggestions to tweaks to your list and to the associated MeteoalarmEventType:

For Event Levels, there also needs to be additions for:

You were able to capture some of the codes that actually aren't standards which is great. Apparently some NWS offices are not complying with the CAP standards... but go figure.

MrBartusek commented 4 months ago

Thank you @andrea-fantini and @inguy24 for great reaserch! I've closed all of the duplicate issues with weatheralerts and they are now pointing here. I will try to implement your finding in #250 and we will see how much coverage it will have.

MrBartusek commented 4 months ago

I think the weatheralert.ts code assumes that the last word is the alert level and so I based my data manipulation on this assumption. this leaves out some edge cases that I did not handle. Maybe someone with more understanding of the code can provide a solution also for these few edge cases.

Yes, that's indeed the case. It's how we determine the event level (yellow / orange / red). There are some edge cases I've tried to fix. I've come up with new event-level mapping:

return {
    Warning: MeteoalarmLevelType.Red,
    Statement: MeteoalarmLevelType.Orange,
    Watch: MeteoalarmLevelType.Orange,
    Advisory: MeteoalarmLevelType.Yellow,
    Alert: MeteoalarmLevelType.Yellow,

    Emergency: MeteoalarmLevelType.Red, // Local Area Emergency
    Danger: MeteoalarmLevelType.Red, // Extreme Fire Danger
    Message: MeteoalarmLevelType.Orange, //Civil Emergency Message
    Outage: MeteoalarmLevelType.Orange, // 911 Telephone Outage.
};

I think it should cover all of these pesky events that don't fit into a standard warning, watch, statement, or advisory schema. Did you find any other edge cases that've missed?