Severe Weather Alerts from the US National Weather Service

Yeah, I wasn’t sure that the “id:” is a unique id based on each actual associated alert or if if it’s based on the type of alert that was sent.

IOW, do all individual alerts get a new “id:” or is the id based on, for example, “freeze warning”?

unfortunately I haven’t had duplicates so far this morning to check it. of course when I want it to happen it won’t…

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.

1 Like

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:

- platform: nws_alerts
  zone_id: 'WIZ065'

Thanks for any suggestions.

Frank

The pycache directory is normal. the system creates that file on restart after the integration is added.

I know there was a bit of me playing around with the code trying to get the multiple event id’s working and might have screwed something up there.

try downloading the current sensor.py file from the repo again. After restarting see if it works for you then.

That’s for the reply finity. Downloaded and replaced but made no difference. I think it’s the same file revision I downloaded earlier today.

Frank

can you open up the sensor.py file and look at line #40 and tell me what is there?

it should look something like:

class NWSAlertSensor(Entity):

and look at line #23 and it should look like:

DEFAULT_NAME = 'NWS Alerts'

Actually…

I just found one more line I had to change (line #37).

try downloading the sensor.py file again now.

I was using a separate sensor.py file for development and I accidentally copied that one to the sensor.py file in the repo.

That’s what I get for doing seven different things at the same time and trying to keep track of them.

Thanks again finity … that seems to do the trick. I now have a working sensor. Now for some automation fun.

Frank

1 Like

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.

2 Likes

Can still be added as a custom repo :wink:

Yeah, good point. I forgot about that. :+1:

Has it made it to HACS, or is there an ETA? Looking forward to it! Thanks!

You can add it as a custom repo for now

added from git today.
files are in /config/custom_components/nws_alerts

config/integrations does not pick it up, tried configuration.yaml:

Configuration invalidCHECK CONFIGURATION

Platform error sensor.nws_alerts - Integration ‘nws_alerts’ not found.

sensor:

- platform: nws_alerts
  zone_id: 'xxx,xxx'

suggestions ?
HassOS 3.13

any errors in the home-assistant.log file located in your config directory?

nothing related to nws_alerts
besides ‘integrationnws_alrts not found’

only thing i did not try … full raspi reboot … it’s there now …

sorry about that

1 Like

That’s great to hear. :relieved:

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.

I’m relieved it wasn’t me this time. :laughing:

It should be showing up as a default repo in HACS soon. It was just accepted a few hours ago.

2 Likes

I now see it in HACS. To migrate, should we delete existing installations?