finity69x2 / nws_alerts

An updated version of the nws_alerts custom integration for Home Assistant
84 stars 29 forks source link

Attribute Value Data? #72

Closed NRutt2005 closed 1 month ago

NRutt2005 commented 8 months ago

Question about this integration. Wasn't sure where else to ask the question. I see that the integration outputs the following attribute products:

I just set this integration up but I would like to set up automations for Severe Thunderstorm Warnings, Tornado Warnings, Tornado Watches, Severe Thunderstorm Watches, etc. Does anyone have screen shots of this integration and the attribute data that is populated for these attributes? Currently it just has 'null' as the attribute values obviously because there hasn't been a weather watch/warning issued since the setup. Just would like a little insight into the data values that will be populated. Thank you!

image

mdisabato commented 7 months ago

These are the header and the first alert. There are currently 4 in my area.

I hope this helps. Let me know if you need more shots of the data.

Screenshot 2024-01-11 at 13 47 40 Screenshot 2024-01-11 at 13 47 51

richcrabtree commented 6 months ago

I would really like to have some example data so I can test my templates

mdisabato commented 6 months ago

Here's what I did to get data when my local forecast was all sunshine and pretty:

Have fun!

ampersandru commented 6 months ago

Can you guys share your yaml on the trigger method of the specific attributes? I see under "spoken_desc" attribute for my area:

  FLOOD WATCH REMAINS IN EFFECT THROUGH WEDNESDAY MORNING
  HIGH SURF ADVISORY REMAINS IN EFFECT UNTIL 4 AM PST TUESDAY
  WIND ADVISORY REMAINS IN EFFECT UNTIL 4 AM PST TUESDAY

Title attribute: title: Flood Watch - High Surf Advisory - Wind Advisory I don't care about the high surf advisory but want the Wind and flood advisory as triggers

ampersandru commented 6 months ago

Ok I think I got it, might be a more graceful way to do multiple ORs in the template

trigger:
  - platform: template
    value_template: >-
      {{ state_attr('sensor.nws_alerts', 'title') is search('Flood',
      ignorecase=True) }}
  - platform: template
    value_template: >-
      {{ state_attr('sensor.nws_alerts', 'title') is search('Wind',
      ignorecase=True) }}
  - platform: template
    value_template: >-
      {{ state_attr('sensor.nws_alerts', 'title') is search('Fire',
      ignorecase=True) }}
  - platform: template
    value_template: >-
      {{ state_attr('sensor.nws_alerts', 'title') is search('Tornado',
      ignorecase=True) }}      
  - platform: template
    value_template: >-
      {{ state_attr('sensor.nws_alerts', 'title') is search('Storm',
      ignorecase=True) }}        
ampersandru commented 6 months ago

Found a better way by adding a template sensor, if you're interested:

sensor:
  - platform: template
    sensors:
      weather_alert:
        friendly_name: "Weather Alert"
        value_template: >-
          {{ 'flood' in state_attr('sensor.nws_alerts', 'title') | lower or
             'rain' in state_attr('sensor.nws_alerts', 'title') | lower or
             'storm' in state_attr('sensor.nws_alerts', 'title') | lower or
             'tornado' in state_attr('sensor.nws_alerts', 'title') | lower }}
finity69x2 commented 1 month ago

It's typically better to get help on implementation of automations in HA via the HA forums instead of opening an issue for something like this as it's not technically an issue.