forked from Github/frigate
Publish audio detections (#7159)
* Send mqtt message when audio is detected * Fix value * Add audio topics to mqtt docs and add mqtt headers * Use existing standard for values * Update mqtt.md
This commit is contained in:
@@ -228,6 +228,10 @@ class AudioEventMaintainer(threading.Thread):
|
||||
"last_detection"
|
||||
] = datetime.datetime.now().timestamp()
|
||||
else:
|
||||
self.inter_process_communicator.queue.put(
|
||||
(f"{self.config.name}/audio/{label}", "ON")
|
||||
)
|
||||
|
||||
resp = requests.post(
|
||||
f"{FRIGATE_LOCALHOST}/api/events/{self.config.name}/{label}/create",
|
||||
json={"duration": None, "source_type": "audio"},
|
||||
@@ -252,6 +256,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']}", "OFF")
|
||||
)
|
||||
|
||||
resp = requests.put(
|
||||
f"{FRIGATE_LOCALHOST}/api/events/{detection['id']}/end",
|
||||
json={
|
||||
@@ -259,6 +267,7 @@ class AudioEventMaintainer(threading.Thread):
|
||||
+ self.config.record.events.post_capture
|
||||
},
|
||||
)
|
||||
|
||||
if resp.status_code == 200:
|
||||
self.detections[detection["label"]] = None
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user