I have the lighting automation that tells where lighting is hitting. I have it announce anything above 0. Can you put a math problem there? I was the first 5 announced. Then every 5 after that? Like cron jobs you can do /5 for every 5 minutes. So every 5 or ten strikes after the first five would be great. We had 345 strikes in one storm. It never shut up while the storm can through.
He is my other problem. (Back Story) I am the admin for 2 Ham Radio repeater. There both in Linux. I wrote a scripting program that will announce the alert over the repeater. No what I am looking for. I have it broadcasting every 15 minutes, first hour, 30 minutes, second hour, and once an hour if it continues after that. If a new alert comes in. The process starts over. But all the alerts are still there. I can not figure out an easy way to do this. Only thing I can think of is make waits. but that will get complicated. Id didn’t know if there is anyone that can help with this.
- id: '1623121460811'
alias: Lighting Notify
description: ''
trigger:
- platform: state
entity_id: sensor.lighting_detection_lightning_counter
condition:
- condition: numeric_state
entity_id: sensor.lighting_detection_lightning_counter
above: '0' ***Can this be multiples?***
- condition: or
conditions:
- condition: time
after: 08:00:00
before: '22:00:00'
action:
- service: tts.google_translate_say
data:
entity_id: media_player.bedroom_speaker
message: Lighting has been detected within {{(states('sensor.lighting_detection_lightning_distance') | int / 1.69) | round (1,'floor') }} miles of our house.
- condition: not
conditions:
- condition: state
entity_id: person.me
state: home
- service: notify.mobile_app_sm_n950u
data:
message: TTS
data:
ttl: 0
priority: high
channel: alarm_stream
title: Lighting has been detected within {{(states('sensor.lighting_detection_lightning_distance')
| int / 1.69) | round (1,'floor') }} miles of our house.
mode: single
#######################################################################
# Main Program
# Run's in background, called by getWxAlert
while [ -f $WXALERT_TEXT ] ; do
# initial broadcast
# check if lock file is present. If so, wait for file to be
# removed, this prevents alert announcements from simultaneioulsy
# being sent.
# if NO_WXALERT file is present, skip playing msg
if [ ! -f $NO_WXALERT_MSG ] ; then
while [ -f /tmp/playWxAlertBg-lock ] ; do
sleep 30
done
# set lock file
echo $MYPROC > /tmp/playWxAlertBg-lock
Msg="Playing Wx Alert (initial) for $COUNTY"
PlayAlert
# clear lock file
rm /tmp/playWxAlertBg-lock
else
log "Skipping Wx Alert (initial) for $COUNTY, $NO_WXALERT_MSG present"
fi
# play time is initial, 15m, 15m, 15m, 30m, 30m, then every 60m
for SLEEPTIME in 900 900 900 1800 1800 ; do
# sleep 15 mins (900)
sleep $SLEEPTIME
if [ ! -f $WXALERT_TEXT ] ; then
break
fi
if [ ! -f $NO_WXALERT_MSG ] ; then
# check if lock file is present. If so, wait for file to be
# removed, this prevents alert announcements from simultaneioulsy
# being sent.
while [ -f /tmp/playWxAlertBg-lock ] ; do
sleep 30
done
# set lock file
echo $MYPROC > /tmp/playWxAlertBg-lock
Msg="Playing Wx Alert (${SLEEPTIME}s) for $COUNTY"
PlayAlert
# clear lock file
rm /tmp/playWxAlertBg-lock
else
log "Skipping Wx Alert (${SLEEPTIME}s) for $COUNTY, $NO_WXALERT_MSG present"
fi
done
while [ -f $WXALERT_TEXT ] ; do
#every 60m
sleep 3600
if [ ! -f $WXALERT_TEXT ] ; then
break
fi
if [ ! -f $NO_WXALERT_MSG ] ; then
# check if lock file is present.
while [ -f /tmp/playWxAlertBg-lock ] ; do
sleep 30
done
# set lock file
echo $MYPROC > /tmp/playWxAlertBg-lock
Msg="Playing Wx Alert (${SLEEPTIME}s) for $COUNTY"
PlayAlert
# clear lock file
rm /tmp/playWxAlertBg-lock
else
log "Skipping Wx Alert (${SLEEPTIME}s) for $COUNTY, $NO_WXALERT_MSG present"
fi
done
done
# remove PID file
rm $WXALERT_SPOOLDIR/$COUNTY/playWxAlertBg.pid
# remove NO_WXALERT_MSG file
if [ -f $NO_WXALERT_MSG ] ; then
rm -r $NO_WXALERT_MSG
fi
log "Alert over for $COUNTY"
exit 0
It is in the sleep section. I tried making some of this in Nodered and I am not real happy with node red. What I am worried about is that this restarts when the new alert comes in. Then they all start over. and play together.
hold on I need to add the weather alert automation. That was the lighting. Still need to figure that out.
- id: '1624065368785'
alias: NWS Notification Weather Alert
description: ''
trigger:
- platform: state
entity_id: sensor.nws_alert_count_filtered
condition:
- condition: and
conditions:
- condition: template
value_template: '{{states.sensor.nws_alert_count_filtered.state | int > 0}}'
- condition: template
value_template: '{{ ((''Severe'' in states.sensor.nws_alert_event_filtered.state)
or (''Tornado'' in states.sensor.nws_alert_event_filtered.state)) and ''Warning''
in states.sensor.nws_alert_event_filtered.state }}'
- condition: or
conditions:
- condition: time
after: 08:00:00
before: '23:00:00'
- condition: template
value_template: '{{ ''Warning'' in states.sensor.nws_alert_event_filtered.state
}}'
action:
- service: tts.google_translate_say
data:
entity_id: media_player.home_group
message: Attention!,,,Attention!,,,The National Weather Service has issued a {{
states.sensor.nws_alert_event_filtered.state }} for your area. It
expires at {{ as_timestamp(state_attr('sensor.nws_alert_event_raw', 'features')[0].properties.expires)|
timestamp_custom('%-I:%M %p on %-m-%-d-%Y') }}.
mode: single
I have 5 of them cause we can have 5 alerts at once.
I solved this myself. I actually thought outside the box. (outside box = home assistant) What I did was, in the script for the other weather alert. That I have actually running the way it needs to on my ham repeater. I use webhooks. I was watching a youtube video on web hooks. make a script that is tailored to the actual alert. Then I made a web hook that controls that script that I created. Then in the box that already runs the weather alert. I use curl POST to make the request and it plays everytime.