Send mqtt message when audio is detected

This commit is contained in:
Nick Mowen 2023-07-14 07:51:40 -06:00
parent 598ae98bfe
commit 09451e7c16

View File

@ -214,6 +214,10 @@ class AudioEventMaintainer(threading.Thread):
"last_detection"
] = datetime.datetime.now().timestamp()
else:
self.inter_process_communicator.queue.put(
(f"{self.config.name}/audio/{label}", True)
)
resp = requests.post(
f"{FRIGATE_LOCALHOST}/api/events/{self.config.name}/{label}/create",
json={"duration": None, "source_type": "audio"},
@ -238,6 +242,10 @@ class AudioEventMaintainer(threading.Thread):
now - detection.get("last_detection", now)
> self.config.audio.max_not_heard
):
self.inter_process_communicator.queue.put(
(f"{self.config.name}/audio/{detection['label']}", True)
)
resp = requests.put(
f"{FRIGATE_LOCALHOST}/api/events/{detection['id']}/end",
json={
@ -245,6 +253,7 @@ class AudioEventMaintainer(threading.Thread):
+ self.config.record.events.post_capture
},
)
if resp.status_code == 200:
self.detections[detection["label"]] = None
else: