Procházet zdrojové kódy

ensure each camera has a detect role set

Blake Blackshear před 4 roky
rodič
revize
c1f0750526
1 změnil soubory, kde provedl 8 přidání a 1 odebrání
  1. 8 1
      frigate/config.py

+ 8 - 1
frigate/config.py

@@ -146,6 +146,12 @@ def each_role_used_once(inputs):
         raise ValueError
     return inputs
 
+def detect_is_required(inputs):
+    roles = [role for i in inputs for role in i['roles']]
+    if not 'detect' in roles:
+        raise ValueError
+    return inputs
+
 CAMERA_FFMPEG_SCHEMA = vol.Schema(
     {
         vol.Required('inputs'): vol.All([{
@@ -154,7 +160,8 @@ CAMERA_FFMPEG_SCHEMA = vol.Schema(
             'global_args':  vol.Any(str, [str]),
             'hwaccel_args': vol.Any(str, [str]),
             'input_args': vol.Any(str, [str]),
-        }], vol.Msg(each_role_used_once, msg="Each input role may only be used once")),
+        }], vol.Msg(each_role_used_once, msg="Each input role may only be used once"), 
+            vol.Msg(detect_is_required, msg="The detect role is required")),
         'output_args': {
             vol.Optional('detect', default=DETECT_FFMPEG_OUTPUT_ARGS_DEFAULT): vol.Any(str, [str]),
             vol.Optional('record', default=RECORD_FFMPEG_OUTPUT_ARGS_DEFAULT): vol.Any(str, [str]),