From c25367221e6702677b575320a3ef7b9345346be7 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sat, 1 Jul 2023 15:33:47 -0600 Subject: [PATCH] Fix audio events not being ended (#6981) * Fix audio events not being ended * Fix audio events not being ended correctly * Clean up debug code --- frigate/events/audio.py | 5 ++++- frigate/events/maintainer.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frigate/events/audio.py b/frigate/events/audio.py index e1d25e018..164c9c62d 100644 --- a/frigate/events/audio.py +++ b/frigate/events/audio.py @@ -202,11 +202,13 @@ class AudioEventMaintainer(threading.Thread): now = datetime.datetime.now().timestamp() for detection in self.detections.values(): + if not detection: + continue + if ( now - detection.get("last_detection", now) > self.config.audio.max_not_heard ): - del self.detections[detection["label"]] requests.put( f"{FRIGATE_LOCALHOST}/api/events/{detection['id']}/end", json={ @@ -214,6 +216,7 @@ class AudioEventMaintainer(threading.Thread): + self.config.record.events.post_capture }, ) + self.detections[detection["label"]] = None def restart_audio_pipe(self) -> None: try: diff --git a/frigate/events/maintainer.py b/frigate/events/maintainer.py index f024f0be6..d688f7dfe 100644 --- a/frigate/events/maintainer.py +++ b/frigate/events/maintainer.py @@ -239,6 +239,6 @@ class EventProcessor(threading.Thread): } try: - Event.update(event).execute() + Event.update(event).where(Event.id == event_data["id"]).execute() except Exception: logger.warning(f"Failed to update manual event: {event_data['id']}")