Trying to test if certain strings are contained in an NWS weather alert

The NWS alert below has a severity of “Severe”. I’m trying to create a conditional so if the severity is “Severe” or “Extreme” then do something. I’ve tried various permutations of the below syntax to no avail. Any help would be appreciated.

-Thanks

if:
  - condition: template
    value_template: >-
      {{ state_attr('sensor.nws_alerts_alerts', 'severity') in ['Extreme',
      'Severe'] }}
    enabled: true
then:
  - action: persistent_notification.create
    metadata: {}
    data:
      message: Extreme or severe
else:
  - action: persistent_notification.create
    metadata: {}
    data:
      message: Moderate or less
icon: mdi:alert
friendly_name: NWS Alerts Alerts
Alerts:
  - Event: Extreme Heat Warning
    ID: 29872761-c648-d10e-297b-9b0ce2402ce0
    URL: >-
      https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.6f30f5805500645a50525aa919588be40c1b6d78.004.2
    Headline: EXTREME HEAT WARNING IN EFFECT FROM 11 AM THURSDAY TO 8 PM MST SUNDAY
    Type: Alert
    Status: Actual
    Severity: Severe
    Certainty: Likely
    Sent: "2026-03-16T11:54:00-07:00"
    Onset: "2026-03-19T11:00:00-07:00"
    Expires: "2026-03-17T03:00:00-07:00"
    Ends: "2026-03-22T20:00:00-07:00"
    AreasAffected: >-
      Cave Creek/New River; Fountain Hills/East Mesa; Apache Junction/Gold
      Canyon
    Description: |-
      * WHERE...Apache Junction/Gold Canyon, Cave Creek/New River, and
      Fountain Hills/East Mesa.

There is no attribute severity… the attribute is Alerts, which contains a list of “alert” objects with their own sub-attributes like Severity.

{{ state_attr('sensor.nws_alerts_alerts','Alerts')
| selectattr('Severity', 'in', ['Severe','Extreme'])
| list | count > 0 }}

How are you getting that alert data?

Thank you! That explains it.

Using this trigger:

entity_id:
  - sensor.nws_alerts_alerts
trigger: state
to: null

It’s from a custom integration:

You can find it in HACS.

The NWS has made some changes to their websites so I’ve updated the configuration instructions but I haven’t uploaded those to HACS yet so if you want to install it you’ll need to go to the github repo and follow the instructions there.

1 Like

Great thank you! Can’t wait to check it out!

Can you tell me if this update will still work with the NWS Alerts Card?

Also, my currently installed version of NWS Alerts is 6.1:

But in HACS it indicates that version 5.0 is available to install:

There are a few thigs in that post I don’t understand…

I don’t think there’s anything that you need to check out. You seem to already be using the integration.

that post above was to tell peterage where to find the integration if they want to install it themselves.

I don’t know of anything called a “NWS Alerts Card”.

there are examples at the github repo of things you can do to display the data in your HA frontend if you want.

If that’s what you mean then yes that will all still work. the only things that have changed (so far) are the instructions on how to find the codes to enter into the configuration. If you already have everything set up then nothing changes and you are good to go.

you are already on the latest version (so far) - V6.3 is after V5.0.

that blurb in the readme was put there for people upgrading from V4.x to V5.x since there was a major rewrite of the integration to make pulling data out of the attributes easier.

after I release the next update in a few days (don’t worry there won’t be any breaking changes in that one either) those update warnings won’t be in the HACS info and it’s already removed from the github readme.

Thanks for the clarification! And thanks for NWS Alerts. BTW I’m using NWS Alerts Card from HACS. So far it seems to work well.

Interesting.

I had never heard that someone made a card for this.

I’ll definitely check that out.

Thanks for letting me know about it! :slightly_smiling_face: