From eec56ef97deca430691fe528fcf0e88c5e50ef37 Mon Sep 17 00:00:00 2001 From: Jason Verhagen Date: Tue, 1 Feb 2022 21:21:12 -0600 Subject: [PATCH] Update weatheralerts_2.yaml package This update adds icons for each alert type (Issue #50) and should take care of most, if not all, of the template errors that were getting logged during startup and each time the sensor became unavailable due to outages and other problems with the weather.gov alerts API (Issue #52). --- packages/weatheralerts_2.yaml | 1619 +++++++++++++++++++++++++++++---- 1 file changed, 1467 insertions(+), 152 deletions(-) diff --git a/packages/weatheralerts_2.yaml b/packages/weatheralerts_2.yaml index 321b929..0ca8494 100644 --- a/packages/weatheralerts_2.yaml +++ b/packages/weatheralerts_2.yaml @@ -67,21 +67,21 @@ sensor: unit_of_measurement: Alerts icon_template: mdi:alert-rhombus value_template: >- - {% set alerts_total = namespace(count=0) %} - {% if (state_attr('sensor.weatheralerts_2', 'alerts')) %} - {% for alert in state_attr('sensor.weatheralerts_2', 'alerts') %} - {% if as_timestamp(alert['expires']) - as_timestamp(now()) > 0 %} - {% set alerts_total.count = alerts_total.count + 1 %} - {% endif %} - {% endfor %} - {% endif %} - {{ alerts_total.count }} + {% set alerts_total = namespace(count=0) %} + {% if (state_attr('sensor.weatheralerts_2', 'alerts')) %} + {% for alert in state_attr('sensor.weatheralerts_2', 'alerts') %} + {% if as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0 %} + {% set alerts_total.count = alerts_total.count + 1 %} + {% endif %} + {% endfor %} + {% endif %} + {{ alerts_total.count }} attribute_templates: warning_count: >- {% set warnings = namespace(count=0) %} {% if (state_attr('sensor.weatheralerts_2', 'alerts')) %} {% for alert in state_attr('sensor.weatheralerts_2', 'alerts') %} - {% if 'warning' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} + {% if 'warning' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} {% set warnings.count = warnings.count + 1 %} {% endif %} {% endfor %} @@ -91,7 +91,7 @@ sensor: {% set watches = namespace(count=0) %} {% if (state_attr('sensor.weatheralerts_2', 'alerts')) %} {% for alert in state_attr('sensor.weatheralerts_2', 'alerts') %} - {% if 'watch' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} + {% if 'watch' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} {% set watches.count = watches.count + 1 %} {% endif %} {% endfor %} @@ -101,7 +101,7 @@ sensor: {% set advisories = namespace(count=0) %} {% if (state_attr('sensor.weatheralerts_2', 'alerts')) %} {% for alert in state_attr('sensor.weatheralerts_2', 'alerts') %} - {% if 'advisory' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} + {% if 'advisory' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} {% set advisories.count = advisories.count + 1 %} {% endif %} {% endfor %} @@ -111,7 +111,7 @@ sensor: {% set statements = namespace(count=0) %} {% if (state_attr('sensor.weatheralerts_2', 'alerts')) %} {% for alert in state_attr('sensor.weatheralerts_2', 'alerts') %} - {% if 'statement' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} + {% if 'statement' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} {% set statements.count = statements.count + 1 %} {% endif %} {% endfor %} @@ -121,7 +121,7 @@ sensor: {% set outlooks = namespace(count=0) %} {% if (state_attr('sensor.weatheralerts_2', 'alerts')) %} {% for alert in state_attr('sensor.weatheralerts_2', 'alerts') %} - {% if 'outlook' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} + {% if 'outlook' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} {% set outlooks.count = outlooks.count + 1 %} {% endif %} {% endfor %} @@ -131,7 +131,7 @@ sensor: {% set alerts = namespace(count=0) %} {% if (state_attr('sensor.weatheralerts_2', 'alerts')) %} {% for alert in state_attr('sensor.weatheralerts_2', 'alerts') %} - {% if 'alert' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} + {% if 'alert' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %} {% set alerts.count = alerts.count + 1 %} {% endif %} {% endfor %} @@ -170,136 +170,267 @@ sensor: weatheralerts_2_alert_1: friendly_name: Weather Alert 1 - icon_template: mdi:alert-rhombus + icon_template: >- + {% set mapper = { + '911 Telephone Outage Emergency' : 'hass:phone-alert', + 'Administrative Message' : 'hass:message-text', + 'Air Quality Alert' : 'hass:blur', + 'Air Stagnation Advisory' : 'hass:blur', + 'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert', + 'Ashfall Advisory' : 'hass:cloud-alert', + 'Ashfall Warning' : 'hass:cloud-alert', + 'Avalanche Advisory' : 'hass:alert', + 'Avalanche Warning' : 'hass:alert', + 'Avalanche Watch' : 'hass:alert', + 'Beach Hazards Statement' : 'hass:beach', + 'Blizzard Warning' : 'hass:snowflake-alert', + 'Blizzard Watch' : 'hass:snowflake-alert', + 'Blowing Dust Advisory' : 'hass:blur', + 'Blowing Dust Warning' : 'hass:blur', + 'Brisk Wind Advisory' : 'hass:weather-windy', + 'Child Abduction Emergency' : 'hass:human-male-child', + 'Civil Danger Warning' : 'hass:image-filter-hdr', + 'Civil Emergency Message' : 'hass:image-filter-hdr', + 'Coastal Flood Advisory' : 'hass:waves', + 'Coastal Flood Statement' : 'hass:waves', + 'Coastal Flood Warning' : 'hass:waves', + 'Coastal Flood Watch' : 'hass:waves', + 'Dense Fog Advisory' : 'hass:weather-fog', + 'Dense Smoke Advisory' : 'hass:smoke', + 'Dust Advisory' : 'hass:blur', + 'Dust Storm Warning' : 'hass:blur', + 'Earthquake Warning' : 'hass:alert', + 'Evacuation - Immediate' : 'hass:exit-run', + 'Excessive Heat Warning' : 'hass:thermometer-plus', + 'Excessive Heat Watch' : 'hass:thermometer-plus', + 'Extreme Cold Warning' : 'hass:thermometer-minus', + 'Extreme Cold Watch' : 'hass:thermometer-minus', + 'Extreme Fire Danger' : 'hass:fire-alert', + 'Extreme Wind Warning' : 'hass:weather-windy', + 'Fire Warning' : 'hass:fire-alert', + 'Fire Weather Watch' : 'hass:fire-alert', + 'Flash Flood Statement' : 'hass:water-alert', + 'Flash Flood Warning' : 'hass:water-alert', + 'Flash Flood Watch' : 'hass:water-alert', + 'Flood Advisory' : 'hass:water-alert', + 'Flood Statement' : 'hass:water-alert', + 'Flood Warning' : 'hass:water-alert', + 'Flood Watch' : 'hass:water-alert', + 'Freeze Warning' : 'hass:thermometer-minus', + 'Freeze Watch' : 'hass:thermometer-minus', + 'Freezing Fog Advisory' : 'hass:snowflake-alert', + 'Freezing Rain Advisory' : 'hass:snowflake-alert', + 'Freezing Spray Advisory' : 'hass:snowflake-alert', + 'Frost Advisory' : 'hass:snowflake-alert', + 'Gale Warning' : 'hass:weather-windy', + 'Gale Watch' : 'hass:weather-windy', + 'Hard Freeze Warning' : 'hass:thermometer-minus', + 'Hard Freeze Watch' : 'hass:thermometer-minus', + 'Hazardous Materials Warning' : 'hass:radioactive', + 'Hazardous Seas Warning' : 'hass:sail-boat', + 'Hazardous Seas Watch' : 'hass:sail-boat', + 'Hazardous Weather Outlook' : 'hass:message-alert', + 'Heat Advisory' : 'hass:thermometer-plus', + 'Heavy Freezing Spray Warning' : 'hass:snowflake-alert', + 'Heavy Freezing Spray Watch' : 'hass:snowflake-alert', + 'High Surf Advisory' : 'hass:surfing', + 'High Surf Warning' : 'hass:surfing', + 'High Wind Warning' : 'hass:weather-windy', + 'High Wind Watch' : 'hass:weather-windy', + 'Hurricane Force Wind Warning' : 'hass:weather-hurricane', + 'Hurricane Force Wind Watch' : 'hass:weather-hurricane', + 'Hurricane Local Statement' : 'hass:weather-hurricane', + 'Hurricane Warning' : 'hass:weather-hurricane', + 'Hurricane Watch' : 'hass:weather-hurricane', + 'Hydrologic Advisory' : 'hass:message-text', + 'Hydrologic Outlook' : 'hass:message-text', + 'Ice Storm Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Advisory' : 'hass:snowflake-alert', + 'Lake Effect Snow Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Watch' : 'hass:snowflake-alert', + 'Lake Wind Advisory' : 'hass:weather-windy', + 'Lakeshore Flood Advisory' : 'hass:waves-arrow-up', + 'Lakeshore Flood Statement' : 'hass:waves-arrow-up', + 'Lakeshore Flood Warning' : 'hass:waves-arrow-up', + 'Lakeshore Flood Watch' : 'hass:waves-arrow-up', + 'Law Enforcement Warning' : 'hass:car-emergency', + 'Local Area Emergency' : 'hass:alert', + 'Low Water Advisory' : 'hass:wave', + 'Marine Weather Statement' : 'hass:sail-boat', + 'Nuclear Power Plant Warning' : 'hass:radioactive', + 'Radiological Hazard Warning' : 'hass:biohazard', + 'Red Flag Warning' : 'fire-alert', + 'Rip Current Statement' : 'hass:surfing', + 'Severe Thunderstorm Warning' : 'hass:weather-lightning', + 'Severe Thunderstorm Watch' : 'hass:weather-lightning', + 'Severe Weather Statement' : 'hass:message-text', + 'Shelter In Place Warning' : 'hass:account-box', + 'Short Term Forecast' : 'hass:message-text', + 'Small Craft Advisory' : 'hass:sail-boat', + 'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat', + 'Small Craft Advisory For Rough Bar' : 'hass:sail-boat', + 'Small Craft Advisory For Winds' : 'hass:sail-boat', + 'Small Stream Flood Advisory' : 'hass:water-alert', + 'Snow Squall Warning' : 'hass:snowflake-alert', + 'Special Marine Warning' : 'hass:sail-boat', + 'Special Weather Statement' : 'hass:message-alert', + 'Storm Surge Warning' : 'hass:waves-arrow-up', + 'Storm Surge Watch' : 'hass:waves-arrow-up', + 'Storm Warning' : 'hass:weather-lightning', + 'Storm Watch' : 'hass:weather-lightning', + 'Test' : 'hass:message-text', + 'Tornado Warning' : 'hass:weather-tornado', + 'Tornado Watch' : 'hass:weather-tornado', + 'Tropical Depression Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Warning' : 'hass:weather-hurricane', + 'Tropical Storm Watch' : 'hass:weather-hurricane', + 'Tsunami Advisory' : 'hass:waves-arrow-up', + 'Tsunami Warning' : 'hass:waves-arrow-up', + 'Tsunami Watch' : 'hass:waves-arrow-up', + 'Typhoon Local Statement' : 'hass:weather-hurricane', + 'Typhoon Warning' : 'hass:weather-hurricane', + 'Typhoon Watch' : 'hass:weather-hurricane', + 'Urban And Small Stream Flood Advisory' : 'hass:home-flood', + 'Volcano Warning' : 'hass:image-filter-hdr', + 'Wind Advisory' : 'hass:weather-windy', + 'Wind Chill Advisory' : 'hass:thermometer-minus', + 'Wind Chill Warning' : 'hass:thermometer-minus', + 'Wind Chill Watch' : 'hass:thermometer-minus', + 'Winter Storm Warning' : 'hass:snowflake-alert', + 'Winter Storm Watch' : 'hass:snowflake-alert', + 'Winter Weather Advisory' : 'hass:snowflake-alert' } %} + {% set state = states['sensor.weatheralerts_2_alert_1'].attributes.alert_event %} + {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }} value_template: >- - {% if (states('sensor.weatheralerts_2') != 'unavailable') and (state_attr('sensor.weatheralerts_2', 'alerts')[0] != null) or ((states('sensor.weatheralerts_2') == 'unavailable') and (as_timestamp(state_attr('sensor.weatheralerts_2', 'alerts')[0].endsExpires) - as_timestamp(now()) > 0)) %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and (state_attr('sensor.weatheralerts_2', 'alerts')[0] != null) or (not is_state('sensor.weatheralerts_2', 'unavailable') and (state_attr('sensor.weatheralerts_2', 'alerts')[0] != null) and (as_timestamp(state_attr('sensor.weatheralerts_2', 'alerts')[0].endsExpires) - as_timestamp(now()) > 0)) %} on {% else %} off {% endif %} attribute_templates: alert_id: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].id }} {% else %} None {% endif %} alert_event: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].event }} {% else %} None {% endif %} alert_area: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].area }} {% else %} None {% endif %} alert_NWSheadline: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') }} {% else %} None {% endif %} alert_description: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].description }} {% else %} None {% endif %} alert_messageType: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].messageType }} {% else %} None {% endif %} alert_status: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].status }} {% else %} None {% endif %} alert_category: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].category }} {% else %} None {% endif %} alert_urgency: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].urgency }} {% else %} None {% endif %} alert_severity: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].severity }} {% else %} None {% endif %} alert_certainty: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].certainty }} {% else %} None {% endif %} alert_response: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].response }} {% else %} None {% endif %} alert_instruction: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].instruction }} {% else %} None {% endif %} alert_sent: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].sent }} {% else %} None {% endif %} alert_effective: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].effective }} {% else %} None {% endif %} alert_onset: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].onset }} {% else %} None {% endif %} alert_expires: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].expires }} {% else %} None {% endif %} alert_title: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].title }} {% else %} None {% endif %} alert_zoneid: >- - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].zoneid }} {% else %} None {% endif %} display_title: > - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].title }} {% else %} None {% endif %} display_message: > - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {% if states.sensor.weatheralerts_2.attributes.alerts[0].NWSheadline != "null" %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') }}
{% endif %} @@ -310,20 +441,20 @@ sensor:
Where : {{ state_attr('sensor.weatheralerts_2', 'friendly_name') }}
Effective: {{ states.sensor.weatheralerts_2.attributes.alerts[0].effective }} {%- if states.sensor.weatheralerts_2.attributes.alerts[0].ends != None %} -
Ends: {{ states.sensor.weatheralerts_2.attributes.alerts[0].ends }} +
Ends: {{ states.sensor.weatheralerts_2.attributes.alerts[0].ends }} {%- endif %}
Expires: {{ states.sensor.weatheralerts_2.attributes.alerts[0].expires }} {% else %} None {% endif %} spoken_title: > - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} Attention!!! Weather alert for {{ state_attr('sensor.weatheralerts_2', 'friendly_name') }}. A {{ states.sensor.weatheralerts_2.attributes.alerts[0].title }}. {{ states.sensor.weatheralerts_2.attributes.alerts[0].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') | capitalize }}. {% else %} None {% endif %} spoken_message: > - {% if states('sensor.weatheralerts_2')|int > 0 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_1') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_1', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 0)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].description | regex_replace('\n\n','

') | regex_replace('\n',' ') | regex_replace('\*','\n*') | regex_replace('

','\n\n') }} {% if states.sensor.weatheralerts_2.attributes.alerts[0].instruction != None %} {{ states.sensor.weatheralerts_2.attributes.alerts[0].instruction | regex_replace('\n\n','

') | regex_replace('\n',' ') | regex_replace('\*','\n*') | regex_replace('

','\n\n') }} @@ -333,136 +464,267 @@ sensor: {% endif %} weatheralerts_2_alert_2: friendly_name: Weather Alert 2 - icon_template: mdi:alert-rhombus + icon_template: >- + {% set mapper = { + '911 Telephone Outage Emergency' : 'hass:phone-alert', + 'Administrative Message' : 'hass:message-text', + 'Air Quality Alert' : 'hass:blur', + 'Air Stagnation Advisory' : 'hass:blur', + 'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert', + 'Ashfall Advisory' : 'hass:cloud-alert', + 'Ashfall Warning' : 'hass:cloud-alert', + 'Avalanche Advisory' : 'hass:alert', + 'Avalanche Warning' : 'hass:alert', + 'Avalanche Watch' : 'hass:alert', + 'Beach Hazards Statement' : 'hass:beach', + 'Blizzard Warning' : 'hass:snowflake-alert', + 'Blizzard Watch' : 'hass:snowflake-alert', + 'Blowing Dust Advisory' : 'hass:blur', + 'Blowing Dust Warning' : 'hass:blur', + 'Brisk Wind Advisory' : 'hass:weather-windy', + 'Child Abduction Emergency' : 'hass:human-male-child', + 'Civil Danger Warning' : 'hass:image-filter-hdr', + 'Civil Emergency Message' : 'hass:image-filter-hdr', + 'Coastal Flood Advisory' : 'hass:waves', + 'Coastal Flood Statement' : 'hass:waves', + 'Coastal Flood Warning' : 'hass:waves', + 'Coastal Flood Watch' : 'hass:waves', + 'Dense Fog Advisory' : 'hass:weather-fog', + 'Dense Smoke Advisory' : 'hass:smoke', + 'Dust Advisory' : 'hass:blur', + 'Dust Storm Warning' : 'hass:blur', + 'Earthquake Warning' : 'hass:alert', + 'Evacuation - Immediate' : 'hass:exit-run', + 'Excessive Heat Warning' : 'hass:thermometer-plus', + 'Excessive Heat Watch' : 'hass:thermometer-plus', + 'Extreme Cold Warning' : 'hass:thermometer-minus', + 'Extreme Cold Watch' : 'hass:thermometer-minus', + 'Extreme Fire Danger' : 'hass:fire-alert', + 'Extreme Wind Warning' : 'hass:weather-windy', + 'Fire Warning' : 'hass:fire-alert', + 'Fire Weather Watch' : 'hass:fire-alert', + 'Flash Flood Statement' : 'hass:water-alert', + 'Flash Flood Warning' : 'hass:water-alert', + 'Flash Flood Watch' : 'hass:water-alert', + 'Flood Advisory' : 'hass:water-alert', + 'Flood Statement' : 'hass:water-alert', + 'Flood Warning' : 'hass:water-alert', + 'Flood Watch' : 'hass:water-alert', + 'Freeze Warning' : 'hass:thermometer-minus', + 'Freeze Watch' : 'hass:thermometer-minus', + 'Freezing Fog Advisory' : 'hass:snowflake-alert', + 'Freezing Rain Advisory' : 'hass:snowflake-alert', + 'Freezing Spray Advisory' : 'hass:snowflake-alert', + 'Frost Advisory' : 'hass:snowflake-alert', + 'Gale Warning' : 'hass:weather-windy', + 'Gale Watch' : 'hass:weather-windy', + 'Hard Freeze Warning' : 'hass:thermometer-minus', + 'Hard Freeze Watch' : 'hass:thermometer-minus', + 'Hazardous Materials Warning' : 'hass:radioactive', + 'Hazardous Seas Warning' : 'hass:sail-boat', + 'Hazardous Seas Watch' : 'hass:sail-boat', + 'Hazardous Weather Outlook' : 'hass:message-alert', + 'Heat Advisory' : 'hass:thermometer-plus', + 'Heavy Freezing Spray Warning' : 'hass:snowflake-alert', + 'Heavy Freezing Spray Watch' : 'hass:snowflake-alert', + 'High Surf Advisory' : 'hass:surfing', + 'High Surf Warning' : 'hass:surfing', + 'High Wind Warning' : 'hass:weather-windy', + 'High Wind Watch' : 'hass:weather-windy', + 'Hurricane Force Wind Warning' : 'hass:weather-hurricane', + 'Hurricane Force Wind Watch' : 'hass:weather-hurricane', + 'Hurricane Local Statement' : 'hass:weather-hurricane', + 'Hurricane Warning' : 'hass:weather-hurricane', + 'Hurricane Watch' : 'hass:weather-hurricane', + 'Hydrologic Advisory' : 'hass:message-text', + 'Hydrologic Outlook' : 'hass:message-text', + 'Ice Storm Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Advisory' : 'hass:snowflake-alert', + 'Lake Effect Snow Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Watch' : 'hass:snowflake-alert', + 'Lake Wind Advisory' : 'hass:weather-windy', + 'Lakeshore Flood Advisory' : 'hass:waves-arrow-up', + 'Lakeshore Flood Statement' : 'hass:waves-arrow-up', + 'Lakeshore Flood Warning' : 'hass:waves-arrow-up', + 'Lakeshore Flood Watch' : 'hass:waves-arrow-up', + 'Law Enforcement Warning' : 'hass:car-emergency', + 'Local Area Emergency' : 'hass:alert', + 'Low Water Advisory' : 'hass:wave', + 'Marine Weather Statement' : 'hass:sail-boat', + 'Nuclear Power Plant Warning' : 'hass:radioactive', + 'Radiological Hazard Warning' : 'hass:biohazard', + 'Red Flag Warning' : 'fire-alert', + 'Rip Current Statement' : 'hass:surfing', + 'Severe Thunderstorm Warning' : 'hass:weather-lightning', + 'Severe Thunderstorm Watch' : 'hass:weather-lightning', + 'Severe Weather Statement' : 'hass:message-text', + 'Shelter In Place Warning' : 'hass:account-box', + 'Short Term Forecast' : 'hass:message-text', + 'Small Craft Advisory' : 'hass:sail-boat', + 'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat', + 'Small Craft Advisory For Rough Bar' : 'hass:sail-boat', + 'Small Craft Advisory For Winds' : 'hass:sail-boat', + 'Small Stream Flood Advisory' : 'hass:water-alert', + 'Snow Squall Warning' : 'hass:snowflake-alert', + 'Special Marine Warning' : 'hass:sail-boat', + 'Special Weather Statement' : 'hass:message-alert', + 'Storm Surge Warning' : 'hass:waves-arrow-up', + 'Storm Surge Watch' : 'hass:waves-arrow-up', + 'Storm Warning' : 'hass:weather-lightning', + 'Storm Watch' : 'hass:weather-lightning', + 'Test' : 'hass:message-text', + 'Tornado Warning' : 'hass:weather-tornado', + 'Tornado Watch' : 'hass:weather-tornado', + 'Tropical Depression Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Warning' : 'hass:weather-hurricane', + 'Tropical Storm Watch' : 'hass:weather-hurricane', + 'Tsunami Advisory' : 'hass:waves-arrow-up', + 'Tsunami Warning' : 'hass:waves-arrow-up', + 'Tsunami Watch' : 'hass:waves-arrow-up', + 'Typhoon Local Statement' : 'hass:weather-hurricane', + 'Typhoon Warning' : 'hass:weather-hurricane', + 'Typhoon Watch' : 'hass:weather-hurricane', + 'Urban And Small Stream Flood Advisory' : 'hass:home-flood', + 'Volcano Warning' : 'hass:image-filter-hdr', + 'Wind Advisory' : 'hass:weather-windy', + 'Wind Chill Advisory' : 'hass:thermometer-minus', + 'Wind Chill Warning' : 'hass:thermometer-minus', + 'Wind Chill Watch' : 'hass:thermometer-minus', + 'Winter Storm Warning' : 'hass:snowflake-alert', + 'Winter Storm Watch' : 'hass:snowflake-alert', + 'Winter Weather Advisory' : 'hass:snowflake-alert' } %} + {% set state = states['sensor.weatheralerts_2_alert_2'].attributes.alert_event %} + {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }} value_template: >- - {% if (states('sensor.weatheralerts_2') != 'unavailable') and (state_attr('sensor.weatheralerts_2', 'alerts')[1] != null) or ((states('sensor.weatheralerts_2') == 'unavailable') and (as_timestamp(state_attr('sensor.weatheralerts_2', 'alerts')[1].endsExpires) - as_timestamp(now()) > 0)) %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and (state_attr('sensor.weatheralerts_2', 'alerts')[1] != null) or (not is_state('sensor.weatheralerts_2', 'unavailable') and (state_attr('sensor.weatheralerts_2', 'alerts')[1] != null) and (as_timestamp(state_attr('sensor.weatheralerts_2', 'alerts')[1].endsExpires) - as_timestamp(now()) > 0)) %} on {% else %} off {% endif %} attribute_templates: alert_id: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].id }} {% else %} None {% endif %} alert_event: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].event }} {% else %} None {% endif %} alert_area: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].area }} {% else %} None {% endif %} alert_NWSheadline: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') }} {% else %} None {% endif %} alert_description: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].description }} {% else %} None {% endif %} alert_messageType: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].messageType }} {% else %} None {% endif %} alert_status: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].status }} {% else %} None {% endif %} alert_category: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].category }} {% else %} None {% endif %} alert_urgency: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].urgency }} {% else %} None {% endif %} alert_severity: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].severity }} {% else %} None {% endif %} alert_certainty: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].certainty }} {% else %} None {% endif %} alert_response: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].response }} {% else %} None {% endif %} alert_instruction: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].instruction }} {% else %} None {% endif %} alert_sent: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].sent }} {% else %} None {% endif %} alert_effective: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].effective }} {% else %} None {% endif %} alert_onset: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].onset }} {% else %} None {% endif %} alert_expires: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].expires }} {% else %} None {% endif %} alert_title: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].title }} {% else %} None {% endif %} alert_zoneid: >- - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].zoneid }} {% else %} None {% endif %} display_title: > - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].title }} {% else %} None {% endif %} display_message: > - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {% if states.sensor.weatheralerts_2.attributes.alerts[1].NWSheadline != "null" %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') }}
{% endif %} @@ -480,13 +742,13 @@ sensor: None {% endif %} spoken_title: > - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} Attention!!! Weather alert for {{ state_attr('sensor.weatheralerts_2', 'friendly_name') }}. A {{ states.sensor.weatheralerts_2.attributes.alerts[1].title }}. {{ states.sensor.weatheralerts_2.attributes.alerts[1].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') | capitalize }}. {% else %} None {% endif %} spoken_message: > - {% if states('sensor.weatheralerts_2')|int > 1 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_2') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_2', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 1)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].description | regex_replace('\n\n','

') | regex_replace('\n',' ') | regex_replace('\*','\n*') | regex_replace('

','\n\n') }} {% if states.sensor.weatheralerts_2.attributes.alerts[1].instruction != None %} {{ states.sensor.weatheralerts_2.attributes.alerts[1].instruction | regex_replace('\n\n','

') | regex_replace('\n',' ') | regex_replace('\*','\n*') | regex_replace('

','\n\n') }} @@ -496,136 +758,267 @@ sensor: {% endif %} weatheralerts_2_alert_3: friendly_name: Weather Alert 3 - icon_template: mdi:alert-rhombus + icon_template: >- + {% set mapper = { + '911 Telephone Outage Emergency' : 'hass:phone-alert', + 'Administrative Message' : 'hass:message-text', + 'Air Quality Alert' : 'hass:blur', + 'Air Stagnation Advisory' : 'hass:blur', + 'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert', + 'Ashfall Advisory' : 'hass:cloud-alert', + 'Ashfall Warning' : 'hass:cloud-alert', + 'Avalanche Advisory' : 'hass:alert', + 'Avalanche Warning' : 'hass:alert', + 'Avalanche Watch' : 'hass:alert', + 'Beach Hazards Statement' : 'hass:beach', + 'Blizzard Warning' : 'hass:snowflake-alert', + 'Blizzard Watch' : 'hass:snowflake-alert', + 'Blowing Dust Advisory' : 'hass:blur', + 'Blowing Dust Warning' : 'hass:blur', + 'Brisk Wind Advisory' : 'hass:weather-windy', + 'Child Abduction Emergency' : 'hass:human-male-child', + 'Civil Danger Warning' : 'hass:image-filter-hdr', + 'Civil Emergency Message' : 'hass:image-filter-hdr', + 'Coastal Flood Advisory' : 'hass:waves', + 'Coastal Flood Statement' : 'hass:waves', + 'Coastal Flood Warning' : 'hass:waves', + 'Coastal Flood Watch' : 'hass:waves', + 'Dense Fog Advisory' : 'hass:weather-fog', + 'Dense Smoke Advisory' : 'hass:smoke', + 'Dust Advisory' : 'hass:blur', + 'Dust Storm Warning' : 'hass:blur', + 'Earthquake Warning' : 'hass:alert', + 'Evacuation - Immediate' : 'hass:exit-run', + 'Excessive Heat Warning' : 'hass:thermometer-plus', + 'Excessive Heat Watch' : 'hass:thermometer-plus', + 'Extreme Cold Warning' : 'hass:thermometer-minus', + 'Extreme Cold Watch' : 'hass:thermometer-minus', + 'Extreme Fire Danger' : 'hass:fire-alert', + 'Extreme Wind Warning' : 'hass:weather-windy', + 'Fire Warning' : 'hass:fire-alert', + 'Fire Weather Watch' : 'hass:fire-alert', + 'Flash Flood Statement' : 'hass:water-alert', + 'Flash Flood Warning' : 'hass:water-alert', + 'Flash Flood Watch' : 'hass:water-alert', + 'Flood Advisory' : 'hass:water-alert', + 'Flood Statement' : 'hass:water-alert', + 'Flood Warning' : 'hass:water-alert', + 'Flood Watch' : 'hass:water-alert', + 'Freeze Warning' : 'hass:thermometer-minus', + 'Freeze Watch' : 'hass:thermometer-minus', + 'Freezing Fog Advisory' : 'hass:snowflake-alert', + 'Freezing Rain Advisory' : 'hass:snowflake-alert', + 'Freezing Spray Advisory' : 'hass:snowflake-alert', + 'Frost Advisory' : 'hass:snowflake-alert', + 'Gale Warning' : 'hass:weather-windy', + 'Gale Watch' : 'hass:weather-windy', + 'Hard Freeze Warning' : 'hass:thermometer-minus', + 'Hard Freeze Watch' : 'hass:thermometer-minus', + 'Hazardous Materials Warning' : 'hass:radioactive', + 'Hazardous Seas Warning' : 'hass:sail-boat', + 'Hazardous Seas Watch' : 'hass:sail-boat', + 'Hazardous Weather Outlook' : 'hass:message-alert', + 'Heat Advisory' : 'hass:thermometer-plus', + 'Heavy Freezing Spray Warning' : 'hass:snowflake-alert', + 'Heavy Freezing Spray Watch' : 'hass:snowflake-alert', + 'High Surf Advisory' : 'hass:surfing', + 'High Surf Warning' : 'hass:surfing', + 'High Wind Warning' : 'hass:weather-windy', + 'High Wind Watch' : 'hass:weather-windy', + 'Hurricane Force Wind Warning' : 'hass:weather-hurricane', + 'Hurricane Force Wind Watch' : 'hass:weather-hurricane', + 'Hurricane Local Statement' : 'hass:weather-hurricane', + 'Hurricane Warning' : 'hass:weather-hurricane', + 'Hurricane Watch' : 'hass:weather-hurricane', + 'Hydrologic Advisory' : 'hass:message-text', + 'Hydrologic Outlook' : 'hass:message-text', + 'Ice Storm Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Advisory' : 'hass:snowflake-alert', + 'Lake Effect Snow Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Watch' : 'hass:snowflake-alert', + 'Lake Wind Advisory' : 'hass:weather-windy', + 'Lakeshore Flood Advisory' : 'hass:waves-arrow-up', + 'Lakeshore Flood Statement' : 'hass:waves-arrow-up', + 'Lakeshore Flood Warning' : 'hass:waves-arrow-up', + 'Lakeshore Flood Watch' : 'hass:waves-arrow-up', + 'Law Enforcement Warning' : 'hass:car-emergency', + 'Local Area Emergency' : 'hass:alert', + 'Low Water Advisory' : 'hass:wave', + 'Marine Weather Statement' : 'hass:sail-boat', + 'Nuclear Power Plant Warning' : 'hass:radioactive', + 'Radiological Hazard Warning' : 'hass:biohazard', + 'Red Flag Warning' : 'fire-alert', + 'Rip Current Statement' : 'hass:surfing', + 'Severe Thunderstorm Warning' : 'hass:weather-lightning', + 'Severe Thunderstorm Watch' : 'hass:weather-lightning', + 'Severe Weather Statement' : 'hass:message-text', + 'Shelter In Place Warning' : 'hass:account-box', + 'Short Term Forecast' : 'hass:message-text', + 'Small Craft Advisory' : 'hass:sail-boat', + 'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat', + 'Small Craft Advisory For Rough Bar' : 'hass:sail-boat', + 'Small Craft Advisory For Winds' : 'hass:sail-boat', + 'Small Stream Flood Advisory' : 'hass:water-alert', + 'Snow Squall Warning' : 'hass:snowflake-alert', + 'Special Marine Warning' : 'hass:sail-boat', + 'Special Weather Statement' : 'hass:message-alert', + 'Storm Surge Warning' : 'hass:waves-arrow-up', + 'Storm Surge Watch' : 'hass:waves-arrow-up', + 'Storm Warning' : 'hass:weather-lightning', + 'Storm Watch' : 'hass:weather-lightning', + 'Test' : 'hass:message-text', + 'Tornado Warning' : 'hass:weather-tornado', + 'Tornado Watch' : 'hass:weather-tornado', + 'Tropical Depression Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Warning' : 'hass:weather-hurricane', + 'Tropical Storm Watch' : 'hass:weather-hurricane', + 'Tsunami Advisory' : 'hass:waves-arrow-up', + 'Tsunami Warning' : 'hass:waves-arrow-up', + 'Tsunami Watch' : 'hass:waves-arrow-up', + 'Typhoon Local Statement' : 'hass:weather-hurricane', + 'Typhoon Warning' : 'hass:weather-hurricane', + 'Typhoon Watch' : 'hass:weather-hurricane', + 'Urban And Small Stream Flood Advisory' : 'hass:home-flood', + 'Volcano Warning' : 'hass:image-filter-hdr', + 'Wind Advisory' : 'hass:weather-windy', + 'Wind Chill Advisory' : 'hass:thermometer-minus', + 'Wind Chill Warning' : 'hass:thermometer-minus', + 'Wind Chill Watch' : 'hass:thermometer-minus', + 'Winter Storm Warning' : 'hass:snowflake-alert', + 'Winter Storm Watch' : 'hass:snowflake-alert', + 'Winter Weather Advisory' : 'hass:snowflake-alert' } %} + {% set state = states['sensor.weatheralerts_2_alert_3'].attributes.alert_event %} + {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }} value_template: >- - {% if (states('sensor.weatheralerts_2') != 'unavailable') and (state_attr('sensor.weatheralerts_2', 'alerts')[2] != null) or ((states('sensor.weatheralerts_2') == 'unavailable') and (as_timestamp(state_attr('sensor.weatheralerts_2', 'alerts')[2].endsExpires) - as_timestamp(now()) > 0)) %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and (state_attr('sensor.weatheralerts_2', 'alerts')[2] != null) or (not is_state('sensor.weatheralerts_2', 'unavailable') and (state_attr('sensor.weatheralerts_2', 'alerts')[2] != null) and (as_timestamp(state_attr('sensor.weatheralerts_2', 'alerts')[2].endsExpires) - as_timestamp(now()) > 0)) %} on {% else %} off {% endif %} attribute_templates: alert_id: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].id }} {% else %} None {% endif %} alert_event: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].event }} {% else %} None {% endif %} alert_area: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].area }} {% else %} None {% endif %} alert_NWSheadline: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') }} {% else %} None {% endif %} alert_description: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].description }} {% else %} None {% endif %} alert_messageType: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].messageType }} {% else %} None {% endif %} alert_status: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].status }} {% else %} None {% endif %} alert_category: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].category }} {% else %} None {% endif %} alert_urgency: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].urgency }} {% else %} None {% endif %} alert_severity: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].severity }} {% else %} None {% endif %} alert_certainty: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].certainty }} {% else %} None {% endif %} alert_response: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].response }} {% else %} None {% endif %} alert_instruction: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].instruction }} {% else %} None {% endif %} alert_sent: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].sent }} {% else %} None {% endif %} alert_effective: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].effective }} {% else %} None {% endif %} alert_onset: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].onset }} {% else %} None {% endif %} alert_expires: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].expires }} {% else %} None {% endif %} alert_title: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].title }} {% else %} None {% endif %} alert_zoneid: >- - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].zoneid }} {% else %} None {% endif %} display_title: > - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].title }} {% else %} None {% endif %} display_message: > - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {% if states.sensor.weatheralerts_2.attributes.alerts[2].NWSheadline != "null" %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') }}
{% endif %} @@ -643,13 +1036,13 @@ sensor: None {% endif %} spoken_title: > - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} Attention!!! Weather alert for {{ state_attr('sensor.weatheralerts_2', 'friendly_name') }}. A {{ states.sensor.weatheralerts_2.attributes.alerts[2].title }}. {{ states.sensor.weatheralerts_2.attributes.alerts[2].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') | capitalize }}. {% else %} None {% endif %} spoken_message: > - {% if states('sensor.weatheralerts_2')|int > 2 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_3') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_3', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 2)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].description | regex_replace('\n\n','

') | regex_replace('\n',' ') | regex_replace('\*','\n*') | regex_replace('

','\n\n') }} {% if states.sensor.weatheralerts_2.attributes.alerts[2].instruction != None %} {{ states.sensor.weatheralerts_2.attributes.alerts[2].instruction | regex_replace('\n\n','

') | regex_replace('\n',' ') | regex_replace('\*','\n*') | regex_replace('

','\n\n') }} @@ -659,136 +1052,267 @@ sensor: {% endif %} weatheralerts_2_alert_4: friendly_name: Weather Alert 4 - icon_template: mdi:alert-rhombus + icon_template: >- + {% set mapper = { + '911 Telephone Outage Emergency' : 'hass:phone-alert', + 'Administrative Message' : 'hass:message-text', + 'Air Quality Alert' : 'hass:blur', + 'Air Stagnation Advisory' : 'hass:blur', + 'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert', + 'Ashfall Advisory' : 'hass:cloud-alert', + 'Ashfall Warning' : 'hass:cloud-alert', + 'Avalanche Advisory' : 'hass:alert', + 'Avalanche Warning' : 'hass:alert', + 'Avalanche Watch' : 'hass:alert', + 'Beach Hazards Statement' : 'hass:beach', + 'Blizzard Warning' : 'hass:snowflake-alert', + 'Blizzard Watch' : 'hass:snowflake-alert', + 'Blowing Dust Advisory' : 'hass:blur', + 'Blowing Dust Warning' : 'hass:blur', + 'Brisk Wind Advisory' : 'hass:weather-windy', + 'Child Abduction Emergency' : 'hass:human-male-child', + 'Civil Danger Warning' : 'hass:image-filter-hdr', + 'Civil Emergency Message' : 'hass:image-filter-hdr', + 'Coastal Flood Advisory' : 'hass:waves', + 'Coastal Flood Statement' : 'hass:waves', + 'Coastal Flood Warning' : 'hass:waves', + 'Coastal Flood Watch' : 'hass:waves', + 'Dense Fog Advisory' : 'hass:weather-fog', + 'Dense Smoke Advisory' : 'hass:smoke', + 'Dust Advisory' : 'hass:blur', + 'Dust Storm Warning' : 'hass:blur', + 'Earthquake Warning' : 'hass:alert', + 'Evacuation - Immediate' : 'hass:exit-run', + 'Excessive Heat Warning' : 'hass:thermometer-plus', + 'Excessive Heat Watch' : 'hass:thermometer-plus', + 'Extreme Cold Warning' : 'hass:thermometer-minus', + 'Extreme Cold Watch' : 'hass:thermometer-minus', + 'Extreme Fire Danger' : 'hass:fire-alert', + 'Extreme Wind Warning' : 'hass:weather-windy', + 'Fire Warning' : 'hass:fire-alert', + 'Fire Weather Watch' : 'hass:fire-alert', + 'Flash Flood Statement' : 'hass:water-alert', + 'Flash Flood Warning' : 'hass:water-alert', + 'Flash Flood Watch' : 'hass:water-alert', + 'Flood Advisory' : 'hass:water-alert', + 'Flood Statement' : 'hass:water-alert', + 'Flood Warning' : 'hass:water-alert', + 'Flood Watch' : 'hass:water-alert', + 'Freeze Warning' : 'hass:thermometer-minus', + 'Freeze Watch' : 'hass:thermometer-minus', + 'Freezing Fog Advisory' : 'hass:snowflake-alert', + 'Freezing Rain Advisory' : 'hass:snowflake-alert', + 'Freezing Spray Advisory' : 'hass:snowflake-alert', + 'Frost Advisory' : 'hass:snowflake-alert', + 'Gale Warning' : 'hass:weather-windy', + 'Gale Watch' : 'hass:weather-windy', + 'Hard Freeze Warning' : 'hass:thermometer-minus', + 'Hard Freeze Watch' : 'hass:thermometer-minus', + 'Hazardous Materials Warning' : 'hass:radioactive', + 'Hazardous Seas Warning' : 'hass:sail-boat', + 'Hazardous Seas Watch' : 'hass:sail-boat', + 'Hazardous Weather Outlook' : 'hass:message-alert', + 'Heat Advisory' : 'hass:thermometer-plus', + 'Heavy Freezing Spray Warning' : 'hass:snowflake-alert', + 'Heavy Freezing Spray Watch' : 'hass:snowflake-alert', + 'High Surf Advisory' : 'hass:surfing', + 'High Surf Warning' : 'hass:surfing', + 'High Wind Warning' : 'hass:weather-windy', + 'High Wind Watch' : 'hass:weather-windy', + 'Hurricane Force Wind Warning' : 'hass:weather-hurricane', + 'Hurricane Force Wind Watch' : 'hass:weather-hurricane', + 'Hurricane Local Statement' : 'hass:weather-hurricane', + 'Hurricane Warning' : 'hass:weather-hurricane', + 'Hurricane Watch' : 'hass:weather-hurricane', + 'Hydrologic Advisory' : 'hass:message-text', + 'Hydrologic Outlook' : 'hass:message-text', + 'Ice Storm Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Advisory' : 'hass:snowflake-alert', + 'Lake Effect Snow Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Watch' : 'hass:snowflake-alert', + 'Lake Wind Advisory' : 'hass:weather-windy', + 'Lakeshore Flood Advisory' : 'hass:waves-arrow-up', + 'Lakeshore Flood Statement' : 'hass:waves-arrow-up', + 'Lakeshore Flood Warning' : 'hass:waves-arrow-up', + 'Lakeshore Flood Watch' : 'hass:waves-arrow-up', + 'Law Enforcement Warning' : 'hass:car-emergency', + 'Local Area Emergency' : 'hass:alert', + 'Low Water Advisory' : 'hass:wave', + 'Marine Weather Statement' : 'hass:sail-boat', + 'Nuclear Power Plant Warning' : 'hass:radioactive', + 'Radiological Hazard Warning' : 'hass:biohazard', + 'Red Flag Warning' : 'fire-alert', + 'Rip Current Statement' : 'hass:surfing', + 'Severe Thunderstorm Warning' : 'hass:weather-lightning', + 'Severe Thunderstorm Watch' : 'hass:weather-lightning', + 'Severe Weather Statement' : 'hass:message-text', + 'Shelter In Place Warning' : 'hass:account-box', + 'Short Term Forecast' : 'hass:message-text', + 'Small Craft Advisory' : 'hass:sail-boat', + 'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat', + 'Small Craft Advisory For Rough Bar' : 'hass:sail-boat', + 'Small Craft Advisory For Winds' : 'hass:sail-boat', + 'Small Stream Flood Advisory' : 'hass:water-alert', + 'Snow Squall Warning' : 'hass:snowflake-alert', + 'Special Marine Warning' : 'hass:sail-boat', + 'Special Weather Statement' : 'hass:message-alert', + 'Storm Surge Warning' : 'hass:waves-arrow-up', + 'Storm Surge Watch' : 'hass:waves-arrow-up', + 'Storm Warning' : 'hass:weather-lightning', + 'Storm Watch' : 'hass:weather-lightning', + 'Test' : 'hass:message-text', + 'Tornado Warning' : 'hass:weather-tornado', + 'Tornado Watch' : 'hass:weather-tornado', + 'Tropical Depression Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Warning' : 'hass:weather-hurricane', + 'Tropical Storm Watch' : 'hass:weather-hurricane', + 'Tsunami Advisory' : 'hass:waves-arrow-up', + 'Tsunami Warning' : 'hass:waves-arrow-up', + 'Tsunami Watch' : 'hass:waves-arrow-up', + 'Typhoon Local Statement' : 'hass:weather-hurricane', + 'Typhoon Warning' : 'hass:weather-hurricane', + 'Typhoon Watch' : 'hass:weather-hurricane', + 'Urban And Small Stream Flood Advisory' : 'hass:home-flood', + 'Volcano Warning' : 'hass:image-filter-hdr', + 'Wind Advisory' : 'hass:weather-windy', + 'Wind Chill Advisory' : 'hass:thermometer-minus', + 'Wind Chill Warning' : 'hass:thermometer-minus', + 'Wind Chill Watch' : 'hass:thermometer-minus', + 'Winter Storm Warning' : 'hass:snowflake-alert', + 'Winter Storm Watch' : 'hass:snowflake-alert', + 'Winter Weather Advisory' : 'hass:snowflake-alert' } %} + {% set state = states['sensor.weatheralerts_2_alert_4'].attributes.alert_event %} + {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }} value_template: >- - {% if (states('sensor.weatheralerts_2') != 'unavailable') and (state_attr('sensor.weatheralerts_2', 'alerts')[3] != null) or ((states('sensor.weatheralerts_2') == 'unavailable') and (as_timestamp(state_attr('sensor.weatheralerts_2', 'alerts')[3].endsExpires) - as_timestamp(now()) > 0)) %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and (state_attr('sensor.weatheralerts_2', 'alerts')[3] != null) or (not is_state('sensor.weatheralerts_2', 'unavailable') and (state_attr('sensor.weatheralerts_2', 'alerts')[3] != null) and (as_timestamp(state_attr('sensor.weatheralerts_2', 'alerts')[3].endsExpires) - as_timestamp(now()) > 0)) %} on {% else %} off {% endif %} attribute_templates: alert_id: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].id }} {% else %} None {% endif %} alert_event: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].event }} {% else %} None {% endif %} alert_area: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].area }} {% else %} None {% endif %} alert_NWSheadline: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') }} {% else %} None {% endif %} alert_description: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].description }} {% else %} None {% endif %} alert_messageType: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].messageType }} {% else %} None {% endif %} alert_status: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].status }} {% else %} None {% endif %} alert_category: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].category }} {% else %} None {% endif %} alert_urgency: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].urgency }} {% else %} None {% endif %} alert_severity: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].severity }} {% else %} None {% endif %} alert_certainty: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].certainty }} {% else %} None {% endif %} alert_response: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].response }} {% else %} None {% endif %} alert_instruction: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].instruction }} {% else %} None {% endif %} alert_sent: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].sent }} {% else %} None {% endif %} alert_effective: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].effective }} {% else %} None {% endif %} alert_onset: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].onset }} {% else %} None {% endif %} alert_expires: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].expires }} {% else %} None {% endif %} alert_title: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].title }} {% else %} None {% endif %} alert_zoneid: >- - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].zoneid }} {% else %} None {% endif %} display_title: > - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].title }} {% else %} None {% endif %} display_message: > - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {% if states.sensor.weatheralerts_2.attributes.alerts[3].NWSheadline != "null" %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') }}
{% endif %} @@ -806,13 +1330,13 @@ sensor: None {% endif %} spoken_title: > - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} Attention!!! Weather alert for {{ state_attr('sensor.weatheralerts_2', 'friendly_name') }}. A {{ states.sensor.weatheralerts_2.attributes.alerts[3].title }}. {{ states.sensor.weatheralerts_2.attributes.alerts[3].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') | capitalize }}. {% else %} None {% endif %} spoken_message: > - {% if states('sensor.weatheralerts_2')|int > 3 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_4') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_4', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 3)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].description | regex_replace('\n\n','

') | regex_replace('\n',' ') | regex_replace('\*','\n*') | regex_replace('

','\n\n') }} {% if states.sensor.weatheralerts_2.attributes.alerts[3].instruction != None %} {{ states.sensor.weatheralerts_2.attributes.alerts[3].instruction | regex_replace('\n\n','

') | regex_replace('\n',' ') | regex_replace('\*','\n*') | regex_replace('

','\n\n') }} @@ -822,136 +1346,267 @@ sensor: {% endif %} weatheralerts_2_alert_5: friendly_name: Weather Alert 5 - icon_template: mdi:alert-rhombus + icon_template: >- + {% set mapper = { + '911 Telephone Outage Emergency' : 'hass:phone-alert', + 'Administrative Message' : 'hass:message-text', + 'Air Quality Alert' : 'hass:blur', + 'Air Stagnation Advisory' : 'hass:blur', + 'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert', + 'Ashfall Advisory' : 'hass:cloud-alert', + 'Ashfall Warning' : 'hass:cloud-alert', + 'Avalanche Advisory' : 'hass:alert', + 'Avalanche Warning' : 'hass:alert', + 'Avalanche Watch' : 'hass:alert', + 'Beach Hazards Statement' : 'hass:beach', + 'Blizzard Warning' : 'hass:snowflake-alert', + 'Blizzard Watch' : 'hass:snowflake-alert', + 'Blowing Dust Advisory' : 'hass:blur', + 'Blowing Dust Warning' : 'hass:blur', + 'Brisk Wind Advisory' : 'hass:weather-windy', + 'Child Abduction Emergency' : 'hass:human-male-child', + 'Civil Danger Warning' : 'hass:image-filter-hdr', + 'Civil Emergency Message' : 'hass:image-filter-hdr', + 'Coastal Flood Advisory' : 'hass:waves', + 'Coastal Flood Statement' : 'hass:waves', + 'Coastal Flood Warning' : 'hass:waves', + 'Coastal Flood Watch' : 'hass:waves', + 'Dense Fog Advisory' : 'hass:weather-fog', + 'Dense Smoke Advisory' : 'hass:smoke', + 'Dust Advisory' : 'hass:blur', + 'Dust Storm Warning' : 'hass:blur', + 'Earthquake Warning' : 'hass:alert', + 'Evacuation - Immediate' : 'hass:exit-run', + 'Excessive Heat Warning' : 'hass:thermometer-plus', + 'Excessive Heat Watch' : 'hass:thermometer-plus', + 'Extreme Cold Warning' : 'hass:thermometer-minus', + 'Extreme Cold Watch' : 'hass:thermometer-minus', + 'Extreme Fire Danger' : 'hass:fire-alert', + 'Extreme Wind Warning' : 'hass:weather-windy', + 'Fire Warning' : 'hass:fire-alert', + 'Fire Weather Watch' : 'hass:fire-alert', + 'Flash Flood Statement' : 'hass:water-alert', + 'Flash Flood Warning' : 'hass:water-alert', + 'Flash Flood Watch' : 'hass:water-alert', + 'Flood Advisory' : 'hass:water-alert', + 'Flood Statement' : 'hass:water-alert', + 'Flood Warning' : 'hass:water-alert', + 'Flood Watch' : 'hass:water-alert', + 'Freeze Warning' : 'hass:thermometer-minus', + 'Freeze Watch' : 'hass:thermometer-minus', + 'Freezing Fog Advisory' : 'hass:snowflake-alert', + 'Freezing Rain Advisory' : 'hass:snowflake-alert', + 'Freezing Spray Advisory' : 'hass:snowflake-alert', + 'Frost Advisory' : 'hass:snowflake-alert', + 'Gale Warning' : 'hass:weather-windy', + 'Gale Watch' : 'hass:weather-windy', + 'Hard Freeze Warning' : 'hass:thermometer-minus', + 'Hard Freeze Watch' : 'hass:thermometer-minus', + 'Hazardous Materials Warning' : 'hass:radioactive', + 'Hazardous Seas Warning' : 'hass:sail-boat', + 'Hazardous Seas Watch' : 'hass:sail-boat', + 'Hazardous Weather Outlook' : 'hass:message-alert', + 'Heat Advisory' : 'hass:thermometer-plus', + 'Heavy Freezing Spray Warning' : 'hass:snowflake-alert', + 'Heavy Freezing Spray Watch' : 'hass:snowflake-alert', + 'High Surf Advisory' : 'hass:surfing', + 'High Surf Warning' : 'hass:surfing', + 'High Wind Warning' : 'hass:weather-windy', + 'High Wind Watch' : 'hass:weather-windy', + 'Hurricane Force Wind Warning' : 'hass:weather-hurricane', + 'Hurricane Force Wind Watch' : 'hass:weather-hurricane', + 'Hurricane Local Statement' : 'hass:weather-hurricane', + 'Hurricane Warning' : 'hass:weather-hurricane', + 'Hurricane Watch' : 'hass:weather-hurricane', + 'Hydrologic Advisory' : 'hass:message-text', + 'Hydrologic Outlook' : 'hass:message-text', + 'Ice Storm Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Advisory' : 'hass:snowflake-alert', + 'Lake Effect Snow Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Watch' : 'hass:snowflake-alert', + 'Lake Wind Advisory' : 'hass:weather-windy', + 'Lakeshore Flood Advisory' : 'hass:waves-arrow-up', + 'Lakeshore Flood Statement' : 'hass:waves-arrow-up', + 'Lakeshore Flood Warning' : 'hass:waves-arrow-up', + 'Lakeshore Flood Watch' : 'hass:waves-arrow-up', + 'Law Enforcement Warning' : 'hass:car-emergency', + 'Local Area Emergency' : 'hass:alert', + 'Low Water Advisory' : 'hass:wave', + 'Marine Weather Statement' : 'hass:sail-boat', + 'Nuclear Power Plant Warning' : 'hass:radioactive', + 'Radiological Hazard Warning' : 'hass:biohazard', + 'Red Flag Warning' : 'fire-alert', + 'Rip Current Statement' : 'hass:surfing', + 'Severe Thunderstorm Warning' : 'hass:weather-lightning', + 'Severe Thunderstorm Watch' : 'hass:weather-lightning', + 'Severe Weather Statement' : 'hass:message-text', + 'Shelter In Place Warning' : 'hass:account-box', + 'Short Term Forecast' : 'hass:message-text', + 'Small Craft Advisory' : 'hass:sail-boat', + 'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat', + 'Small Craft Advisory For Rough Bar' : 'hass:sail-boat', + 'Small Craft Advisory For Winds' : 'hass:sail-boat', + 'Small Stream Flood Advisory' : 'hass:water-alert', + 'Snow Squall Warning' : 'hass:snowflake-alert', + 'Special Marine Warning' : 'hass:sail-boat', + 'Special Weather Statement' : 'hass:message-alert', + 'Storm Surge Warning' : 'hass:waves-arrow-up', + 'Storm Surge Watch' : 'hass:waves-arrow-up', + 'Storm Warning' : 'hass:weather-lightning', + 'Storm Watch' : 'hass:weather-lightning', + 'Test' : 'hass:message-text', + 'Tornado Warning' : 'hass:weather-tornado', + 'Tornado Watch' : 'hass:weather-tornado', + 'Tropical Depression Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Warning' : 'hass:weather-hurricane', + 'Tropical Storm Watch' : 'hass:weather-hurricane', + 'Tsunami Advisory' : 'hass:waves-arrow-up', + 'Tsunami Warning' : 'hass:waves-arrow-up', + 'Tsunami Watch' : 'hass:waves-arrow-up', + 'Typhoon Local Statement' : 'hass:weather-hurricane', + 'Typhoon Warning' : 'hass:weather-hurricane', + 'Typhoon Watch' : 'hass:weather-hurricane', + 'Urban And Small Stream Flood Advisory' : 'hass:home-flood', + 'Volcano Warning' : 'hass:image-filter-hdr', + 'Wind Advisory' : 'hass:weather-windy', + 'Wind Chill Advisory' : 'hass:thermometer-minus', + 'Wind Chill Warning' : 'hass:thermometer-minus', + 'Wind Chill Watch' : 'hass:thermometer-minus', + 'Winter Storm Warning' : 'hass:snowflake-alert', + 'Winter Storm Watch' : 'hass:snowflake-alert', + 'Winter Weather Advisory' : 'hass:snowflake-alert' } %} + {% set state = states['sensor.weatheralerts_2_alert_5'].attributes.alert_event %} + {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }} value_template: >- - {% if (states('sensor.weatheralerts_2') != 'unavailable') and (state_attr('sensor.weatheralerts_2', 'alerts')[4] != null) or ((states('sensor.weatheralerts_2') == 'unavailable') and (as_timestamp(state_attr('sensor.weatheralerts_2', 'alerts')[4].endsExpires) - as_timestamp(now()) > 0)) %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and (state_attr('sensor.weatheralerts_2', 'alerts')[4] != null) or (not is_state('sensor.weatheralerts_2', 'unavailable') and (state_attr('sensor.weatheralerts_2', 'alerts')[4] != null) and (as_timestamp(state_attr('sensor.weatheralerts_2', 'alerts')[4].endsExpires) - as_timestamp(now()) > 0)) %} on {% else %} off {% endif %} attribute_templates: alert_id: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].id }} {% else %} None {% endif %} alert_event: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].event }} {% else %} None {% endif %} alert_area: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].area }} {% else %} None {% endif %} alert_NWSheadline: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') }} {% else %} None {% endif %} alert_description: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].description }} {% else %} None {% endif %} alert_messageType: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].messageType }} {% else %} None {% endif %} alert_status: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].status }} {% else %} None {% endif %} alert_category: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].category }} {% else %} None {% endif %} alert_urgency: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].urgency }} {% else %} None {% endif %} alert_severity: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].severity }} {% else %} None {% endif %} alert_certainty: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].certainty }} {% else %} None {% endif %} alert_response: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].response }} {% else %} None {% endif %} alert_instruction: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].instruction }} {% else %} None {% endif %} alert_sent: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].sent }} {% else %} None {% endif %} alert_effective: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].effective }} {% else %} None {% endif %} alert_onset: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].onset }} {% else %} None {% endif %} alert_expires: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].expires }} {% else %} None {% endif %} alert_title: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].title }} {% else %} None {% endif %} alert_zoneid: >- - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].zoneid }} {% else %} None {% endif %} display_title: > - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].title }} {% else %} None {% endif %} display_message: > - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {% if states.sensor.weatheralerts_2.attributes.alerts[4].NWSheadline != "null" %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') }}
{% endif %} @@ -969,13 +1624,13 @@ sensor: None {% endif %} spoken_title: > - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} Attention!!! Weather alert for {{ state_attr('sensor.weatheralerts_2', 'friendly_name') }}. A {{ states.sensor.weatheralerts_2.attributes.alerts[4].title }}. {{ states.sensor.weatheralerts_2.attributes.alerts[4].NWSheadline | regex_replace('\[\'','') | regex_replace('\'\]','') | capitalize }}. {% else %} None {% endif %} spoken_message: > - {% if states('sensor.weatheralerts_2')|int > 4 or (states('sensor.weatheralerts_2') == "unavailable" and states('sensor.weatheralerts_2_alert_5') == "on") %} + {% if not is_state('sensor.weatheralerts_2', 'unavailable') and not is_state('sensor.weatheralerts_2', 'unknown') and is_state('sensor.weatheralerts_2_alert_5', 'on') or (is_number(states('sensor.weatheralerts_2')) and (states('sensor.weatheralerts_2')|int > 4)) %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].description | regex_replace('\n\n','

') | regex_replace('\n',' ') | regex_replace('\*','\n*') | regex_replace('

','\n\n') }} {% if states.sensor.weatheralerts_2.attributes.alerts[4].instruction != None %} {{ states.sensor.weatheralerts_2.attributes.alerts[4].instruction | regex_replace('\n\n','

') | regex_replace('\n',' ') | regex_replace('\*','\n*') | regex_replace('

','\n\n') }} @@ -1021,6 +1676,138 @@ sensor: {% endif %} weatheralerts_2_alert_1_most_recent_active_alert: + icon_template: >- + {% set mapper = { + '911 Telephone Outage Emergency' : 'hass:phone-alert', + 'Administrative Message' : 'hass:message-text', + 'Air Quality Alert' : 'hass:blur', + 'Air Stagnation Advisory' : 'hass:blur', + 'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert', + 'Ashfall Advisory' : 'hass:cloud-alert', + 'Ashfall Warning' : 'hass:cloud-alert', + 'Avalanche Advisory' : 'hass:alert', + 'Avalanche Warning' : 'hass:alert', + 'Avalanche Watch' : 'hass:alert', + 'Beach Hazards Statement' : 'hass:beach', + 'Blizzard Warning' : 'hass:snowflake-alert', + 'Blizzard Watch' : 'hass:snowflake-alert', + 'Blowing Dust Advisory' : 'hass:blur', + 'Blowing Dust Warning' : 'hass:blur', + 'Brisk Wind Advisory' : 'hass:weather-windy', + 'Child Abduction Emergency' : 'hass:human-male-child', + 'Civil Danger Warning' : 'hass:image-filter-hdr', + 'Civil Emergency Message' : 'hass:image-filter-hdr', + 'Coastal Flood Advisory' : 'hass:waves', + 'Coastal Flood Statement' : 'hass:waves', + 'Coastal Flood Warning' : 'hass:waves', + 'Coastal Flood Watch' : 'hass:waves', + 'Dense Fog Advisory' : 'hass:weather-fog', + 'Dense Smoke Advisory' : 'hass:smoke', + 'Dust Advisory' : 'hass:blur', + 'Dust Storm Warning' : 'hass:blur', + 'Earthquake Warning' : 'hass:alert', + 'Evacuation - Immediate' : 'hass:exit-run', + 'Excessive Heat Warning' : 'hass:thermometer-plus', + 'Excessive Heat Watch' : 'hass:thermometer-plus', + 'Extreme Cold Warning' : 'hass:thermometer-minus', + 'Extreme Cold Watch' : 'hass:thermometer-minus', + 'Extreme Fire Danger' : 'hass:fire-alert', + 'Extreme Wind Warning' : 'hass:weather-windy', + 'Fire Warning' : 'hass:fire-alert', + 'Fire Weather Watch' : 'hass:fire-alert', + 'Flash Flood Statement' : 'hass:water-alert', + 'Flash Flood Warning' : 'hass:water-alert', + 'Flash Flood Watch' : 'hass:water-alert', + 'Flood Advisory' : 'hass:water-alert', + 'Flood Statement' : 'hass:water-alert', + 'Flood Warning' : 'hass:water-alert', + 'Flood Watch' : 'hass:water-alert', + 'Freeze Warning' : 'hass:thermometer-minus', + 'Freeze Watch' : 'hass:thermometer-minus', + 'Freezing Fog Advisory' : 'hass:snowflake-alert', + 'Freezing Rain Advisory' : 'hass:snowflake-alert', + 'Freezing Spray Advisory' : 'hass:snowflake-alert', + 'Frost Advisory' : 'hass:snowflake-alert', + 'Gale Warning' : 'hass:weather-windy', + 'Gale Watch' : 'hass:weather-windy', + 'Hard Freeze Warning' : 'hass:thermometer-minus', + 'Hard Freeze Watch' : 'hass:thermometer-minus', + 'Hazardous Materials Warning' : 'hass:radioactive', + 'Hazardous Seas Warning' : 'hass:sail-boat', + 'Hazardous Seas Watch' : 'hass:sail-boat', + 'Hazardous Weather Outlook' : 'hass:message-alert', + 'Heat Advisory' : 'hass:thermometer-plus', + 'Heavy Freezing Spray Warning' : 'hass:snowflake-alert', + 'Heavy Freezing Spray Watch' : 'hass:snowflake-alert', + 'High Surf Advisory' : 'hass:surfing', + 'High Surf Warning' : 'hass:surfing', + 'High Wind Warning' : 'hass:weather-windy', + 'High Wind Watch' : 'hass:weather-windy', + 'Hurricane Force Wind Warning' : 'hass:weather-hurricane', + 'Hurricane Force Wind Watch' : 'hass:weather-hurricane', + 'Hurricane Local Statement' : 'hass:weather-hurricane', + 'Hurricane Warning' : 'hass:weather-hurricane', + 'Hurricane Watch' : 'hass:weather-hurricane', + 'Hydrologic Advisory' : 'hass:message-text', + 'Hydrologic Outlook' : 'hass:message-text', + 'Ice Storm Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Advisory' : 'hass:snowflake-alert', + 'Lake Effect Snow Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Watch' : 'hass:snowflake-alert', + 'Lake Wind Advisory' : 'hass:weather-windy', + 'Lakeshore Flood Advisory' : 'hass:waves-arrow-up', + 'Lakeshore Flood Statement' : 'hass:waves-arrow-up', + 'Lakeshore Flood Warning' : 'hass:waves-arrow-up', + 'Lakeshore Flood Watch' : 'hass:waves-arrow-up', + 'Law Enforcement Warning' : 'hass:car-emergency', + 'Local Area Emergency' : 'hass:alert', + 'Low Water Advisory' : 'hass:wave', + 'Marine Weather Statement' : 'hass:sail-boat', + 'Nuclear Power Plant Warning' : 'hass:radioactive', + 'Radiological Hazard Warning' : 'hass:biohazard', + 'Red Flag Warning' : 'fire-alert', + 'Rip Current Statement' : 'hass:surfing', + 'Severe Thunderstorm Warning' : 'hass:weather-lightning', + 'Severe Thunderstorm Watch' : 'hass:weather-lightning', + 'Severe Weather Statement' : 'hass:message-text', + 'Shelter In Place Warning' : 'hass:account-box', + 'Short Term Forecast' : 'hass:message-text', + 'Small Craft Advisory' : 'hass:sail-boat', + 'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat', + 'Small Craft Advisory For Rough Bar' : 'hass:sail-boat', + 'Small Craft Advisory For Winds' : 'hass:sail-boat', + 'Small Stream Flood Advisory' : 'hass:water-alert', + 'Snow Squall Warning' : 'hass:snowflake-alert', + 'Special Marine Warning' : 'hass:sail-boat', + 'Special Weather Statement' : 'hass:message-alert', + 'Storm Surge Warning' : 'hass:waves-arrow-up', + 'Storm Surge Watch' : 'hass:waves-arrow-up', + 'Storm Warning' : 'hass:weather-lightning', + 'Storm Watch' : 'hass:weather-lightning', + 'Test' : 'hass:message-text', + 'Tornado Warning' : 'hass:weather-tornado', + 'Tornado Watch' : 'hass:weather-tornado', + 'Tropical Depression Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Warning' : 'hass:weather-hurricane', + 'Tropical Storm Watch' : 'hass:weather-hurricane', + 'Tsunami Advisory' : 'hass:waves-arrow-up', + 'Tsunami Warning' : 'hass:waves-arrow-up', + 'Tsunami Watch' : 'hass:waves-arrow-up', + 'Typhoon Local Statement' : 'hass:weather-hurricane', + 'Typhoon Warning' : 'hass:weather-hurricane', + 'Typhoon Watch' : 'hass:weather-hurricane', + 'Urban And Small Stream Flood Advisory' : 'hass:home-flood', + 'Volcano Warning' : 'hass:image-filter-hdr', + 'Wind Advisory' : 'hass:weather-windy', + 'Wind Chill Advisory' : 'hass:thermometer-minus', + 'Wind Chill Warning' : 'hass:thermometer-minus', + 'Wind Chill Watch' : 'hass:thermometer-minus', + 'Winter Storm Warning' : 'hass:snowflake-alert', + 'Winter Storm Watch' : 'hass:snowflake-alert', + 'Winter Weather Advisory' : 'hass:snowflake-alert' } %} + {% set state = states['sensor.weatheralerts_2_alert_1'].attributes.alert_event %} + {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }} value_template: >- {% if states('sensor.weatheralerts_2_alert_1_most_recent_active_alert') == '' and states('sensor.weatheralerts_2_alert_1') != 'on' %} unavailable @@ -1059,6 +1846,138 @@ sensor: {{ state_attr('sensor.weatheralerts_2_alert_1_most_recent_active_alert', 'alert_id') }} {% endif %} weatheralerts_2_alert_2_most_recent_active_alert: + icon_template: >- + {% set mapper = { + '911 Telephone Outage Emergency' : 'hass:phone-alert', + 'Administrative Message' : 'hass:message-text', + 'Air Quality Alert' : 'hass:blur', + 'Air Stagnation Advisory' : 'hass:blur', + 'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert', + 'Ashfall Advisory' : 'hass:cloud-alert', + 'Ashfall Warning' : 'hass:cloud-alert', + 'Avalanche Advisory' : 'hass:alert', + 'Avalanche Warning' : 'hass:alert', + 'Avalanche Watch' : 'hass:alert', + 'Beach Hazards Statement' : 'hass:beach', + 'Blizzard Warning' : 'hass:snowflake-alert', + 'Blizzard Watch' : 'hass:snowflake-alert', + 'Blowing Dust Advisory' : 'hass:blur', + 'Blowing Dust Warning' : 'hass:blur', + 'Brisk Wind Advisory' : 'hass:weather-windy', + 'Child Abduction Emergency' : 'hass:human-male-child', + 'Civil Danger Warning' : 'hass:image-filter-hdr', + 'Civil Emergency Message' : 'hass:image-filter-hdr', + 'Coastal Flood Advisory' : 'hass:waves', + 'Coastal Flood Statement' : 'hass:waves', + 'Coastal Flood Warning' : 'hass:waves', + 'Coastal Flood Watch' : 'hass:waves', + 'Dense Fog Advisory' : 'hass:weather-fog', + 'Dense Smoke Advisory' : 'hass:smoke', + 'Dust Advisory' : 'hass:blur', + 'Dust Storm Warning' : 'hass:blur', + 'Earthquake Warning' : 'hass:alert', + 'Evacuation - Immediate' : 'hass:exit-run', + 'Excessive Heat Warning' : 'hass:thermometer-plus', + 'Excessive Heat Watch' : 'hass:thermometer-plus', + 'Extreme Cold Warning' : 'hass:thermometer-minus', + 'Extreme Cold Watch' : 'hass:thermometer-minus', + 'Extreme Fire Danger' : 'hass:fire-alert', + 'Extreme Wind Warning' : 'hass:weather-windy', + 'Fire Warning' : 'hass:fire-alert', + 'Fire Weather Watch' : 'hass:fire-alert', + 'Flash Flood Statement' : 'hass:water-alert', + 'Flash Flood Warning' : 'hass:water-alert', + 'Flash Flood Watch' : 'hass:water-alert', + 'Flood Advisory' : 'hass:water-alert', + 'Flood Statement' : 'hass:water-alert', + 'Flood Warning' : 'hass:water-alert', + 'Flood Watch' : 'hass:water-alert', + 'Freeze Warning' : 'hass:thermometer-minus', + 'Freeze Watch' : 'hass:thermometer-minus', + 'Freezing Fog Advisory' : 'hass:snowflake-alert', + 'Freezing Rain Advisory' : 'hass:snowflake-alert', + 'Freezing Spray Advisory' : 'hass:snowflake-alert', + 'Frost Advisory' : 'hass:snowflake-alert', + 'Gale Warning' : 'hass:weather-windy', + 'Gale Watch' : 'hass:weather-windy', + 'Hard Freeze Warning' : 'hass:thermometer-minus', + 'Hard Freeze Watch' : 'hass:thermometer-minus', + 'Hazardous Materials Warning' : 'hass:radioactive', + 'Hazardous Seas Warning' : 'hass:sail-boat', + 'Hazardous Seas Watch' : 'hass:sail-boat', + 'Hazardous Weather Outlook' : 'hass:message-alert', + 'Heat Advisory' : 'hass:thermometer-plus', + 'Heavy Freezing Spray Warning' : 'hass:snowflake-alert', + 'Heavy Freezing Spray Watch' : 'hass:snowflake-alert', + 'High Surf Advisory' : 'hass:surfing', + 'High Surf Warning' : 'hass:surfing', + 'High Wind Warning' : 'hass:weather-windy', + 'High Wind Watch' : 'hass:weather-windy', + 'Hurricane Force Wind Warning' : 'hass:weather-hurricane', + 'Hurricane Force Wind Watch' : 'hass:weather-hurricane', + 'Hurricane Local Statement' : 'hass:weather-hurricane', + 'Hurricane Warning' : 'hass:weather-hurricane', + 'Hurricane Watch' : 'hass:weather-hurricane', + 'Hydrologic Advisory' : 'hass:message-text', + 'Hydrologic Outlook' : 'hass:message-text', + 'Ice Storm Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Advisory' : 'hass:snowflake-alert', + 'Lake Effect Snow Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Watch' : 'hass:snowflake-alert', + 'Lake Wind Advisory' : 'hass:weather-windy', + 'Lakeshore Flood Advisory' : 'hass:waves-arrow-up', + 'Lakeshore Flood Statement' : 'hass:waves-arrow-up', + 'Lakeshore Flood Warning' : 'hass:waves-arrow-up', + 'Lakeshore Flood Watch' : 'hass:waves-arrow-up', + 'Law Enforcement Warning' : 'hass:car-emergency', + 'Local Area Emergency' : 'hass:alert', + 'Low Water Advisory' : 'hass:wave', + 'Marine Weather Statement' : 'hass:sail-boat', + 'Nuclear Power Plant Warning' : 'hass:radioactive', + 'Radiological Hazard Warning' : 'hass:biohazard', + 'Red Flag Warning' : 'fire-alert', + 'Rip Current Statement' : 'hass:surfing', + 'Severe Thunderstorm Warning' : 'hass:weather-lightning', + 'Severe Thunderstorm Watch' : 'hass:weather-lightning', + 'Severe Weather Statement' : 'hass:message-text', + 'Shelter In Place Warning' : 'hass:account-box', + 'Short Term Forecast' : 'hass:message-text', + 'Small Craft Advisory' : 'hass:sail-boat', + 'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat', + 'Small Craft Advisory For Rough Bar' : 'hass:sail-boat', + 'Small Craft Advisory For Winds' : 'hass:sail-boat', + 'Small Stream Flood Advisory' : 'hass:water-alert', + 'Snow Squall Warning' : 'hass:snowflake-alert', + 'Special Marine Warning' : 'hass:sail-boat', + 'Special Weather Statement' : 'hass:message-alert', + 'Storm Surge Warning' : 'hass:waves-arrow-up', + 'Storm Surge Watch' : 'hass:waves-arrow-up', + 'Storm Warning' : 'hass:weather-lightning', + 'Storm Watch' : 'hass:weather-lightning', + 'Test' : 'hass:message-text', + 'Tornado Warning' : 'hass:weather-tornado', + 'Tornado Watch' : 'hass:weather-tornado', + 'Tropical Depression Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Warning' : 'hass:weather-hurricane', + 'Tropical Storm Watch' : 'hass:weather-hurricane', + 'Tsunami Advisory' : 'hass:waves-arrow-up', + 'Tsunami Warning' : 'hass:waves-arrow-up', + 'Tsunami Watch' : 'hass:waves-arrow-up', + 'Typhoon Local Statement' : 'hass:weather-hurricane', + 'Typhoon Warning' : 'hass:weather-hurricane', + 'Typhoon Watch' : 'hass:weather-hurricane', + 'Urban And Small Stream Flood Advisory' : 'hass:home-flood', + 'Volcano Warning' : 'hass:image-filter-hdr', + 'Wind Advisory' : 'hass:weather-windy', + 'Wind Chill Advisory' : 'hass:thermometer-minus', + 'Wind Chill Warning' : 'hass:thermometer-minus', + 'Wind Chill Watch' : 'hass:thermometer-minus', + 'Winter Storm Warning' : 'hass:snowflake-alert', + 'Winter Storm Watch' : 'hass:snowflake-alert', + 'Winter Weather Advisory' : 'hass:snowflake-alert' } %} + {% set state = states['sensor.weatheralerts_2_alert_1'].attributes.alert_event %} + {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }} value_template: >- {% if states('sensor.weatheralerts_2_alert_2_most_recent_active_alert') == '' and states('sensor.weatheralerts_2_alert_2') != 'on' %} unavailable @@ -1097,6 +2016,138 @@ sensor: {{ state_attr('sensor.weatheralerts_2_alert_2_most_recent_active_alert', 'alert_id') }} {% endif %} weatheralerts_2_alert_3_most_recent_active_alert: + icon_template: >- + {% set mapper = { + '911 Telephone Outage Emergency' : 'hass:phone-alert', + 'Administrative Message' : 'hass:message-text', + 'Air Quality Alert' : 'hass:blur', + 'Air Stagnation Advisory' : 'hass:blur', + 'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert', + 'Ashfall Advisory' : 'hass:cloud-alert', + 'Ashfall Warning' : 'hass:cloud-alert', + 'Avalanche Advisory' : 'hass:alert', + 'Avalanche Warning' : 'hass:alert', + 'Avalanche Watch' : 'hass:alert', + 'Beach Hazards Statement' : 'hass:beach', + 'Blizzard Warning' : 'hass:snowflake-alert', + 'Blizzard Watch' : 'hass:snowflake-alert', + 'Blowing Dust Advisory' : 'hass:blur', + 'Blowing Dust Warning' : 'hass:blur', + 'Brisk Wind Advisory' : 'hass:weather-windy', + 'Child Abduction Emergency' : 'hass:human-male-child', + 'Civil Danger Warning' : 'hass:image-filter-hdr', + 'Civil Emergency Message' : 'hass:image-filter-hdr', + 'Coastal Flood Advisory' : 'hass:waves', + 'Coastal Flood Statement' : 'hass:waves', + 'Coastal Flood Warning' : 'hass:waves', + 'Coastal Flood Watch' : 'hass:waves', + 'Dense Fog Advisory' : 'hass:weather-fog', + 'Dense Smoke Advisory' : 'hass:smoke', + 'Dust Advisory' : 'hass:blur', + 'Dust Storm Warning' : 'hass:blur', + 'Earthquake Warning' : 'hass:alert', + 'Evacuation - Immediate' : 'hass:exit-run', + 'Excessive Heat Warning' : 'hass:thermometer-plus', + 'Excessive Heat Watch' : 'hass:thermometer-plus', + 'Extreme Cold Warning' : 'hass:thermometer-minus', + 'Extreme Cold Watch' : 'hass:thermometer-minus', + 'Extreme Fire Danger' : 'hass:fire-alert', + 'Extreme Wind Warning' : 'hass:weather-windy', + 'Fire Warning' : 'hass:fire-alert', + 'Fire Weather Watch' : 'hass:fire-alert', + 'Flash Flood Statement' : 'hass:water-alert', + 'Flash Flood Warning' : 'hass:water-alert', + 'Flash Flood Watch' : 'hass:water-alert', + 'Flood Advisory' : 'hass:water-alert', + 'Flood Statement' : 'hass:water-alert', + 'Flood Warning' : 'hass:water-alert', + 'Flood Watch' : 'hass:water-alert', + 'Freeze Warning' : 'hass:thermometer-minus', + 'Freeze Watch' : 'hass:thermometer-minus', + 'Freezing Fog Advisory' : 'hass:snowflake-alert', + 'Freezing Rain Advisory' : 'hass:snowflake-alert', + 'Freezing Spray Advisory' : 'hass:snowflake-alert', + 'Frost Advisory' : 'hass:snowflake-alert', + 'Gale Warning' : 'hass:weather-windy', + 'Gale Watch' : 'hass:weather-windy', + 'Hard Freeze Warning' : 'hass:thermometer-minus', + 'Hard Freeze Watch' : 'hass:thermometer-minus', + 'Hazardous Materials Warning' : 'hass:radioactive', + 'Hazardous Seas Warning' : 'hass:sail-boat', + 'Hazardous Seas Watch' : 'hass:sail-boat', + 'Hazardous Weather Outlook' : 'hass:message-alert', + 'Heat Advisory' : 'hass:thermometer-plus', + 'Heavy Freezing Spray Warning' : 'hass:snowflake-alert', + 'Heavy Freezing Spray Watch' : 'hass:snowflake-alert', + 'High Surf Advisory' : 'hass:surfing', + 'High Surf Warning' : 'hass:surfing', + 'High Wind Warning' : 'hass:weather-windy', + 'High Wind Watch' : 'hass:weather-windy', + 'Hurricane Force Wind Warning' : 'hass:weather-hurricane', + 'Hurricane Force Wind Watch' : 'hass:weather-hurricane', + 'Hurricane Local Statement' : 'hass:weather-hurricane', + 'Hurricane Warning' : 'hass:weather-hurricane', + 'Hurricane Watch' : 'hass:weather-hurricane', + 'Hydrologic Advisory' : 'hass:message-text', + 'Hydrologic Outlook' : 'hass:message-text', + 'Ice Storm Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Advisory' : 'hass:snowflake-alert', + 'Lake Effect Snow Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Watch' : 'hass:snowflake-alert', + 'Lake Wind Advisory' : 'hass:weather-windy', + 'Lakeshore Flood Advisory' : 'hass:waves-arrow-up', + 'Lakeshore Flood Statement' : 'hass:waves-arrow-up', + 'Lakeshore Flood Warning' : 'hass:waves-arrow-up', + 'Lakeshore Flood Watch' : 'hass:waves-arrow-up', + 'Law Enforcement Warning' : 'hass:car-emergency', + 'Local Area Emergency' : 'hass:alert', + 'Low Water Advisory' : 'hass:wave', + 'Marine Weather Statement' : 'hass:sail-boat', + 'Nuclear Power Plant Warning' : 'hass:radioactive', + 'Radiological Hazard Warning' : 'hass:biohazard', + 'Red Flag Warning' : 'fire-alert', + 'Rip Current Statement' : 'hass:surfing', + 'Severe Thunderstorm Warning' : 'hass:weather-lightning', + 'Severe Thunderstorm Watch' : 'hass:weather-lightning', + 'Severe Weather Statement' : 'hass:message-text', + 'Shelter In Place Warning' : 'hass:account-box', + 'Short Term Forecast' : 'hass:message-text', + 'Small Craft Advisory' : 'hass:sail-boat', + 'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat', + 'Small Craft Advisory For Rough Bar' : 'hass:sail-boat', + 'Small Craft Advisory For Winds' : 'hass:sail-boat', + 'Small Stream Flood Advisory' : 'hass:water-alert', + 'Snow Squall Warning' : 'hass:snowflake-alert', + 'Special Marine Warning' : 'hass:sail-boat', + 'Special Weather Statement' : 'hass:message-alert', + 'Storm Surge Warning' : 'hass:waves-arrow-up', + 'Storm Surge Watch' : 'hass:waves-arrow-up', + 'Storm Warning' : 'hass:weather-lightning', + 'Storm Watch' : 'hass:weather-lightning', + 'Test' : 'hass:message-text', + 'Tornado Warning' : 'hass:weather-tornado', + 'Tornado Watch' : 'hass:weather-tornado', + 'Tropical Depression Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Warning' : 'hass:weather-hurricane', + 'Tropical Storm Watch' : 'hass:weather-hurricane', + 'Tsunami Advisory' : 'hass:waves-arrow-up', + 'Tsunami Warning' : 'hass:waves-arrow-up', + 'Tsunami Watch' : 'hass:waves-arrow-up', + 'Typhoon Local Statement' : 'hass:weather-hurricane', + 'Typhoon Warning' : 'hass:weather-hurricane', + 'Typhoon Watch' : 'hass:weather-hurricane', + 'Urban And Small Stream Flood Advisory' : 'hass:home-flood', + 'Volcano Warning' : 'hass:image-filter-hdr', + 'Wind Advisory' : 'hass:weather-windy', + 'Wind Chill Advisory' : 'hass:thermometer-minus', + 'Wind Chill Warning' : 'hass:thermometer-minus', + 'Wind Chill Watch' : 'hass:thermometer-minus', + 'Winter Storm Warning' : 'hass:snowflake-alert', + 'Winter Storm Watch' : 'hass:snowflake-alert', + 'Winter Weather Advisory' : 'hass:snowflake-alert' } %} + {% set state = states['sensor.weatheralerts_2_alert_1'].attributes.alert_event %} + {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }} value_template: >- {% if states('sensor.weatheralerts_2_alert_3_most_recent_active_alert') == '' and states('sensor.weatheralerts_2_alert_3') != 'on' %} unavailable @@ -1135,18 +2186,150 @@ sensor: {{ state_attr('sensor.weatheralerts_2_alert_3_most_recent_active_alert', 'alert_id') }} {% endif %} weatheralerts_2_alert_4_most_recent_active_alert: + icon_template: >- + {% set mapper = { + '911 Telephone Outage Emergency' : 'hass:phone-alert', + 'Administrative Message' : 'hass:message-text', + 'Air Quality Alert' : 'hass:blur', + 'Air Stagnation Advisory' : 'hass:blur', + 'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert', + 'Ashfall Advisory' : 'hass:cloud-alert', + 'Ashfall Warning' : 'hass:cloud-alert', + 'Avalanche Advisory' : 'hass:alert', + 'Avalanche Warning' : 'hass:alert', + 'Avalanche Watch' : 'hass:alert', + 'Beach Hazards Statement' : 'hass:beach', + 'Blizzard Warning' : 'hass:snowflake-alert', + 'Blizzard Watch' : 'hass:snowflake-alert', + 'Blowing Dust Advisory' : 'hass:blur', + 'Blowing Dust Warning' : 'hass:blur', + 'Brisk Wind Advisory' : 'hass:weather-windy', + 'Child Abduction Emergency' : 'hass:human-male-child', + 'Civil Danger Warning' : 'hass:image-filter-hdr', + 'Civil Emergency Message' : 'hass:image-filter-hdr', + 'Coastal Flood Advisory' : 'hass:waves', + 'Coastal Flood Statement' : 'hass:waves', + 'Coastal Flood Warning' : 'hass:waves', + 'Coastal Flood Watch' : 'hass:waves', + 'Dense Fog Advisory' : 'hass:weather-fog', + 'Dense Smoke Advisory' : 'hass:smoke', + 'Dust Advisory' : 'hass:blur', + 'Dust Storm Warning' : 'hass:blur', + 'Earthquake Warning' : 'hass:alert', + 'Evacuation - Immediate' : 'hass:exit-run', + 'Excessive Heat Warning' : 'hass:thermometer-plus', + 'Excessive Heat Watch' : 'hass:thermometer-plus', + 'Extreme Cold Warning' : 'hass:thermometer-minus', + 'Extreme Cold Watch' : 'hass:thermometer-minus', + 'Extreme Fire Danger' : 'hass:fire-alert', + 'Extreme Wind Warning' : 'hass:weather-windy', + 'Fire Warning' : 'hass:fire-alert', + 'Fire Weather Watch' : 'hass:fire-alert', + 'Flash Flood Statement' : 'hass:water-alert', + 'Flash Flood Warning' : 'hass:water-alert', + 'Flash Flood Watch' : 'hass:water-alert', + 'Flood Advisory' : 'hass:water-alert', + 'Flood Statement' : 'hass:water-alert', + 'Flood Warning' : 'hass:water-alert', + 'Flood Watch' : 'hass:water-alert', + 'Freeze Warning' : 'hass:thermometer-minus', + 'Freeze Watch' : 'hass:thermometer-minus', + 'Freezing Fog Advisory' : 'hass:snowflake-alert', + 'Freezing Rain Advisory' : 'hass:snowflake-alert', + 'Freezing Spray Advisory' : 'hass:snowflake-alert', + 'Frost Advisory' : 'hass:snowflake-alert', + 'Gale Warning' : 'hass:weather-windy', + 'Gale Watch' : 'hass:weather-windy', + 'Hard Freeze Warning' : 'hass:thermometer-minus', + 'Hard Freeze Watch' : 'hass:thermometer-minus', + 'Hazardous Materials Warning' : 'hass:radioactive', + 'Hazardous Seas Warning' : 'hass:sail-boat', + 'Hazardous Seas Watch' : 'hass:sail-boat', + 'Hazardous Weather Outlook' : 'hass:message-alert', + 'Heat Advisory' : 'hass:thermometer-plus', + 'Heavy Freezing Spray Warning' : 'hass:snowflake-alert', + 'Heavy Freezing Spray Watch' : 'hass:snowflake-alert', + 'High Surf Advisory' : 'hass:surfing', + 'High Surf Warning' : 'hass:surfing', + 'High Wind Warning' : 'hass:weather-windy', + 'High Wind Watch' : 'hass:weather-windy', + 'Hurricane Force Wind Warning' : 'hass:weather-hurricane', + 'Hurricane Force Wind Watch' : 'hass:weather-hurricane', + 'Hurricane Local Statement' : 'hass:weather-hurricane', + 'Hurricane Warning' : 'hass:weather-hurricane', + 'Hurricane Watch' : 'hass:weather-hurricane', + 'Hydrologic Advisory' : 'hass:message-text', + 'Hydrologic Outlook' : 'hass:message-text', + 'Ice Storm Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Advisory' : 'hass:snowflake-alert', + 'Lake Effect Snow Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Watch' : 'hass:snowflake-alert', + 'Lake Wind Advisory' : 'hass:weather-windy', + 'Lakeshore Flood Advisory' : 'hass:waves-arrow-up', + 'Lakeshore Flood Statement' : 'hass:waves-arrow-up', + 'Lakeshore Flood Warning' : 'hass:waves-arrow-up', + 'Lakeshore Flood Watch' : 'hass:waves-arrow-up', + 'Law Enforcement Warning' : 'hass:car-emergency', + 'Local Area Emergency' : 'hass:alert', + 'Low Water Advisory' : 'hass:wave', + 'Marine Weather Statement' : 'hass:sail-boat', + 'Nuclear Power Plant Warning' : 'hass:radioactive', + 'Radiological Hazard Warning' : 'hass:biohazard', + 'Red Flag Warning' : 'fire-alert', + 'Rip Current Statement' : 'hass:surfing', + 'Severe Thunderstorm Warning' : 'hass:weather-lightning', + 'Severe Thunderstorm Watch' : 'hass:weather-lightning', + 'Severe Weather Statement' : 'hass:message-text', + 'Shelter In Place Warning' : 'hass:account-box', + 'Short Term Forecast' : 'hass:message-text', + 'Small Craft Advisory' : 'hass:sail-boat', + 'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat', + 'Small Craft Advisory For Rough Bar' : 'hass:sail-boat', + 'Small Craft Advisory For Winds' : 'hass:sail-boat', + 'Small Stream Flood Advisory' : 'hass:water-alert', + 'Snow Squall Warning' : 'hass:snowflake-alert', + 'Special Marine Warning' : 'hass:sail-boat', + 'Special Weather Statement' : 'hass:message-alert', + 'Storm Surge Warning' : 'hass:waves-arrow-up', + 'Storm Surge Watch' : 'hass:waves-arrow-up', + 'Storm Warning' : 'hass:weather-lightning', + 'Storm Watch' : 'hass:weather-lightning', + 'Test' : 'hass:message-text', + 'Tornado Warning' : 'hass:weather-tornado', + 'Tornado Watch' : 'hass:weather-tornado', + 'Tropical Depression Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Warning' : 'hass:weather-hurricane', + 'Tropical Storm Watch' : 'hass:weather-hurricane', + 'Tsunami Advisory' : 'hass:waves-arrow-up', + 'Tsunami Warning' : 'hass:waves-arrow-up', + 'Tsunami Watch' : 'hass:waves-arrow-up', + 'Typhoon Local Statement' : 'hass:weather-hurricane', + 'Typhoon Warning' : 'hass:weather-hurricane', + 'Typhoon Watch' : 'hass:weather-hurricane', + 'Urban And Small Stream Flood Advisory' : 'hass:home-flood', + 'Volcano Warning' : 'hass:image-filter-hdr', + 'Wind Advisory' : 'hass:weather-windy', + 'Wind Chill Advisory' : 'hass:thermometer-minus', + 'Wind Chill Warning' : 'hass:thermometer-minus', + 'Wind Chill Watch' : 'hass:thermometer-minus', + 'Winter Storm Warning' : 'hass:snowflake-alert', + 'Winter Storm Watch' : 'hass:snowflake-alert', + 'Winter Weather Advisory' : 'hass:snowflake-alert' } %} + {% set state = states['sensor.weatheralerts_2_alert_1'].attributes.alert_event %} + {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }} value_template: >- - {% if states('sensor.weatheralerts_2_alert_4_most_recent_active_alert') == '' and states('sensor.weatheralerts_2_alert_4') != 'on' %} - unavailable - {% elif states('sensor.weatheralerts_2_alert_4_most_recent_active_alert') == 'unavailable' and states('sensor.weatheralerts_2_alert_4') != 'on' %} - unavailable - {% elif states('sensor.weatheralerts_2_alert_4_most_recent_active_alert') == 'unknown' and states('sensor.weatheralerts_2_alert_4') != 'on' %} - unavailable - {% elif states('sensor.weatheralerts_2_alert_4') == 'on' %} - {{ state_attr('sensor.weatheralerts_2_alert_4', 'alert_event') }} - {% else %} - {{ states('sensor.weatheralerts_2_alert_4_most_recent_active_alert') }} - {% endif %} + {% if states('sensor.weatheralerts_2_alert_4_most_recent_active_alert') == '' and states('sensor.weatheralerts_2_alert_4') != 'on' %} + unavailable + {% elif states('sensor.weatheralerts_2_alert_4_most_recent_active_alert') == 'unavailable' and states('sensor.weatheralerts_2_alert_4') != 'on' %} + unavailable + {% elif states('sensor.weatheralerts_2_alert_4_most_recent_active_alert') == 'unknown' and states('sensor.weatheralerts_2_alert_4') != 'on' %} + unavailable + {% elif states('sensor.weatheralerts_2_alert_4') == 'on' %} + {{ state_attr('sensor.weatheralerts_2_alert_4', 'alert_event') }} + {% else %} + {{ states('sensor.weatheralerts_2_alert_4_most_recent_active_alert') }} + {% endif %} attribute_templates: alert_effective: >- {% if states('sensor.weatheralerts_2_alert_4_most_recent_active_alert') == '' and states('sensor.weatheralerts_2_alert_4') != 'on' %} @@ -1173,6 +2356,138 @@ sensor: {{ state_attr('sensor.weatheralerts_2_alert_4_most_recent_active_alert', 'alert_id') }} {% endif %} weatheralerts_2_alert_5_most_recent_active_alert: + icon_template: >- + {% set mapper = { + '911 Telephone Outage Emergency' : 'hass:phone-alert', + 'Administrative Message' : 'hass:message-text', + 'Air Quality Alert' : 'hass:blur', + 'Air Stagnation Advisory' : 'hass:blur', + 'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert', + 'Ashfall Advisory' : 'hass:cloud-alert', + 'Ashfall Warning' : 'hass:cloud-alert', + 'Avalanche Advisory' : 'hass:alert', + 'Avalanche Warning' : 'hass:alert', + 'Avalanche Watch' : 'hass:alert', + 'Beach Hazards Statement' : 'hass:beach', + 'Blizzard Warning' : 'hass:snowflake-alert', + 'Blizzard Watch' : 'hass:snowflake-alert', + 'Blowing Dust Advisory' : 'hass:blur', + 'Blowing Dust Warning' : 'hass:blur', + 'Brisk Wind Advisory' : 'hass:weather-windy', + 'Child Abduction Emergency' : 'hass:human-male-child', + 'Civil Danger Warning' : 'hass:image-filter-hdr', + 'Civil Emergency Message' : 'hass:image-filter-hdr', + 'Coastal Flood Advisory' : 'hass:waves', + 'Coastal Flood Statement' : 'hass:waves', + 'Coastal Flood Warning' : 'hass:waves', + 'Coastal Flood Watch' : 'hass:waves', + 'Dense Fog Advisory' : 'hass:weather-fog', + 'Dense Smoke Advisory' : 'hass:smoke', + 'Dust Advisory' : 'hass:blur', + 'Dust Storm Warning' : 'hass:blur', + 'Earthquake Warning' : 'hass:alert', + 'Evacuation - Immediate' : 'hass:exit-run', + 'Excessive Heat Warning' : 'hass:thermometer-plus', + 'Excessive Heat Watch' : 'hass:thermometer-plus', + 'Extreme Cold Warning' : 'hass:thermometer-minus', + 'Extreme Cold Watch' : 'hass:thermometer-minus', + 'Extreme Fire Danger' : 'hass:fire-alert', + 'Extreme Wind Warning' : 'hass:weather-windy', + 'Fire Warning' : 'hass:fire-alert', + 'Fire Weather Watch' : 'hass:fire-alert', + 'Flash Flood Statement' : 'hass:water-alert', + 'Flash Flood Warning' : 'hass:water-alert', + 'Flash Flood Watch' : 'hass:water-alert', + 'Flood Advisory' : 'hass:water-alert', + 'Flood Statement' : 'hass:water-alert', + 'Flood Warning' : 'hass:water-alert', + 'Flood Watch' : 'hass:water-alert', + 'Freeze Warning' : 'hass:thermometer-minus', + 'Freeze Watch' : 'hass:thermometer-minus', + 'Freezing Fog Advisory' : 'hass:snowflake-alert', + 'Freezing Rain Advisory' : 'hass:snowflake-alert', + 'Freezing Spray Advisory' : 'hass:snowflake-alert', + 'Frost Advisory' : 'hass:snowflake-alert', + 'Gale Warning' : 'hass:weather-windy', + 'Gale Watch' : 'hass:weather-windy', + 'Hard Freeze Warning' : 'hass:thermometer-minus', + 'Hard Freeze Watch' : 'hass:thermometer-minus', + 'Hazardous Materials Warning' : 'hass:radioactive', + 'Hazardous Seas Warning' : 'hass:sail-boat', + 'Hazardous Seas Watch' : 'hass:sail-boat', + 'Hazardous Weather Outlook' : 'hass:message-alert', + 'Heat Advisory' : 'hass:thermometer-plus', + 'Heavy Freezing Spray Warning' : 'hass:snowflake-alert', + 'Heavy Freezing Spray Watch' : 'hass:snowflake-alert', + 'High Surf Advisory' : 'hass:surfing', + 'High Surf Warning' : 'hass:surfing', + 'High Wind Warning' : 'hass:weather-windy', + 'High Wind Watch' : 'hass:weather-windy', + 'Hurricane Force Wind Warning' : 'hass:weather-hurricane', + 'Hurricane Force Wind Watch' : 'hass:weather-hurricane', + 'Hurricane Local Statement' : 'hass:weather-hurricane', + 'Hurricane Warning' : 'hass:weather-hurricane', + 'Hurricane Watch' : 'hass:weather-hurricane', + 'Hydrologic Advisory' : 'hass:message-text', + 'Hydrologic Outlook' : 'hass:message-text', + 'Ice Storm Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Advisory' : 'hass:snowflake-alert', + 'Lake Effect Snow Warning' : 'hass:snowflake-alert', + 'Lake Effect Snow Watch' : 'hass:snowflake-alert', + 'Lake Wind Advisory' : 'hass:weather-windy', + 'Lakeshore Flood Advisory' : 'hass:waves-arrow-up', + 'Lakeshore Flood Statement' : 'hass:waves-arrow-up', + 'Lakeshore Flood Warning' : 'hass:waves-arrow-up', + 'Lakeshore Flood Watch' : 'hass:waves-arrow-up', + 'Law Enforcement Warning' : 'hass:car-emergency', + 'Local Area Emergency' : 'hass:alert', + 'Low Water Advisory' : 'hass:wave', + 'Marine Weather Statement' : 'hass:sail-boat', + 'Nuclear Power Plant Warning' : 'hass:radioactive', + 'Radiological Hazard Warning' : 'hass:biohazard', + 'Red Flag Warning' : 'fire-alert', + 'Rip Current Statement' : 'hass:surfing', + 'Severe Thunderstorm Warning' : 'hass:weather-lightning', + 'Severe Thunderstorm Watch' : 'hass:weather-lightning', + 'Severe Weather Statement' : 'hass:message-text', + 'Shelter In Place Warning' : 'hass:account-box', + 'Short Term Forecast' : 'hass:message-text', + 'Small Craft Advisory' : 'hass:sail-boat', + 'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat', + 'Small Craft Advisory For Rough Bar' : 'hass:sail-boat', + 'Small Craft Advisory For Winds' : 'hass:sail-boat', + 'Small Stream Flood Advisory' : 'hass:water-alert', + 'Snow Squall Warning' : 'hass:snowflake-alert', + 'Special Marine Warning' : 'hass:sail-boat', + 'Special Weather Statement' : 'hass:message-alert', + 'Storm Surge Warning' : 'hass:waves-arrow-up', + 'Storm Surge Watch' : 'hass:waves-arrow-up', + 'Storm Warning' : 'hass:weather-lightning', + 'Storm Watch' : 'hass:weather-lightning', + 'Test' : 'hass:message-text', + 'Tornado Warning' : 'hass:weather-tornado', + 'Tornado Watch' : 'hass:weather-tornado', + 'Tropical Depression Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Local Statement' : 'hass:weather-hurricane', + 'Tropical Storm Warning' : 'hass:weather-hurricane', + 'Tropical Storm Watch' : 'hass:weather-hurricane', + 'Tsunami Advisory' : 'hass:waves-arrow-up', + 'Tsunami Warning' : 'hass:waves-arrow-up', + 'Tsunami Watch' : 'hass:waves-arrow-up', + 'Typhoon Local Statement' : 'hass:weather-hurricane', + 'Typhoon Warning' : 'hass:weather-hurricane', + 'Typhoon Watch' : 'hass:weather-hurricane', + 'Urban And Small Stream Flood Advisory' : 'hass:home-flood', + 'Volcano Warning' : 'hass:image-filter-hdr', + 'Wind Advisory' : 'hass:weather-windy', + 'Wind Chill Advisory' : 'hass:thermometer-minus', + 'Wind Chill Warning' : 'hass:thermometer-minus', + 'Wind Chill Watch' : 'hass:thermometer-minus', + 'Winter Storm Warning' : 'hass:snowflake-alert', + 'Winter Storm Watch' : 'hass:snowflake-alert', + 'Winter Weather Advisory' : 'hass:snowflake-alert' } %} + {% set state = states['sensor.weatheralerts_2_alert_1'].attributes.alert_event %} + {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }} value_template: >- {% if states('sensor.weatheralerts_2_alert_5_most_recent_active_alert') == '' and states('sensor.weatheralerts_2_alert_5') != 'on' %} unavailable