Skip to content

NVR with realtime local object detection for IP cameras

Publish audio detections (#7159)

Nicolas Mowendfd3fcdff6e0
diff --git a/docs/docs/integrations/mqtt.md b/docs/docs/integrations/mqtt.md
index 8f690bcaab..cd6de8651e 100644
--- a/docs/docs/integrations/mqtt.md
+++ b/docs/docs/integrations/mqtt.md
@@ -5,6 +5,8 @@ title: MQTT
These are the MQTT messages generated by Frigate. The default topic_prefix is `frigate`, but can be changed in the config file.
+## General Frigate Topics
+
### `frigate/available`
Designed to be used as an availability topic with Home Assistant. Possible message are:
@@ -15,23 +17,6 @@ Designed to be used as an availability topic with Home Assistant. Possible messa
Causes Frigate to exit. Docker should be configured to automatically restart the container on exit.
-### `frigate/<camera_name>/<object_name>`
-
-Publishes the count of objects for the camera for use as a sensor in Home Assistant.
-`all` can be used as the object_name for the count of all objects for the camera.
-
-### `frigate/<zone_name>/<object_name>`
-
-Publishes the count of objects for the zone for use as a sensor in Home Assistant.
-`all` can be used as the object_name for the count of all objects for the zone.
-
-### `frigate/<camera_name>/<object_name>/snapshot`
-
-Publishes a jpeg encoded frame of the detected object type. When the object is no longer detected, the highest confidence image is published or the original image
-is published again.
-
-The height and crop of snapshots can be configured in the config.
-
### `frigate/events`
Message published for each changed event. The first message is published when the tracked object is no longer marked as a false_positive. When Frigate finds a better snapshot of the tracked object or when a zone change occurs, it will publish a message with the same id. When the event ends, a final message is published with `end_time` set.
@@ -111,6 +96,41 @@ Message published for each changed event. The first message is published when th
Same data available at `/api/stats` published at a configurable interval.
+## Frigate Camera Topics
+
+### `frigate/<camera_name>/<object_name>`
+
+Publishes the count of objects for the camera for use as a sensor in Home Assistant.
+`all` can be used as the object_name for the count of all objects for the camera.
+
+### `frigate/<zone_name>/<object_name>`
+
+Publishes the count of objects for the zone for use as a sensor in Home Assistant.
+`all` can be used as the object_name for the count of all objects for the zone.
+
+### `frigate/<camera_name>/<object_name>/snapshot`
+
+Publishes a jpeg encoded frame of the detected object type. When the object is no longer detected, the highest confidence image is published or the original image
+is published again.
+
+The height and crop of snapshots can be configured in the config.
+
+### `frigate/<camera_name>/audio/<audio_type>`
+
+Publishes "ON" when a type of audio is detected and "OFF" when it is not for the camera for use as a sensor in Home Assistant.
+
+### `frigate/<camera_name>/audio/dBFS`
+
+Publishes the dBFS value for audio detected on this camera.
+
+**NOTE:** Requires audio detection to be enabled
+
+### `frigate/<camera_name>/audio/rms`
+
+Publishes the rms value for audio detected on this camera.
+
+**NOTE:** Requires audio detection to be enabled
+
### `frigate/<camera_name>/detect/set`
Topic to turn object detection for a camera on and off. Expected values are `ON` and `OFF`.
diff --git a/frigate/events/audio.py b/frigate/events/audio.py
index a9d9b82c75..1c39e4d59e 100644
--- a/frigate/events/audio.py
+++ b/frigate/events/audio.py
@@ -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: