You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
3.2 KiB

######################################################################
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Lightning Alerts - Nearby strike warnings and snooze workflow
# Related Issue: 1550
# Keeps push alerts but also logs to Activity feed.
# -------------------------------------------------------------------
# Guide: https://www.vcloudinfo.com/2020/08/adding-a-lightning-sensor-to-home-assistant.html | Existing Issue #392
# Notes: Lightning Notification owns lightning safety speech and intentionally
# holds a 60-minute cooldown; duplicate triggers are silenced.
# Notes: Wait briefly for numeric distance data, then fall back to "nearby"
# rather than aborting when the distance sensor is unavailable.
######################################################################
input_boolean:
snooze_lightning:
name: Snooze Lightning
initial: off
icon: mdi:weather-lightning
automation:
- alias: Snooze Lightning
id: 1f295bb8-8925-4b22-8f75-9l1ghtn1nga8
trigger:
platform: event
event_type: mobile_app_notification_action
event_data:
action: SNOOZE_LIGHTNING
action:
- service: input_boolean.turn_on
entity_id: input_boolean.snooze_lightning
- alias: 'Lightning Notification'
id: 6e054688-5e75-48bd-9411-52a3e26264d1
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: sensor.blitzortung_lightning_counter
condition:
- condition: state
entity_id: group.family
state: 'home'
- condition: numeric_state
entity_id: sensor.blitzortung_lightning_counter
above: 0
- condition: state
entity_id: input_boolean.snooze_lightning
state: 'off'
action:
- wait_template: >-
{{ is_number(states('sensor.blitzortung_lightning_distance')) }}
timeout: "00:00:05"
continue_on_timeout: true
- variables:
lightning_location: >-
{% set distance_km = states('sensor.blitzortung_lightning_distance') | float(none) %}
{% if distance_km is not none %}
within {{ (distance_km / 1.609344) | round(1) }} miles of our home
{% else %}
nearby
{% endif %}
- service: script.send_to_logbook
data:
topic: "WEATHER"
message: "Lightning detected {{ lightning_location }}."
- service: script.notify_engine_two_button
data:
title: 'Lightning Warning!'
value1: "Lightning has been detected {{ lightning_location }}. Be careful if outdoors."
title1: 'Snooze Alerts until tomorrow'
action1: 'SNOOZE_LIGHTNING'
icon1: 'sfsymbols:arrow.up.circle'
who: "Family"
group: 'Information'
- service: script.speech_engine
data:
value1: "Lightning has been detected {{ lightning_location }}. Please make sure everyone is inside the house."
call_window_check: 1
call_garage_check: 1
- delay:
minutes: 60

Powered by TurnKey Linux.