Fix Frigate event schema break (top_score === null)

This commit is contained in:
Dermot Duffy
2023-05-06 11:46:30 -07:00
parent 23a69f007f
commit cb6a73c3f8
4 changed files with 188 additions and 5 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ const eventSchema = z.object({
label: z.string(),
sub_label: z.string().nullable(),
start_time: z.number(),
top_score: z.number(),
top_score: z.number().nullable(),
zones: z.string().array(),
retain_indefinitely: z.boolean().optional(),
});
+4 -4
View File
@@ -14,11 +14,11 @@ export const getEventTitle = (event: FrigateEvent): string => {
? event.end_time - event.start_time
: Date.now() / 1000 - event.start_time,
);
const score = event.top_score !== null ? ` ${Math.round(event.top_score * 100)}%` : '';
return `${formatDateAndTime(
utcToZonedTime(event.start_time * 1000, localTimezone),
)} [${durationSeconds}s, ${prettifyTitle(event.label)} ${Math.round(
event.top_score * 100,
)}%]`;
)} [${durationSeconds}s, ${prettifyTitle(event.label)}${score}]`;
};
export const getRecordingTitle = (
@@ -93,5 +93,5 @@ export const getRecordingID = (
// can be dedup'd from this id.
return `${cameraConfig.frigate?.client_id ?? ''}/${
cameraConfig.frigate.camera_name ?? ''
}/${recording.startTime.getTime()}/${recording.endTime.getTime()}}`;
}/${recording.startTime.getTime()}/${recording.endTime.getTime()}`;
};