I have been tinkering with trying to set an input boolean with an automation, using a template as a trigger, and I’ve tried a few things. This is what I have as a trigger for the automation…
{{ 'warning' in state_attr('sensor.nws_alerts', 'state') | lower }}
Essentially, I want to set the input boolean state (of a “severe weather” input boolean) if any National Weather Service alerts contain the word “warning”. I had a severe thunderstorm warning yesterday, and nothing happened.
Anybody know what I’m doing wrong? I will also need to set the input boolean once the “warning” goes away.
The attributes of the sensor contain information like this…
Title
Special Weather Statement - Severe Thunderstorm Watch
Event ID
https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.59f7a454e9ebc6767abfaec2e1fcff13cbb4c212.001.1 - https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.356e31e13eb1efd20c06ba265a2048ead6642693.001.1
Message type
Alert - Alert
Event status
Actual - Actual
Event severity
Moderate - Severe
Event expires
2023-09-08T16:30:00-04:00 - 2023-09-08T23:00:00-04:00
Display desc
> Headline: Strong thunderstorms will impact portions of southwestern Litchfield, southeastern Ulster and southern Dutchess Counties through 430 PM EDT Status: Actual Message Type: Alert Severity: Moderate
Etc...
I remember seeing some of this discussion around when I initially set my configuration up, and much of mine is just copied from elsewhere. This is a long overdue piece of the puzzle for me, since my goal is to trigger a “Severe Weather” mode when an alert comes in to enable automating around that.
I just had another alert go active, and my input_boolean changed properly. Now I just need that input_boolean to clear when the alert is over… Figuring that out should about do it…