ensure each camera has a detect role set

This commit is contained in:
Blake Blackshear 2021-01-15 22:01:24 -06:00
parent 89e02b6956
commit c1f0750526

View File

@ -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]),