finity69x2 / nws_alerts

An updated version of the nws_alerts custom integration for Home Assistant
80 stars 25 forks source link

Request to expand spoken attributes for sensor #65

Closed MeanderingWanderer closed 1 week ago

MeanderingWanderer commented 1 year ago

Thanks for the NWS Alert integration, its a great addition.

If I could make a suggestion, it would be expanding the attributes of the nws sensor. When using with TTS, the current spoken_desc (from nws headline field) provides very limited information about the alert. More information about the alert is included in the display_desc, but it is complicated to parse the info to only include nws description for TTS to read. (display_desc combines multiple fields from alert)

Would it be possible to add an extended_spoken_desc using only the NWS description, without the added nws fields that the display_desc contains?

I wish I was able to contribute and make it happen, unfortunately its not in my ability. Many thanks-

i.e. https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.7e5dd3ad6b9cc589d0bf16ed0c774aa633a5a081.001.1

kevsfastz commented 1 year ago

For example, nws_alerts sends this data for headline:

"Headline: Severe Thunderstorm Warning"

when the same headline from https://api.weather.gov/alerts/active shows:

"headline": "Severe Thunderstorm Warning issued May 5 at 2:39PM CDT until May 5 at 4:00PM CDT by NWS Jackson MS"

It would be nice to have the complete headline provided by weather.gov.

ajkerley commented 5 months ago

+1

finity69x2 commented 4 months ago

Sorry I've taken so long to get back to this.

The two requests are kind of different but I'll see what I can do for both requests.

I can easily add an extended spoken description.

But I doubt I'll change the current headline but I can add a new attribute for the time the alert was sent that will give you the same data that you can use as you see fit.

finity69x2 commented 1 week ago

After trying to figure out a way to implement this I think I'm at an impasse.

Adding another section called "extended_spoken_desc" wouldn't be an issue but the problem is going to be that you could run up against a hard limit of the allowed size of the attributes.

The size limit of the state has always been less than 255 characters. At one point there was no size limitation on attributes so you could pretty much do whatever was needed in there. But that has changed now and I think there's a limit of 16k (don't quote me on that tho.)

So the concern is that there could be too many alerts at one time with enough data that effectively almost doubling the data for every alert by duplicating the description field into the "extended_spoken_desc" would cause errors in the integration preventing you from getting other critical alerts.

TBF this could already possibly happen if there were enough simultaneous alerts but adding the additional data only increases the chances of that happening by reducing any wiggle room.

So all that said I don't think I'll be able to add it.