Update 'notify/src/ntfy.py'
This commit is contained in:
parent
d29d9e16f0
commit
a13f099e14
|
@ -3,15 +3,15 @@ import requests
|
||||||
from datetime import datetime, timedelta
|
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):
|
def send_rate_limited_notification(event_id, camera, object_label, score, quiet_period=1):
|
||||||
global last_notification_time
|
global last_notification_time
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
if last_notification_time is None or now - last_notification_time >= timedelta(minutes=quiet_period):
|
if camera not in last_notification_time or now - last_notification_time[camera] >= timedelta(minutes=quiet_period):
|
||||||
last_notification_time = now
|
last_notification_time[camera] = now
|
||||||
send_notification(event_id, camera, object_label, score, priority=3)
|
send_notification(event_id, camera, object_label, score, priority=3)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue