This is a fun project I worked on.
If there is lightning within 10 miles detected by my Tempest Weather Station (and near by sensors), it will send a SMS notification and also play an audible alert in my outdoor space.
alias: "Safety: Lightning Strike"
description: ""
trigger:
- platform: state
entity_id:
- sensor.weatherflow_last_lightning_strike
condition:
- condition: numeric_state
entity_id: sensor.weatherflow_last_lightning_strike_distance
below: 10
action:
- variables:
ttsmessage: >-
Lightning has been detected within {{
states('sensor.weatherflow_last_lightning_strike_distance') }} miles.
Please stop outdoor activities and seek shelter until at least 30
minutes after the most recent strike, which is currently {{
(as_timestamp(now()) + 1800) | timestamp_custom('%I:%M%p') }}.
smsmessage: "666 Evil St: {{ ttsmessage }}"
- service: notify.twilio_sms
data:
message: "{{ smsmessage }}"
target:
- "+155555551212"
- if:
- condition: time
after: "08:00:00"
before: "22:00:00"
then:
- repeat:
count: "2"
sequence:
- repeat:
count: "3"
sequence:
- service: media_player.play_media
target:
entity_id:
- media_player.pool_1
- media_player.pool_2
- media_player.deck
data:
announce: true
media_content_id: >-
https://www.mydomain.com/public/urgent_alert.mp3
media_content_type: music
extra:
volume: 70
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: media_player.play_media
target:
entity_id:
- media_player.pool_1
- media_player.pool_2
- media_player.deck
data:
announce: true
media_content_id: media-source://tts/cloud?message={{ ttsmessage | urlencode }}
media_content_type: provider
extra:
volume: 70
- delay:
seconds: >
{% set l = ttsmessage|length %} {% set speed = 120 %} {% set
duration_seconds = ((speed *
l)/1000)|round(0,method='ceil')|int %} {{ duration_seconds }}
- delay:
hours: 0
minutes: 25
seconds: 0
milliseconds: 0
enabled: true
mode: single