mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-02 05:44:03 +02:00
At most 1 notification every 30 minutes
https://github.com/alexbelgium/hassio-addons/issues/1749
This commit is contained in:
@@ -26,6 +26,7 @@ srv="birdnet_recording"
|
|||||||
srv2="birdnet_analysis"
|
srv2="birdnet_analysis"
|
||||||
ingest_dir="$RECS_DIR/StreamData"
|
ingest_dir="$RECS_DIR/StreamData"
|
||||||
counter=10
|
counter=10
|
||||||
|
last_notification_time=0
|
||||||
|
|
||||||
# Ensure directories and permissions
|
# Ensure directories and permissions
|
||||||
mkdir -p "$ingest_dir"
|
mkdir -p "$ingest_dir"
|
||||||
@@ -35,6 +36,15 @@ chmod -R 755 "$ingest_dir"
|
|||||||
# Function to send notifications using Apprise
|
# Function to send notifications using Apprise
|
||||||
apprisealert() {
|
apprisealert() {
|
||||||
local issue_message="$1"
|
local issue_message="$1"
|
||||||
|
local current_time=$(date +%s)
|
||||||
|
local time_diff=$((current_time - last_notification_time))
|
||||||
|
|
||||||
|
# Check if 30 minutes have passed since the last notification
|
||||||
|
if ((time_diff < 1800)); then
|
||||||
|
log_yellow "Notification suppressed to avoid spamming (last sent $time_diff seconds ago)"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
local notification=""
|
local notification=""
|
||||||
local stopped_service="<br><b>Stopped services:</b> "
|
local stopped_service="<br><b>Stopped services:</b> "
|
||||||
|
|
||||||
@@ -59,6 +69,7 @@ apprisealert() {
|
|||||||
TITLE="BirdNET-Analyzer Alert"
|
TITLE="BirdNET-Analyzer Alert"
|
||||||
if [[ -f "$HOME/BirdNET-Pi/birdnet/bin/apprise" && -s "$HOME/BirdNET-Pi/apprise.txt" ]]; then
|
if [[ -f "$HOME/BirdNET-Pi/birdnet/bin/apprise" && -s "$HOME/BirdNET-Pi/apprise.txt" ]]; then
|
||||||
"$HOME/BirdNET-Pi/birdnet/bin/apprise" -vv -t "$TITLE" -b "$notification" --input-format=html --config="$HOME/BirdNET-Pi/apprise.txt"
|
"$HOME/BirdNET-Pi/birdnet/bin/apprise" -vv -t "$TITLE" -b "$notification" --input-format=html --config="$HOME/BirdNET-Pi/apprise.txt"
|
||||||
|
last_notification_time=$current_time
|
||||||
else
|
else
|
||||||
log_red "Apprise not configured or missing!"
|
log_red "Apprise not configured or missing!"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user