Example #1
0
 def __init__(self, config, name):
     self._config = config
     self._name = f"{config.mqtt.client_id} {config.camera.name} {name}"
     self._device_name = f"{config.mqtt.client_id} {config.camera.name}"
     self._unique_id = helpers.slugify(self._name)
     self._node_id = self._config.camera.mqtt_name
     self._object_id = helpers.slugify(name)
Example #2
0
 def __init__(self, config, mqtt_queue, object_id=""):
     self._config = config
     self._mqtt_queue = mqtt_queue
     self._object_id = object_id
     self._node_id = config.camera.mqtt_name
     self._name = config.camera.mqtt_name
     self._device_name = f"{config.mqtt.client_id} {config.camera.name}"
     self._unique_id = slugify(self.name)
Example #3
0
 def __init__(self, config, face):
     self._config = config
     self._name = f"{config.mqtt.client_id} Face detected {face}"
     self._friendly_name = f"Face detected {face}"
     self._device_name = config.mqtt.client_id
     self._unique_id = self._name
     self._node_id = slugify(config.mqtt.client_id)
     self._object_id = f"face_detected_{slugify(face)}"
Example #4
0
def ensure_mqtt_name(camera: Dict[str, str]) -> Dict[str, str]:
    """Ensure name is compatible with MQTT."""
    if camera["mqtt_name"] is None:
        camera["mqtt_name"] = slugify(camera["name"])

    match = MQTT_NAME_REGEX.match(camera["mqtt_name"])

    if not match:
        raise Invalid(
            f"Error in config for camera {camera['name']}. "
            f"mqtt_name can only contain the characters [a-zA-Z0-9_], "
            f"got {camera['mqtt_name']}")

    return camera
Example #5
0
 def __init__(self, camera):
     super().__init__(camera)
     self._name = camera["name"]
     self._name_slug = slugify(self.name)
     self._mqtt_name = camera["mqtt_name"]
     self._global_args = camera["global_args"]
     self._filter_args = camera["filter_args"]
     self._substream = None
     if camera.get("substream", None):
         self._substream = Substream(camera)
     self._motion_detection = camera.get("motion_detection", {})
     self._object_detection = camera.get("object_detection", {})
     self._zones = self.generate_zones(camera["zones"])
     self._publish_image = camera["publish_image"]
     self._ffmpeg_loglevel = camera["ffmpeg_loglevel"]
     self._ffmpeg_recoverable_errors = camera["ffmpeg_recoverable_errors"]
     self._static_mjpeg_streams = camera["static_mjpeg_streams"]
     self._logging = None
     if camera.get("logging", None):
         self._logging = LoggingConfig(camera["logging"])
Example #6
0
    def __init__(self, camera, motion_detection):
        # Inherit values from global motion detection config
        if not camera.get("motion_detection"):
            camera["motion_detection"] = {}

        camera["motion_detection"]["type"] = motion_detection["type"]
        local_motion_detection_config = motion_detection.copy()
        local_motion_detection_config.update(camera["motion_detection"])
        camera["motion_detection"] = local_motion_detection_config

        self._schema = self.build_schema(camera)

        self._validated_config = self._schema(camera)

        super().__init__(self._validated_config)
        self._name = self._validated_config["name"]
        self._name_slug = slugify(self.name)
        self._mqtt_name = self._validated_config["mqtt_name"]
        self._global_args = self._validated_config["global_args"]
        self._substream = None
        if self._validated_config.get("substream", None):
            self._substream = Substream(self._validated_config)
        self._motion_detection = self._validated_config.get(
            "motion_detection", {})
        self._object_detection = self._validated_config.get(
            "object_detection", {})
        self._zones = self.generate_zones(self._validated_config["zones"])
        self._publish_image = self._validated_config["publish_image"]
        self._ffmpeg_loglevel = self._validated_config["ffmpeg_loglevel"]
        self._ffmpeg_recoverable_errors = self._validated_config[
            "ffmpeg_recoverable_errors"]
        self._ffprobe_loglevel = self._validated_config["ffprobe_loglevel"]
        self._static_mjpeg_streams = self._validated_config[
            "static_mjpeg_streams"]
        self._logging = None
        if self._validated_config.get("logging", None):
            self._logging = LoggingConfig(self._validated_config["logging"])