Severe Weather Alerts from the US National Weather Service


#41

Maybe in that case a simple sensor that shows the details can be created that you can put on your weather tab. Then you can get rid of the pop up completely.

I’ll look into it to see what I can come up with.


#42

For some strange reason the “features” attribute isn’t updating.

Current JSON output from page:

{
    "@context": [
        "https://raw.githubusercontent.com/geojson/geojson-ld/master/contexts/geojson-base.jsonld",
        {
            "wx": "https://api.weather.gov/ontology#",
            "@vocab": "https://api.weather.gov/ontology#"
        }
    ],
    "type": "FeatureCollection",
    "features": [
        {
            "id": "https://api.weather.gov/alerts/NWS-IDP-PROD-3212551-2821313",
            "type": "Feature",
            "geometry": null,
            "properties": {
                "@id": "https://api.weather.gov/alerts/NWS-IDP-PROD-3212551-2821313",
                "@type": "wx:Alert",
                "id": "NWS-IDP-PROD-3212551-2821313",
                "areaDesc": "San Carlos; Globe/Miami; Pinal/Superstition Mountains",
                "geocode": {
                    "UGC": [
                        "AZZ560",
                        "AZZ562",
                        "AZZ558"
                    ],
                    "SAME": [
                        "004007",
                        "004021",
                        "004013"
                    ]
                },
                "affectedZones": [
                    "https://api.weather.gov/zones/forecast/AZZ560",
                    "https://api.weather.gov/zones/forecast/AZZ562",
                    "https://api.weather.gov/zones/forecast/AZZ558"
                ],
                "references": [
                    {
                        "@id": "https://api.weather.gov/alerts/NWS-IDP-PROD-3212098-2820980",
                        "identifier": "NWS-IDP-PROD-3212098-2820980",
                        "sender": "[email protected]",
                        "sent": "2018-11-12T02:12:00-07:00"
                    },
                    {
                        "@id": "https://api.weather.gov/alerts/NWS-IDP-PROD-3212099-2820981",
                        "identifier": "NWS-IDP-PROD-3212099-2820981",
                        "sender": "[email protected]",
                        "sent": "2018-11-12T02:12:00-07:00"
                    }
                ],
                "sent": "2018-11-12T09:11:00-07:00",
                "effective": "2018-11-12T09:11:00-07:00",
                "onset": "2018-11-13T02:00:00-07:00",
                "expires": "2018-11-12T21:15:00-07:00",
                "ends": "2018-11-13T09:00:00-07:00",
                "status": "Actual",
                "messageType": "Update",
                "category": "Met",
                "severity": "Moderate",
                "certainty": "Likely",
                "urgency": "Expected",
                "event": "Freeze Warning",
                "sender": "[email protected]",
                "senderName": "NWS Phoenix AZ",
                "headline": "Freeze Warning issued November 12 at 9:11AM MST expiring November 13 at 9:00AM MST by NWS Phoenix AZ",
                "description": "* TEMPERATURES...As low as 29.\n\n* TIMING...Early Tuesday morning.\n\n* IMPACTS...Freezing temperatures could kill sensitive\nvegetation and damage unprotected outdoor plumbing.",
                "instruction": "A Freeze Warning means sub-freezing temperatures are imminent or\nhighly likely. These conditions will destroy or damage crops and\nother sensitive vegetation.",
                "response": "Execute",
                "parameters": {
                    "NWSheadline": [
                        "FREEZE WARNING REMAINS IN EFFECT FROM 2 AM TO 9 AM MST TUESDAY"
                    ],
                    "VTEC": [
                        "/O.CON.KPSR.FZ.W.0002.181113T0900Z-181113T1600Z/"
                    ],
                    "PIL": [
                        "PSRNPWPSR"
                    ],
                    "BLOCKCHANNEL": [
                        "CMAS",
                        "EAS",
                        "NWEM"
                    ],
                    "eventEndingTime": [
                        "2018-11-13T09:00:00-07:00"
                    ]
                }
            }
        }
    ],
    "title": "current watches, warnings, and advisories",
    "updated": "2018-11-12T16:13:01+00:00"
}

In HASS:

{
  "icon": "mdi:alert-circle",
  "features": [
    {
      "geometry": {
        "coordinates": [
          [
            [
              -112.33,
              33.59
            ],
            [
              -112.33,
              33.7299999
            ],
            [
              -112.19,
              33.7299999
            ],
            [
              -112.19,
              33.59
            ],
            [
              -112.33,
              33.59
            ]
          ]
        ],
        "type": "Polygon"
      },
      "id": "https://api.weather.gov/alerts/NWS-IDP-PROD-3172065-2794455",
      "properties": {
        "@id": "https://api.weather.gov/alerts/NWS-IDP-PROD-3172065-2794455",
        "@type": "wx:Alert",
        "affectedZones": [
          "https://api.weather.gov/zones/county/AZC013"
        ],
        "areaDesc": "Maricopa, AZ",
        "category": "Met",
        "certainty": "Likely",
        "description": "The National Weather Service in Phoenix has issued a\n\n* Flood Advisory for...\nMaricopa County in south central Arizona...\n\n* Until 100 PM MST.\n\n* At 957 AM MST, Doppler radar indicated heavy rain that will cause\nminor flooding in the advisory area.\n\n* Some locations that will experience flooding include...\nGlendale, Peoria, El Mirage, Youngtown, Sun City, Sun City West and\nArrowhead Mall.\n\n* This includes the following highways...\nUS Highway 60 between mile markers 145 and 149.\nAZ Route 101 between mile markers 11 and 18.\nAZ Route 303 between mile markers 124 and 126.",
        "effective": "2018-10-14T09:57:00-07:00",
        "ends": "2018-10-14T13:00:00-07:00",
        "event": "Flood Advisory",
        "expires": "2018-10-14T13:00:00-07:00",
        "geocode": {
          "SAME": [
            "004013"
          ],
          "UGC": [
            "AZC013"
          ]
        },
        "headline": "Flood Advisory issued October 14 at 9:57AM MST expiring October 14 at 1:00PM MST by NWS Phoenix AZ",
        "id": "NWS-IDP-PROD-3172065-2794455",
        "instruction": "",
        "messageType": "Alert",
        "onset": "2018-10-14T09:57:00-07:00",
        "parameters": {
          "BLOCKCHANNEL": [
            "CMAS",
            "EAS",
            "NWEM"
          ],
          "PIL": [
            "PSRFLSPSR"
          ],
          "VTEC": [
            "/O.NEW.KPSR.FA.Y.0240.181014T1657Z-181014T2000Z/"
          ],
          "eventEndingTime": [
            "2018-10-14T13:00:00-07:00"
          ]
        },
        "references": [],
        "response": "Avoid",
        "sender": "[email protected]",
        "senderName": "NWS Phoenix AZ",
        "sent": "2018-10-14T09:57:00-07:00",
        "severity": "Minor",
        "status": "Actual",
        "urgency": "Expected"
      },
      "type": "Feature"
    }
  ],
  "friendly_name": "NWS Alert Event"
}

#43

what is the URL of the rest sensor you’re using for the event?

I’ll try to reproduce it and see what I come up with. I have a throw away sensor setup that I use for testing.

EDIT:

Post the complete code you’re using for the event sensor, please.


#44

Here ya go:

- platform: rest
  resource: https://api.weather.gov/alerts/active/count
  name: NWS Alert Count
  value_template: >
    {% if value_json.zones.AZZ540 is defined %}
      {{ value_json.zones.AZZ540 }}
    {% elif value_json.zones.AZC013 is defined %}
      {{ value_json.zones.AZC013 }}
    {% else %}
      0
    {% endif %}
  #json_attributes:
  #  - event
  #  - description
  #  - instructions
  #  - expires
  headers:
    User-Agent: Homeassistant
    Accept: application/ld+json
  scan_interval: 60
    
- platform: rest
  resource: https://api.weather.gov/alerts/active?zone=AZZ540,AZC013
  name: NWS Alert Event
  value_template: >
    {% if value_json.features[0] is defined %}
      {{ value_json['features'][0]['properties'].event }}
    {% else %}
      None
    {% endif %}
  json_attributes:
    - features
  #  - description
  #  - instructions
  #  - expires
  headers:
    User-Agent: Homeassistant
    Accept: application/geo+json
  scan_interval: 60  

#45

I used your sensor code from above and things seem to be working OK for me with it.

if I go to the templates page and put in my alert entity I get:

and in more human readable form:

[{'id': 'https://api.weather.gov/alerts/NWS-IDP-PROD-3212908-2821573', 
'type': 'Feature', 
'geometry': None, 
'properties': 
{'@id': 'https://api.weather.gov/alerts/NWS-IDP-PROD-3212908-2821573', 
'@type': 'wx:Alert', 
'id': 'NWS-IDP-PROD-3212908-2821573', 
'areaDesc': 'San Carlos; Globe/Miami; Pinal/Superstition Mountains', 
'geocode': {'UGC': ['AZZ560', 'AZZ562', 'AZZ558'],
'SAME': ['004007', '004021', '004013']}, 
'affectedZones': ['https://api.weather.gov/zones/forecast/AZZ560', 'https://api.weather.gov/zones/forecast/AZZ562', 'https://api.weather.gov/zones/forecast/AZZ558'], 
'references': [{'@id': 'https://api.weather.gov/alerts/NWS-IDP-PROD-3212551-2821313', 'identifier': 'NWS-IDP-PROD-3212551-2821313', 'sender': '[email protected]', 'sent': '2018-11-12T09:11:00-07:00'}], 
'sent': '2018-11-12T13:51:00-07:00', 
'effective': '2018-11-12T13:51:00-07:00', 
'onset': '2018-11-13T02:00:00-07:00', 
'expires': '2018-11-13T04:00:00-07:00', 
'ends': '2018-11-13T09:00:00-07:00', 
'status': 'Actual', 
'messageType': 'Update', 
'category': 'Met', 
'severity': 'Moderate', 
'certainty': 'Likely', 
'urgency': 'Expected', 
'event': 'Freeze Warning', 
'sender': '[email protected].gov', 
'senderName': 'NWS Phoenix AZ', 
'headline': 'Freeze Warning issued November 12 at 1:51PM MST expiring November 13 at 9:00AM MST by NWS Phoenix AZ', 
'description': '* TEMPERATURES...As low as 29.\n\n* TIMING...Early Tuesday morning.\n\n* IMPACTS...Freezing temperatures could kill sensitive\nvegetation and damage unprotected outdoor plumbing.', 
'instruction': 'A Freeze Warning means sub-freezing temperatures are imminent or\nhighly likely. These conditions will destroy or damage crops and\nother sensitive vegetation.', 
'response': 'Execute', 
'parameters': {'NWSheadline': ['FREEZE WARNING REMAINS IN EFFECT FROM 2 AM TO 9 AM MST TUESDAY'], 'VTEC': ['/O.CON.KPSR.FZ.W.0002.181113T0900Z-181113T1600Z/'], 'PIL': ['PSRNPWPSR'], 'BLOCKCHANNEL': ['CMAS', 'EAS', 'NWEM'], 'eventEndingTime': ['2018-11-13T09:00:00-07:00']}}}]

and the {{ states.sensor.nws_alert_event_test.state }} is “Freeze Warning”

Where in HA are you seeing the second result from your post above? The format definitely looks off.


#46

The dev-state panel, when I click the nws_alert_event sensor that’s what came up, like it’s not updating for some reason.


#47

I now realized why your format looked off above. It was because it’s the attributes you were getting in the box at the top of the dev-tools page when you clicked on the entity. I’ve never looked at it in that way before.

But it’s still not the same as mine usually is or the way my test sensor was when I put your info in.

I’m really not sure what went wrong above.

I copied your code exactly and everything seems to be working correctly for me.

Is it still screwed up for you now? As of this moment your state should be reading ‘None’.


#48

Currently it is showing “None” but here’s what the previous alert stated:


#49

strange.

I’ve never had that issue.

I’ve had other issues (unknown, unavailable) but never where the event didn’t match the description. I’m not sure how that would even be possible with the sensor since it pulls the whole web page at the same time that includes both the event and the description unless the NOAA API web page was screwed up somehow.

Hopefully it will work correctly the next time an alert comes up.


#50

I wrote a “wrapper script” for volume control on my Google Home that works great. It allows for dynamic volume control, but always keeps the volume low at night. (You could set the volume to 0 to turn it off.) Here’s the code. I think it should work for Echos. I simply call this script with the appropriate parameters whenever I want my Google Home to say something.

##################################################################################################
# standard house annoucements
# turn volume down at night
##################################################################################################

house_annoucement:
  alias: House Annoucement
  sequence:
  # check if silent mode selected
  - condition: state
    entity_id: input_boolean.silent_mode
    state: 'off'  

  # if night mode volume off, else use set volume
  - service: media_player.volume_set
    data_template:
      entity_id: media_player.google_home
      volume_level: >
        {% if is_state('input_select.house_mode', 'Night') %}
          0.3
        {% else %}
        {{ volume }} 
        {% endif %}
    
  # play the message on google home
  - service: tts.google_say
    data_template:
      entity_id: media_player.google_home
      message: '{{ this_message }}'

Here’s an example usage.

  # play annoucement
  - service: script.house_annoucement
    data_template:
      this_message: 'The garage door is open.'
      volume: 0.6

#51

Unfortunately I don’t think that will work for the Echo since the custom component requires that the Echo is not in standby for the volume control to work.

But thanks for posting that for those using Google media players.


#52

I was hoping it would after last night being awakened by Alexa and her sister dots all yelling WARNING! FROST WARNING! AUSTIN TX!! at 3 am this morning… and then at 4 am… and then at 5 am…

but I’d rather have it wake me than not exist at all… so thanks!


#53

Ok…

I’ve been hesitating posting this update because I wanted to try to get the Echo volume control integrated but I just haven’t been able to work out the bugs in that part. And due to the issues that @berniebl an @Dixey are having I’ll just post what I’ve done so far.

I was getting some “unavailable” and “unknown” in the sensor at times which would cause the announcements and pop ups to trigger multiple times for the same alert so I’ve modified the sensors a bit to hopefully better filter that out.

I also added the capability to add additional sensors to get announcements for secondary (or tertiary, etc) alert announcement in case another severe alert comes in while one is already active.

And I updated the bedroom announcement to only announce a Tornado Warning because my wife got really upset that she got woke up at 3 am to hear that there was a Freeze Warning for the next night.

Here is the new code. I’ll post all of it again for completeness:

sensor:
  - platform: rest
    resource: https://api.weather.gov/alerts/active/count
    name: NWS Alert Count Raw
    value_template: >
      {% if value_json is defined and value_json.zones.INZ009 is defined %}
        {{ value_json.zones.INZ009 }}
      {% elif value_json is defined and value_json.zones.INC033 is defined %}
        {{ value_json.zones.INC033 }}
      {% else %}
        0
      {% endif %}
    headers:
      User-Agent: Homeassistant
      Accept: application/ld+json
    scan_interval: 60
  
  - platform: template
    sensors:
      nws_alert_count_filtered:
        friendly_name: NWS Alert Count
        entity_id: sensor.nws_alert_count_raw
        value_template: >
          {% if is_state('sensor.nws_alert_count_raw', 'unavailable') or is_state('sensor.nws_alert_count_raw', 'unknown') %}
            {{ states.sensor.nws_alert_count_filtered.state }}
          {% else %}
            {{ states.sensor.nws_alert_count_raw.state }}
          {% endif %}

    
  - platform: rest
    resource: https://api.weather.gov/alerts/active?zone=INZ009,INC033
    name: NWS Alert Event Raw
    value_template: >
      {% if value_json.features[0] is defined %}
        {{ value_json['features'][0]['properties'].event }}
      {% else %}
        None
      {% endif %}
    json_attributes:
      - features
    headers:
      User-Agent: Homeassistant
      Accept: application/geo+json
    scan_interval: 60
  
  - platform: template
    sensors:
      nws_alert_event_filtered:
        friendly_name: NWS Alert Event
        entity_id: sensor.nws_alert_event_raw
        value_template: >
          {% if is_state('sensor.nws_alert_event_raw', 'unavailable') or is_state('sensor.nws_alert_event_raw', 'unknown') %}
            {{ states.sensor.nws_alert_event_filtered.state }}
          {% else %}
            {{ states.sensor.nws_alert_event_raw.state }}
          {% endif %}
  
  - platform: template
    sensors:
      nws_alert_event_2:
        friendly_name: NWS Alert Event 2
        entity_id: sensor.nws_alert_event_raw
        value_template: >
          {% if state_attr('sensor.nws_alert_event_raw', 'features')[1] is defined %}
            {{ state_attr('sensor.nws_alert_event_raw', 'features')[1]['properties'].event }}
          {% else %}
            None
          {% endif %}
      nws_alert_event_3:
        friendly_name: NWS Alert Event 3
        entity_id: sensor.nws_alert_event_raw
        value_template: >
          {% if state_attr('sensor.nws_alert_event_raw', 'features')[2] is defined %}
            {{ state_attr('sensor.nws_alert_event_raw', 'features')[2]['properties'].event }}
          {% else %}
            None
          {% endif %}

automation:
  - alias: 'NWS Weather Alert Pop Up Control'
    trigger:
      platform: state
      entity_id: sensor.nws_alert_count_filtered
    condition:
      - condition: template  
        value_template: '{{states.sensor.nws_alert_count_filtered.state | int > 0}}'
    action:
      service: script.nws_popup_on_wx_alert
     
  - alias: NWS Notification Weather Alert
    trigger:
      platform: state
      entity_id: sensor.nws_alert_count_filtered
    condition:
      - condition: template
        value_template: '{{states.sensor.nws_alert_count_filtered.state | int > 0}}'
    action:
      - service: notify.pushbullet_notify
        data:
          message: "NWS: {{ states.sensor.nws_alert_event_filtered.state }}"
        
  - alias: NWS Announcement Weather Alert
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.nws_alert_count_filtered
    condition:
      condition: and
      conditions:
        - condition: template
          value_template: '{{states.sensor.nws_alert_count_filtered.state | int > 0}}'
        - condition: template
          value_template: "{{ (('Severe' in states.sensor.nws_alert_event_filtered.state) or ('Tornado' in states.sensor.nws_alert_event_filtered.state)) and 'Warning' in states.sensor.nws_alert_event_filtered.state }}"
    action:
      #- service: media_player.volume_set
      #  data:
      #    entity_id:
      #      - media_player.computer_room_dot
      #      - media_player.kitchen_dot
      #      - media_player.livingroom_dot
      #      - media_player.master_bedroom_dot
      #    volume_level: 0.9
      - service: media_player.alexa_tts
        data_template:
          entity_id: 
            - media_player.computer_room_dot
            - media_player.kitchen_dot
            - media_player.livingroom_dot
            #- media_player.master_bedroom_dot
            - media_player.garage_dot
            - media_player.big_room_dot
          message: "Attention!,,,Attention!,,,The National Weather Service has issued a 
        {{ states.sensor.nws_alert_event_filtered.state }} for your area. 
        It expires at {{ as_timestamp(state_attr('sensor.nws_alert_event_raw', 'features')[0].properties.expires)| timestamp_custom('%-I:%M %p on %-m-%-d-%Y') }}."
      - delay: '00:00:10'
      - service: media_player.alexa_tts
        data_template:
          entity_id: 
            - media_player.computer_room_dot
            - media_player.kitchen_dot
            - media_player.livingroom_dot
            #- media_player.master_bedroom_dot
            - media_player.garage_dot
            - media_player.big_room_dot  
          message: "Attention!,,,Attention!,,,The National Weather Service has issued a 
        {{ states.sensor.nws_alert_event_filtered.state }} for your area. 
        It expires at {{ as_timestamp(state_attr('sensor.nws_alert_event_raw', 'features')[0].properties.expires)| timestamp_custom('%-I:%M %p on %-m-%-d-%Y') }}."
        
  - alias: NWS Announcement Weather Alert 2
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.nws_alert_count_filtered
    condition:
      condition: and
      conditions:
        - condition: template
          value_template: '{{states.sensor.nws_alert_count_filtered.state | int > 1}}'
        - condition: template
          value_template: "{{ (('Severe' in states.sensor.nws_alert_event_2.state) or ('Tornado' in states.sensor.nws_alert_event_2.state)) and 'Warning' in states.sensor.nws_alert_event_2.state }}"
    action:
      #- service: media_player.volume_set
      #  data:
      #    entity_id:
      #      - media_player.computer_room_dot
      #      - media_player.kitchen_dot
      #      - media_player.livingroom_dot
      #      - media_player.master_bedroom_dot
      #    volume_level: 0.9
      - service: media_player.alexa_tts
        data_template:
          entity_id: 
            - media_player.computer_room_dot
            - media_player.kitchen_dot
            - media_player.livingroom_dot
            #- media_player.master_bedroom_dot
            - media_player.garage_dot
            - media_player.big_room_dot
          message: "Attention!,,,Attention!,,,A second severe weather alert has been issued. The National 
 Weather Service has issued a 
        {{ states.sensor.nws_alert_event_2.state }} for your area. 
        It expires at {{ as_timestamp(state_attr('sensor.nws_alert_event_raw', 'features')[1].properties.expires)| timestamp_custom('%-I:%M %p on %-m-%-d-%Y') }}."
      - delay: '00:00:10'
      - service: media_player.alexa_tts
        data_template:
          entity_id: 
            - media_player.computer_room_dot
            - media_player.kitchen_dot
            - media_player.livingroom_dot
            #- media_player.master_bedroom_dot
            - media_player.garage_dot
            - media_player.big_room_dot  
          message: "Attention!,,,Attention!,,,A second severe weather alert has been issued. The National Weather Service has issued a 
        {{ states.sensor.nws_alert_event_2.state }} for your area. 
        It expires at {{ as_timestamp(state_attr('sensor.nws_alert_event_raw', 'features')[1].properties.expires)| timestamp_custom('%-I:%M %p on %-m-%-d-%Y') }}."
    
  - alias: NWS Announcement Weather Alert for MBR
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.nws_alert_count_filtered
    condition:
      condition: and
      conditions:
        - condition: template
          value_template: '{{states.sensor.nws_alert_count_filtered.state | int > 0}}'
        - condition: template
          value_template: "{{ 'Tornado' in states.sensor.nws_alert_event_filtered.state and 'Warning' in states.sensor.nws_alert_event_filtered.state }}"
    action:
      #- service: media_player.volume_set
      #  data:
      #    entity_id:
      #      - media_player.computer_room_dot
      #      - media_player.kitchen_dot
      #      - media_player.livingroom_dot
      #      - media_player.master_bedroom_dot
      #    volume_level: 0.9
      - service: media_player.alexa_tts
        data_template:
          entity_id: 
            - media_player.master_bedroom_dot
          message: "Warning!,,,Warning!,,,The National Weather Service has issued a 
        {{ states.sensor.nws_alert_event_filtered.state }} for your area. 
        It expires at {{ as_timestamp(state_attr('sensor.nws_alert_event_raw', 'features')[0].properties.expires)| timestamp_custom('%-I:%M %p on %-m-%-d-%Y') }}."
      - delay: '00:00:10'
      - service: media_player.alexa_tts
        data_template:
          entity_id: 
            - media_player.master_bedroom_dot
          message: "Warning!,,,Warning!,,,The National Weather Service has issued a 
        {{ states.sensor.nws_alert_event_filtered.state }} for your area. 
        It expires at {{ as_timestamp(state_attr('sensor.nws_alert_event_raw', 'features')[0].properties.expires)| timestamp_custom('%-I:%M %p on %-m-%-d-%Y') }}."
          
  - alias: NWS Announcement Weather Alert 2 for MBR
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.nws_alert_count_filtered
    condition:
      condition: and
      conditions:
        - condition: template
          value_template: '{{states.sensor.nws_alert_count_filtered.state | int > 1}}'
        - condition: template
          value_template: "{{ 'Tornado' in states.sensor.nws_alert_event_2.state and 'Warning' in  states.sensor.nws_alert_event_2.state }}"
    action:
      #- service: media_player.volume_set
      #  data:
      #    entity_id:
      #      - media_player.computer_room_dot
      #      - media_player.kitchen_dot
      #      - media_player.livingroom_dot
      #      - media_player.master_bedroom_dot
      #    volume_level: 0.9
      - service: media_player.alexa_tts
        data_template:
          entity_id:
            - media_player.master_bedroom_dot
          message: "Warning!,,,Warning!,,,A second severe weather alert has been issued. The National Weather Service has issued a 
        {{ states.sensor.nws_alert_event_2.state }} for your area. 
        It expires at {{ as_timestamp(state_attr('sensor.nws_alert_event_raw', 'features')[1].properties.expires)| timestamp_custom('%-I:%M %p on %-m-%-d-%Y') }}."
      - delay: '00:00:10'
      - service: media_player.alexa_tts
        data_template:
          entity_id: 
            - media_player.master_bedroom_dot
          message: "Warning!,,,Warning!,,,A second severe weather alert has been issued. The National Weather Service has issued a 
        {{ states.sensor.nws_alert_event_2.state }} for your area. 
        It expires at {{ as_timestamp(state_attr('sensor.nws_alert_event_raw', 'features')[1].properties.expires)| timestamp_custom('%-I:%M %p on %-m-%-d-%Y') }}."


script:
  nws_popup_on_wx_alert:
    alias: NWS Weather Alert Pop Up
    sequence:
        ## Dismiss any current alert so the UI isn't filled 
        ## up with these if there are more then one.
        ## Only show the latest alert
      - service: persistent_notification.dismiss
        data:
          notification_id: "nwswxalert"
        ## Create a new persistant notification in the UI for a new alert
      - service_template: >
          {% if states.sensor.nws_alert_event_filtered.state != 'None' %}
            persistent_notification.create
          {% endif %}
        data_template:
          notification_id: "nwswxalert"
          message: "{{ state_attr('sensor.nws_alert_event_raw', 'features')[0].properties.description }}"
          title: '{{ states.sensor.nws_alert_event_raw.state }}'

And just as I was posting this I realized I didn’t have a pop up script to handle a second alert event so I threw this one together. As an FYI, I haven’t tested it at all so hopefully it works (it passes the config check as is tho). If not get rid of it and everything else should work OK. I hope. :wink: :smile:


#54

Okay thanks! Installed and now waiting for a real world test. By the way, I have not done them before but is this single file a ‘package’? I broke it’s components out into my sensors, scripts and automations `cause I wasn’t sure. I’m still kinda new to this.


#55

Nope. It should be broken out into it’s different sections.

I don’t use packages either. Maybe I should but things work like this for me for now and that would be one more thing to learn in the ever lengthening list of things to learn. :smile:


#56

First off thanks to @finity for all the work he’s put into this, I’ve been looking for a replacement for wunderground alerts and this really fits the bill.

I’ve taken much of the underlying work here and created a custom component for nws alerts sensor. The sensor can be created by adding the nws_alerts.py file to <config_directory>/custom_components/sensor/ and adding the following to your sensor definitions:

platform: nws_alerts
zone_id: 'PAC049'

The sensor reports:

  • state (number of alerts),
  • title (title of each alert)
  • display_desc (message to display in popup)
  • spoken_desc (message for alexa or whatever TTS you use to speak aloud)

Code can be found here.


#57

Cool!

Thanks for doing that. I’ll definitely give it a try.

Can the sensor be created to use more than one zone? Or can you create more than one sensor using different zones?

I assume the latter and the entity id of the sensor that gets created will be based on the zone you enter?


#58

Right now, it’s one zone per sensor. But you should be able to create as many sensors as you like. So you’d end up with sensor.nws_alerts, sensor.nws_alerts_2, sensor.nws_alerts_3… I’ll see if i can work out a way to name these more specifically. Using the zone in the name would make sense, as you pointed out.


#59

@finity - Just wanted to thank you for putting this together. Had to do a bit customizing for my own setup but the end result works splendidly. I received my first “real” alert today.

Thanks again.


#60

I’m glad I could help.

And with the new custom component by @eracknaphobia hopefully it will start acting like a “real” service soon. :wink: