I’m using the NWS Alerts integration, and I’m using template entries to pull some of the date out of the exposed fields. Like this:
- name: "NWS Alert Type"
state: "{{ state_attr('sensor.nws_alerts', 'title') }}"
- name: "NWS Alert Text"
state: "{{ state_attr('sensor.nws_alerts', 'spoken_desc') }}"
- name: "NWS Alert Expires"
state: "{{ state_attr('sensor.nws_alerts', 'event_expires') }}"
Those all work fine …
However, there is a field called “display_desc” that exposes a LOT of data. This morning we had a fog advisory so it had all of this data which I pulled using:
{{ state_attr('sensor.nws_alerts', 'display_desc') }}
>
Headline: LOCALLY DENSE FOG POSSIBLE THIS MORNING
Status: Actual
Message Type: Alert
Severity: Moderate
Certainty: Observed
Expires: 2022-09-16T09:30:00-04:00
Description: Locally dense fog can be expected through mid morning with
visibilities reduced to below a half mile at times.
Motorists should slow down and be prepared for a sudden reductions
in visibility. If traveling, be prepared to take a few extra
minutes on your morning commute. Conditions are expected to
improve by 10 AM.
Instruction: None
Within that, what I want is the “Description:”
I tried doing:
{{ state_attr('sensor.nws_alerts', 'display_desc', 'Description') }}
But it doesn’t allow 4 fields … only 3.
How can I further filter upon that block of text?
To make matters worse, the alert fields all clear at the expire time of course, so I can’t test now.
Thank you!