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:
Nicolas Mowen
2023-07-14 18:06:00 -06:00
committed by GitHub
parent 00016b7499
commit dfd3fcdff6
2 changed files with 46 additions and 17 deletions

View File

@@ -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: