diff --git a/frigate/config.py b/frigate/config.py index 883215d83..eb2b47869 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -216,7 +216,9 @@ CAMERAS_SCHEMA = vol.Schema(vol.All( }, 'objects': OBJECTS_SCHEMA, vol.Optional('motion', default={}): MOTION_SCHEMA, - vol.Optional('detect', default={}): DETECT_SCHEMA + vol.Optional('detect', default={}): DETECT_SCHEMA.extend({ + vol.Optional('enabled', default=True): bool + }) } }, vol.Msg(ensure_zones_and_cameras_have_different_names, msg='Zones cannot share names with cameras')) ) @@ -737,14 +739,20 @@ class MotionConfig(): class DetectConfig(): def __init__(self, global_config, config, camera_fps): + self._enabled = config['enabled'] self._max_disappeared = config.get('max_disappeared', global_config.get('max_disappeared', camera_fps*2)) + @property + def enabled(self): + return self._enabled + @property def max_disappeared(self): return self._max_disappeared def to_dict(self): return { + 'enabled': self.enabled, 'max_disappeared': self._max_disappeared, } diff --git a/frigate/mqtt.py b/frigate/mqtt.py index 44c3edfb3..98b027972 100644 --- a/frigate/mqtt.py +++ b/frigate/mqtt.py @@ -65,14 +65,18 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics): camera_name = message.topic.split('/')[-3] command = message.topic.split('/')[-1] + detect_settings = config.cameras[camera_name].detect + if payload == 'ON': if not camera_metrics[camera_name]["detection_enabled"].value: logger.info(f"Turning on detection for {camera_name} via mqtt") camera_metrics[camera_name]["detection_enabled"].value = True + detect_settings._enabled = True elif payload == 'OFF': if camera_metrics[camera_name]["detection_enabled"].value: logger.info(f"Turning off detection for {camera_name} via mqtt") camera_metrics[camera_name]["detection_enabled"].value = False + detect_settings._enabled = False else: logger.warning(f"Received unsupported value at {message.topic}: {payload}")