Update 'notify/src/ntfy.py'

This commit is contained in:
Ashish D'Souza 2023-05-20 18:21:11 -05:00
parent d29d9e16f0
commit a13f099e14
1 changed files with 3 additions and 3 deletions

View File

@ -3,15 +3,15 @@ import requests
from datetime import datetime, timedelta
last_notification_time = None
last_notification_time = {}
def send_rate_limited_notification(event_id, camera, object_label, score, quiet_period=1):
global last_notification_time
now = datetime.now()
if last_notification_time is None or now - last_notification_time >= timedelta(minutes=quiet_period):
last_notification_time = now
if camera not in last_notification_time or now - last_notification_time[camera] >= timedelta(minutes=quiet_period):
last_notification_time[camera] = now
send_notification(event_id, camera, object_label, score, priority=3)