Severe Weather Alerts from the US National Weather Service

That’s freakin’ unbelievable…

Ya I need to adjust my template to something like the most recent 5 or 6 alerts lol, but it’s working good overall. :+1:

1 Like

Is there a way to have the automation not trigger if the message is just a test?

...THIS_MESSAGE_IS_FOR_TEST_PURPOSES_ONLY...

...THIS IS A TEST TO DETERMINE TRANSMISSION TIMES INVOLVED IN THE DISSEMINATION OF TSUNAMI INFORMATION...

I added a condition to address this issue:

    - condition: template
      value_template: "{{ ('THIS_MESSAGE_IS_FOR_TEST_PURPOSES_ONLY' not in (state_attr('sensor.nws_alerts','display_desc').split('\n\n-\n\n')[0])) }}"

Excellent, thank you.

I’ve gone through about half of this thread trying to find see if this issue has been fixed. Yesterday I started getting alerts for “Special Weather Statement”. I’m getting this same alert about every two minutes and its getting out of hand. Has anyone been able to limit the repeat notifications?

Thanks,

the best I’ve come up with is the following:

create a “variable”:

## this uses the hass_variable custom component.
## you can install thru HACS or manually from https://github.com/Wibias/hass-variables

variable:
  nws_alerts_event_ids:
    value: 'none'
    restore: true

then create an automation to update that variable with the event ID:

  - alias: NWS Update Event ID Variable
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.nws_alerts
    action:
      service: variable.set_variable
      data:
        variable: nws_alerts_event_ids
        value: "{{ (trigger.to_state.attributes.event_id).split('-')[0] }}"
        attributes: 
          history_1: "{{ states('variable.nws_alerts_event_ids') }}"
          history_2: "{{ state_attr('variable.nws_alerts_event_ids', 'history_1') }}"
          history_3: "{{ state_attr('variable.nws_alerts_event_ids', 'history_2') }}"
          history_4: "{{ state_attr('variable.nws_alerts_event_ids', 'history_3') }}"
          history_5: "{{ state_attr('variable.nws_alerts_event_ids', 'history_4') }}"
          history_6: "{{ state_attr('variable.nws_alerts_event_ids', 'history_5') }}"
          history_7: "{{ state_attr('variable.nws_alerts_event_ids', 'history_6') }}"
          history_8: "{{ state_attr('variable.nws_alerts_event_ids', 'history_7') }}"
          history_9: "{{ state_attr('variable.nws_alerts_event_ids', 'history_8') }}"
          history_10: "{{ state_attr('variable.nws_alerts_event_ids', 'history_9') }}"

then use the data in the variable as a condition in the notifications/announcements:

  - alias: NWS Notification Weather Alert
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: sensor.nws_alerts
    condition:
      - "{{states('sensor.nws_alerts') | int > 0}}"
      - '{{ trigger.to_state.state|int > trigger.from_state.state|int }}'
      - "{{ (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] not in states.variable.nws_alerts_event_ids.attributes.values()|list) and (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] != states('variable.nws_alerts_event_ids')) }}"
    action:
      - service: notify.pushbullet_notify
        data:
          message: >
            "NWS: {{ state_attr('sensor.nws_alerts', 'title').split(' - ')[0] }}"
            
  - alias: NWS Announce Weather Alert
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.nws_alerts
    condition:
      condition: and
      conditions:
        - "{{states('sensor.nws_alerts') | int > 0}}"
        - '{{ trigger.to_state.state|int > trigger.from_state.state|int }}'
        - "{{ ('Severe Thunderstorm Warning' in state_attr('sensor.nws_alerts', 'title')) or ('Tornado Warning' in state_attr('sensor.nws_alerts', 'title')) }}"
        - "{{ (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] not in states.variable.nws_alerts_event_ids.attributes.values()|list) and (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] != states('variable.nws_alerts_event_ids')) }}"
    action:
          .
          .
          .

It’s not perfect but it works pretty well.

Has anyone started started making a blueprint for this?

I don’t see how you could. there’s too many moving parts.

In trying to diagnose why my automations to not automatically when there is an alert (works well if they are executed in the Automation UI) I have a question.
Below I copied one of the small sections of an automation.
Was wondering if the quotes ( " ) vs the ( ’ ) make a difference. If you look at the two value templates both types are used at the beginning of the line and at the end.
If I try to change them to all single, VS code throws a fit.
Any thoughts?

automation:
  - alias: 'NWS Weather Alert Pop Up Control'
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.nws_alerts
    condition:
      - condition: template
        value_template: "{{ states('sensor.nws_alerts') | int > 0 }}"
      - condition: template
        value_template: '{{ trigger.to_state.state|float > trigger.from_state.state|float }}'
      - condition: template
        value_template: "{{ (trigger.to_state.attributes.event_id).split('-')[0] not in states.variable.nws_alerts_event_ids.attributes.values()|list }}"

Thanks

This automation is fine as is.

Thank you so much for the reply

I cannot get the config to validate. I even updated to var which is recommended on the GitHub.

Invalid config for [var]: [value] is an invalid option for [var]. Check: var->var->nws_alerts_event_ids->value. (See /config/configuration.yaml, line 10). 

that’s because I’m not using the “var” integration by snarky-snark. I’m using the “hass-variables” integration by Wibias (previously by Rogro82).

you can find it here (as shown in the comments for the code posted above):

Thanks, I didn’t realize there were to HACS integrations for variables, sorry.

I think I got it all set up, now that we aren’t under any watches or the like, we’ll see if it works.

Thanks for all your help.

1 Like

Well I guess that didn’t work very well. Now I’m not getting Special Weather Statements at all.

is the current event_id in the list of event_id in the history of the variable?

if it is already there then that’s exactly what you should expect.

Here is how I implemented NWS Alerts in my Home Assistant. I am looking for any thoughts or improvements I can make.

Can you share your flow?