finity69x2 / nws_alerts

An updated version of the nws_alerts custom integration for Home Assistant
84 stars 29 forks source link

Alerts ignored for late alpha states when /alerts/count truncates response #43

Closed woliver13 closed 2 years ago

woliver13 commented 2 years ago

2022-07-24 Have been trying to debug an issue where no alerts show up in my part of Texas even though a straight zone call shows them. While debugging, I saw a truncation message in the /alerts/count response. After digging further into the code I realized that the TX zone and county alerts were being cut off. When I went back to try and capture the truncated output for repro instructions the /alert/count call was suddenly allowing 323 alerts in the response. Would it be possible to skip the /alerts/count call and go straight to the /alerts?zone= call to avoid any future truncation issues?

finity69x2 commented 2 years ago

the alerts/count is used for the state of the entity.

the alerts zone is used to get the data from each of the alerts for the entity attributes.

I'm not sure why one would be affected by the other unless I'm not understanding what exactly is being truncated (and I admit this is probably the case).

Are you still having this issue?

if so could you give me the zone info you are using so I can try to test it myself?

woliver13 commented 2 years ago

Line 175 of init.py checks if the zone_id in the loop is in data["zones"]. When it cut off at 300 values, all Texas alerts were not in data["zones"] so the zone_id was never checked.

finity69x2 commented 2 years ago

So you are saying that you had a zone in texas that had over 300 active alerts at one time but the data got cut off at 300 so no state or event displayed at all? (are you checking every zone in texas to get that many alerts?)

Or did the 300 events display but not the rest?

I'm really trying to wrap my head around what happened and TBH how much of an issue this could ever be to decide if its even worth pursuing. Or just write it off as a rare anomaly caused by a failure of the NWS.

If you think it's important then I'm open to a PR as long as it doesn't break the functionality of the current implementation.

woliver13 commented 2 years ago

It was 300 alerts nationally, that is why Texas was truncated. I'm inclined to agree with you that this should be a low priority. Closing now.