Fixing some weather alerts

This commit is contained in:
Jeffrey Stone 2021-08-28 15:52:42 -04:00
parent 062398cc5e
commit 189e4d87a4
3 changed files with 115 additions and 16 deletions

View File

@ -23,7 +23,7 @@ http:
# ssl_key: !secret ahsl_ssl_key # ssl_key: !secret ahsl_ssl_key
use_x_forwarded_for: true use_x_forwarded_for: true
trusted_proxies: !secret proxy_ips trusted_proxies: !secret proxy_ips
ip_ban_enabled: true ip_ban_enabled: false
login_attempts_threshold: 5 login_attempts_threshold: 5
ssdp: ssdp:
@ -69,7 +69,8 @@ template:
binary_sensor: binary_sensor:
- name: lightning_detected - name: lightning_detected
unique_id: lightning_detected_sensor unique_id: lightning_detected_sensor
state: "{{ states('sensor.recent_lighting_strikes') | int > 0 }}" state: >
{{ states('sensor.recent_lightning_strikes') | int > 0 }}
device_class: safety device_class: safety
updater: updater:
@ -99,6 +100,5 @@ input_boolean: !include input_boolean.yaml
input_datetime: !include input_datetime.yaml input_datetime: !include input_datetime.yaml
zone: !include zones.yaml zone: !include zones.yaml
shell_command: shell_command:
google_token: sed -i -e 's/2client.client"}2client.client"}/2client.client"}/g' /config/.google.token google_token: sed -i -e 's/2client.client"}2client.client"}/2client.client"}/g' /config/.google.token

View File

@ -239,9 +239,20 @@ sensor:
lighting_stike_count: lighting_stike_count:
friendly_name: "Lightning Strike Count" friendly_name: "Lightning Strike Count"
value_template: "{{ states('sensor.acurite_6045m_3078_strcnt') }}" value_template: "{{ states('sensor.acurite_6045m_3078_strcnt') }}"
yesterday_rainfall_in:
friendly_name: "Yesterday Rainfall"
value_template: "{{ state_attr('sensor.daily_rainfall_in', 'last_period') }}"
previous_rainfall: previous_rainfall:
friendly_name: "Past 48h Rainfall" friendly_name: "Past 48h Rainfall"
value_template: "{{ states('sensor.daily_rainfall_in') | int + state_attr('sensor.daily_rainfall_in', 'previous_period') | int }}" value_template: "{{ states('sensor.daily_rainfall_in') | int + state_attr('sensor.daily_rainfall_in', 'last_period') | int }}"
lightning_warning:
friendly_name: "Lightning Warning"
value_template: >-
{%- if states('sensor.recent_lightning_strikes') | int > 0 %}
Unsafe
{% else %}
Safe
{%- endif %}
automation: automation:

View File

@ -104,6 +104,16 @@ sensor:
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{{ warnings.count }} {{ warnings.count }}
flood_warning_count: >-
{% set warnings = namespace(count=0) %}
{% if (state_attr('sensor.weatheralerts', 'alerts')) %}
{% for alert in state_attr('sensor.weatheralerts', 'alerts') %}
{% if 'flood warning' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %}
{% set warnings.count = warnings.count + 1 %}
{% endif %}
{% endfor %}
{% endif %}
{{ warnings.count }}
watch_count: >- watch_count: >-
{% set watches = namespace(count=0) %} {% set watches = namespace(count=0) %}
{% if (state_attr('sensor.weatheralerts', 'alerts')) %} {% if (state_attr('sensor.weatheralerts', 'alerts')) %}
@ -134,6 +144,16 @@ sensor:
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{{ watches.count }} {{ watches.count }}
flood_watch_count: >-
{% set watches = namespace(count=0) %}
{% if (state_attr('sensor.weatheralerts', 'alerts')) %}
{% for alert in state_attr('sensor.weatheralerts', 'alerts') %}
{% if 'flood watch' in alert.event.lower() and (as_timestamp(alert['endsExpires']) - as_timestamp(now()) > 0) %}
{% set watches.count = watches.count + 1 %}
{% endif %}
{% endfor %}
{% endif %}
{{ watches.count }}
advisory_count: >- advisory_count: >-
{% set advisories = namespace(count=0) %} {% set advisories = namespace(count=0) %}
{% if (state_attr('sensor.weatheralerts', 'alerts')) %} {% if (state_attr('sensor.weatheralerts', 'alerts')) %}
@ -1429,23 +1449,85 @@ automation:
entity_id: input_text.weatheralerts_triggered_alert_ids entity_id: input_text.weatheralerts_triggered_alert_ids
value: "{{ state_attr('sensor.weatheralerts_alert_1', 'alert_id') }} {{ state_attr('sensor.weatheralerts_alert_2', 'alert_id') }} {{ state_attr('sensor.weatheralerts_alert_3', 'alert_id') }} {{ state_attr('sensor.weatheralerts_alert_4', 'alert_id') }} {{ state_attr('sensor.weatheralerts_alert_5', 'alert_id') }}" value: "{{ state_attr('sensor.weatheralerts_alert_1', 'alert_id') }} {{ state_attr('sensor.weatheralerts_alert_2', 'alert_id') }} {{ state_attr('sensor.weatheralerts_alert_3', 'alert_id') }} {{ state_attr('sensor.weatheralerts_alert_4', 'alert_id') }} {{ state_attr('sensor.weatheralerts_alert_5', 'alert_id') }}"
- alias: NWS Notification Weather Alert # - alias: NWS Notification Weather Alert
# trigger:
# - platform: numeric_state
# entity_id: sensor.weatheralerts_active_alerts
# attribute: warning_count
# above: 0
# - platform: numeric_state
# entity_id: sensor.weatheralerts_active_alerts
# attribute: watch_count
# above: 0
# action:
# - service: script.text_notify
# data_template:
# title: "Weather Alert for Anchorage House"
# message: >
# There are currently {{ state_attr('sensor.weatheralerts_active_alerts', 'warning_count') | int }} active warnings and {{ state_attr('sensor.weatheralerts_active_alerts', 'watch_count') | int }} watches for our area.
- alias: NWS Tornado Watch Notification
id: e1cb2b7c-0423-11eb-adc1-0242ac120002
trigger: trigger:
- platform: numeric_state - platform: numeric_state
entity_id: sensor.weatheralerts_active_alerts entity_id: sensor.weatheralerts_active_alerts
attribute: warning_count attribute: tornado_watch_count
above: 0 above: 0
id: watch
- platform: numeric_state - platform: numeric_state
entity_id: sensor.weatheralerts_active_alerts entity_id: sensor.weatheralerts_active_alerts
attribute: watch_count attribute: tornado_watch_count
above: 0 below: 1
id: cancel
action: action:
- service: script.text_notify - choose:
data_template: - conditions:
title: "Weather Alert for Anchorage House" - condition: trigger
message: > id: watch
There are currently {{ state_attr('sensor.weatheralerts', 'warning_count') | int }} active warnings and {{ state_attr('sensor.weatheralerts', 'watch_count') | int }} watches for our area. sequence:
- service: script.text_notify
data_template:
message: "Tornado Watch Issued for Anchorage House"
- conditions:
- condition: trigger
id: cancel
sequence:
- service: script.text_notify
data_template:
message: "Tornado Watch no longer in effect for Anchorage House"
default: []
- alias: NWS TStorm Watch Notification
id: e1cb2938-0423-11eb-adc1-0242ac120002
trigger:
- platform: numeric_state
entity_id: sensor.weatheralerts_active_alerts
attribute: tstorm_watch_count
above: 0
id: watch
- platform: numeric_state
entity_id: sensor.weatheralerts_active_alerts
attribute: tstorm_watch_count
below: 1
id: cancel
action:
- choose:
- conditions:
- condition: trigger
id: watch
sequence:
- service: script.text_notify
data_template:
message: "Severe Thunderstorm Watch Issued for Anchorage House"
- conditions:
- condition: trigger
id: cancel
sequence:
- service: script.text_notify
data_template:
message: "Severe Thunderstorm no longer in effect for Anchorage House"
default: []
# Announce Severe Weather # Announce Severe Weather
- alias: NWS Announce Weather Alert - alias: NWS Announce Weather Alert
@ -1464,6 +1546,9 @@ automation:
- condition: template - condition: template
value_template: "{{ state_attr('sensor.weatheralerts_alert_1', 'alert_id') not in states('input_text.weatheralerts_triggered_audible_alert_ids') }}" value_template: "{{ state_attr('sensor.weatheralerts_alert_1', 'alert_id') not in states('input_text.weatheralerts_triggered_audible_alert_ids') }}"
action: action:
- service: script.text_notify
data_template:
message: "Severe Thunderstorm Warning Issued for Anchorage House"
- service: script.status_annc - service: script.status_annc
data_template: data_template:
who: '{{ states.sensor.room_presence.state }}' who: '{{ states.sensor.room_presence.state }}'
@ -1496,6 +1581,9 @@ automation:
attribute: tornado_warning_count attribute: tornado_warning_count
above: 0 above: 0
action: action:
- service: script.text_notify
data_template:
message: "Tornado Warning Issued for Anchorage House"
- service: script.jarvis_alert - service: script.jarvis_alert
data_template: data_template:
message: "Attention!,,,Attention!,,,The National Weather Service Has issued a Tornado Warning for our area." message: "Attention!,,,Attention!,,,The National Weather Service Has issued a Tornado Warning for our area."
@ -1532,7 +1620,7 @@ automation:
- alias: Lightning Detected - alias: Lightning Detected
trigger: trigger:
- platform: state - platform: state
entity_id: binary_sensor.lightning_detected_2 entity_id: sensor.lightning_warning
to: 'Unsafe' to: 'Unsafe'
condition: condition:
- condition: state - condition: state
@ -1552,7 +1640,7 @@ automation:
- alias: Lightning Warning Off - alias: Lightning Warning Off
trigger: trigger:
- platform: state - platform: state
entity_id: binary_sensor.lightning_detected_2 entity_id: sensor.lightning_warning
to: 'Safe' to: 'Safe'
for: for:
minutes: 20 minutes: 20