I contacted the developers of the NWS API and have verified that the “id:” field is unique to every separate alert that is issued.
I don’t think @eracknaphobia is active on his github repo for the original nws_alerts integration so I created a new one at my github and made the modifications needed to bring the “id:” into the attributes of the sensor.
I’m no python programmer but I have it tested and working for a single alert at a time so far. I haven’t been able to test it for multiple active alerts at a time but I’m pretty sure I have it right.
If you want to test it out further then you can go to my github and download it from there:
The installation instructions are on the repo. You won’t be able to use this integration at the same time as the original integration. If that’s a problem then there is a way to be able to use both together but it’s going to entail some editing of the sensor.py file along with the entity_ids everywhere you use it in your system. Let me know if you want to do that and I can tell you what you need to do.
After the sensor gets created that point you should be able to filter the notifications or announcements based on a new alert by comparing the “event_id” attribute.
I haven’t worked out any details for how to do that but it should be straight forward for a single alert. It will get a bit trickier for multiple alerts.
Please let me know if it works out for you. And if I get a chance to work out the code for the filtering then I’ll update here again.
Tried the new directions from the link. On reboot of the server I get no errors but also don’t get a new sensor. Checking the nws_alerts folder it now has a subdirectory pycache. Rechecked the sensor platform definition multiple times and see no issue. Is there possibly some other initialization requirement for the custom component? Here’s the sensor definition:
As an FYI there has been another update to the custom integration.
the way I added the event ID a few days ago didn’t allow multiple event ids to be logged as attributes. I’ve fixed that now.
the “event_id:” attribute is a list of all current alert ids separated by three dashes (—) so you can split the json on those characters and do automations based on the different ids if necessary.
And @firstof9 was kind enough to submit a PR to allow for configuration of the integration via the UI config method.
You can still also configure everything via yaml as well.
Please go to my github repo for the integration to download the update. Installation instructions can be found there but it’s pretty much the same as before but there are just more files in the nws_alerts folder now.
There are no breaking changes for this integration by updating.
The repo is also now (almost) set up to be installed via HACS too. But I’m trying to figure out if my understanding of the dev docs for HACS has a new requirement for a logo or not. It seems that way from those docs tho.
I really hate these weird little errors that pop up that I need to figure out. I always feel bad that something that I’m responsible for isn’t working right and is causing someone issues.