nws_alerts icon indicating copy to clipboard operation
nws_alerts copied to clipboard

Multiple alerts concatenated into long strings

Open disconn3ct opened this issue 1 year ago • 3 comments

In my region we frequently get overlapping alerts with the same data, but this occurs even with multiple distinct alerts. I've checked upstream and they are being issued as separate items.

For example, due to the wildfires there are several overlapping air quality emergencies as well as special weather statements with the same information. Instead of receiving an array with each alert as an 'object', it is only returning single long strings:

title: Air Quality Alert - Air Quality Alert - Special Weather Statement - Air Quality Alert - Air Quality Alert - Special Weather Statement - Air Quality Alert - Air Quality Alert
message_type: Alert - Alert - Alert - Alert - Alert - Alert - Alert - Alert - Alert
event_status: Actual - Actual - Actual - Actual - Actual - Actual - Actual - Actual - Actual

I would expect arrays of attributes, similar to other multi-value integrations (especially weather). I haven't come across any other cases where I need to deserialize data from a sensor.

disconn3ct avatar Jun 08 '23 15:06 disconn3ct

I have encountered this issue as well. Also, the implementation with concatenation makes it quite difficult to parse out attributes for a given alert. I would like to suggest an alternative solution - add a service that responds with an appropriate data structure, new in 2023.7, would make it possible for automations to react to the data they need. I found a way to do this with custom templates but I had to jump through a lot of hoops to make it possible.

BranchyMcBranchface avatar Jul 11 '23 12:07 BranchyMcBranchface

How are you currently parsing? The example (https://github.com/finity69x2/nws_alerts/blob/master/lovelace/alerts_tab) seems to use a built-in function: state_attr('sensor.nws_alerts', 'title').split(' - ')[alert_num]

AD-Wright avatar May 10 '24 02:05 AD-Wright

The attribute should be an array of alert entities.

kevinhaas avatar Jun 22 '24 14:06 kevinhaas

This will be fixed in the next release

finity69x2 avatar Aug 04 '24 11:08 finity69x2