Severe Weather Alerts from the US National Weather Service

Yes in this instance I was trying to trigger it manually however it didn’t trigger when I did get an alert so I was trying to test why it didn’t trigger. Is there a way to force a trigger? Maybe set the alert back to 0 then to 1, will that force a trigger?

You could try it. I’m not sure how the trigger data would be handled as far as “to_state” is concerned but I guess it could work.

when it didn’t trigger on the alert did you check the automation trace to see why it didn’t run the actions as expected?

I did but the automation never triggered. It didn’t trigger until I tried to do it manually.

Just tried setting the state back to 0 then to 1 but again it didn’t trigger

are you saying that looking at the traces that the trigger never occurred at all even tho the state of the sensor changed?

if so then what is the trigger that you have configured?

post the entire automation in properly formatted yaml.

Well, I’m embarrassed, turns out I just copied and pasted your yaml without checking what the actual sensor id was. I assumed it was going to be sensor.nws_alert but in reality it is sensor.nws_alert_alert. Looked at it a dozen times and I still didn’t see it.

Having said that I tried again to manually set back the state and it appears the autmation ran but I still didn’t get the persistent notification. I’ll have to look into it some more.

1 Like

Yeah, with the latest change to the integration that added that extra “_alert” to the end of the sensor the package files won’t work out of the box anymore.

I completely forgot about that so thanks for pointing it out. I’ll need to fix that.

I tried again with changing the state from 0 to 1 and it appears to trigger the automation. Looking at the trace it seams to go through each step however the script doesn’t trigger. When I go to look at the trace for the script there isn’t one that corresponds to the trigger of the automation. Seems like the manual trigger of changing the state is triggering the automation but for some reason now the script isn’t running. I thought maybe the repeat .item info isn’t there but I would think the script would still trigger so not sure why it’s not.

Also I see I have another sensor called “sensor.nws_alerts_alerts0”, is this expected? I didn’t see it mentioned anywhere.

I have no idea where that sensor entity_id came from. Are you sure you didn’t accidentally change the entity_id when you tried changing the sensor state (maybe adding a 0 when trying to change the state to 0)?

Otherwise as far as the script is concerned it likely won’t work triggering it manually since there is no repeat items to act on. Sometimes there’s no real easy way to things like this. You may just need to either wait until an actual alert comes thru or you can change the location that the sensor is monitoring to a location that has current alerts. You can use INZ009 since we have an active alert right now. then you can easily change it back after testing.

also as an FYI I updated the repo with a new package file for use with v6 and later. It’s untested but I think it should work as all that was needed was to add an extra “_alerts” to the end of every instance of “sensor.nws_alerts”.

Just a quick update, I received a new alert overnight and everything triggered as expected. Thanks for your help. This is one of my favorite integrations. I used it for years in our prior location and couldn’t wait to get it going again here in our new home.

1 Like

Just to chime, in sorry it’s late.

When manually triggering, the to_state doesn’t get populated due to nothing actually triggering the automation. Manually running an automation bypasses the trigger portion entierly.

So i have used this automation for a few years to control my DIY powerwall. If a tornado or thunderstorm watch/warning comes up, the automation will tell the powerwall to grid charge hard to be full in case the storm causes a blackout.

Anyway, realized it was broken and now reading about all th breaking changes. So looking for some help/spot check. This is what i used to have:

triggers:
  - entity_id: sensor.nws_alerts
    trigger: state
conditions:
      - condition: and
        conditions:
          - condition: template
            value_template: "{{states('sensor.nws_alerts') | int > 0}}"
          - condition: template
            value_template: >-
              {{ ('Severe Thunderstorm' in state_attr('sensor.nws_alerts',
              'title')) or ('Tornado' in state_attr('sensor.nws_alerts',
              'title')) }}
          - condition: template
            value_template: >-
              {{ (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] !=
              states('variable.nws_alerts_event_ids')) }}

I believe the last condition was a way to prevent the automation from repeating when nws_alerts updated but the storm warning didn’t change. I want to keep that functionality.

I figured out the new syntax for reading the warning. (i think)

triggers:
  - entity_id: sensor.nws_alerts
    trigger: state
conditions:
  - condition: and
    conditions:
      - condition: template
        value_template: "{{states('sensor.nws_alerts') | int > 0}}"
      - condition: template
        value_template: |2-
                {% set alerts = state_attr('sensor.nws_alerts', 'Alerts') %}
                {% if alerts %}
                  {% for alert in alerts %}
                    {% if 'tornado' in alert['Event'] | lower or 'thunderstorm' in alert['Event'] | lower %}
                      {{ true }}
                    {% endif %}
                  {% endfor %}
                {% endif %}

However i don’t know how to get back the functionality where the automation won’t run if nwws_alerts updates but the storm warning is unchanged. Any help would be appreciated.

try this as the last condition:

- condition: template
  value_template: >-
    {{ trigger.to_state.attributes.Alerts | reject('in', trigger.from_state.attributes.Alerts) | sort(attribute='ID') | list() }}

In the scripts to announce how do I get it to sat the “headline”?

I’ve spent hours on trying figure how make this work. I’ve tried using different areas that got active Thunderstorm/Tornado warning and watches and I can’t figure how to get any of it to work. I see the autiomation/yaml examples in the Packages, but Ive tried copying, editing, chat GPT for help, nothing. I’m way to dumb for this. I had the old version working great on my other HA setup, it still works, but for life of me I cannot figure out how to make this new way work. Fortunately with old one, there was a guy who made a video of how to configure it.

let’s start with the basics…

what is the entity_id of your current sensor?

Those that might read this, that template was bugged. After many prompts on Mr AI i have this instead.

{{ state_attr('sensor.nws_alerts', 'Alerts') | selectattr('Event', 'search', '(?i)tornado|thunderstorm') | list | count > 0 }}

sensor.nws_alerts_alerts is the current name of my sensor. I found active weather yesterday and attempted to use the Tornado/thunderstorm watches, warnings, etc to do testing, but still couldn’t figure out how to get it to trigger anything.

Do the automations exist in your system? make sure they are in the list under your automations section.

And if so then do they show any traces?

Can you post at least one of your automations that isn’t working? Make sure the yaml is properly formatted.

alias: NWS - Persistent Notifications
description: ""
triggers:
  - entity_id: sensor.nws_alerts_alerts
    trigger: state
conditions:
  - condition: numeric_state
    entity_id: sensor.nws_alerts_alerts
    above: 0
actions:
  - repeat:
      for_each: >-
        {{ trigger.to_state.attributes.Alerts | reject('in',
        trigger.from_state.attributes.Alerts) | sort(attribute='ID') | list() }}
      sequence:
        - data:
            notification_id: NWS_{{ repeat.item.ID }}
            title: "NWS New: {{ repeat.item.Event }}"
            message: "{{ repeat.item.Description }}"
          action: script.nws_alerts_persistent_notification
        - delay:
            seconds: 5
mode: queued
initial_state: "on"
max: 10

Is one of them. I think my understanding of templates and trying to create automations utilizing them and the sensor from NWS just isn’t up to par