Send mqtt message when motion is detected

This commit is contained in:
Nick Mowen 2022-04-26 14:13:52 -06:00
parent 0a4d658c7f
commit a57b60e259
2 changed files with 11 additions and 0 deletions

View File

@ -255,6 +255,8 @@ class FrigateApp:
args=(
name,
config,
self.mqtt_client,
self.config.mqtt.topic_prefix,
model_shape,
self.config.model.merged_labelmap,
self.detection_queue,

View File

@ -340,6 +340,8 @@ def capture_camera(name, config: CameraConfig, process_info):
def track_camera(
name,
config: CameraConfig,
mqtt_client,
mqtt_prefix,
model_shape,
labelmap,
detection_queue,
@ -381,6 +383,8 @@ def track_camera(
process_frames(
name,
mqtt_client,
mqtt_prefix,
frame_queue,
frame_shape,
model_shape,
@ -468,6 +472,8 @@ def detect(
def process_frames(
camera_name: str,
mqtt_client,
mqtt_prefix,
frame_queue: mp.Queue,
frame_shape,
model_shape,
@ -518,6 +524,9 @@ def process_frames(
# look for motion if enabled
motion_boxes = motion_detector.detect(frame) if motion_enabled.value else []
if mqtt_client:
mqtt_client(f"{mqtt_prefix}/{camera_name}/motion/detected", True if motion_boxes else False, False)
regions = []
# if detection is disabled