Add a new convenience option to depend on all other cameras.

This commit is contained in:
Dermot Duffy
2022-06-10 09:10:42 -07:00
parent 40be446c69
commit 14bbb26e95
6 changed files with 73 additions and 30 deletions
+4 -4
View File
@@ -21,10 +21,10 @@ export const CONF_CAMERAS_ARRAY_WEBRTC_CARD_URL =
`${CONF_CAMERAS}.#.webrtc_card.url` as const;
export const CONF_CAMERAS_ARRAY_LIVE_PROVIDER =
`${CONF_CAMERAS}.#.live_provider` as const;
export const CONF_CAMERAS_ARRAY_DEPENDENT_CAMERAS =
`${CONF_CAMERAS}.#.dependent_cameras` as const;
export const CONF_CAMERAS_ARRAY_DEPENDENT_CAMERAS_ALL =
`${CONF_CAMERAS}.#.dependent_cameras_all` as const;
export const CONF_CAMERAS_ARRAY_DEPENDENCIES_CAMERAS =
`${CONF_CAMERAS}.#.dependencies.cameras` as const;
export const CONF_CAMERAS_ARRAY_DEPENDENCIES_ALL_CAMERAS =
`${CONF_CAMERAS}.#.dependencies.all_cameras` as const;
export const CONF_CAMERAS_ARRAY_TRIGGER_BY_MOTION =
`${CONF_CAMERAS}.#.trigger_by_motion` as const;
export const CONF_CAMERAS_ARRAY_TRIGGER_BY_OCCUPANCY =
+8 -5
View File
@@ -16,8 +16,8 @@ import {
CONF_CAMERAS_ARRAY_CAMERA_ENTITY,
CONF_CAMERAS_ARRAY_CAMERA_NAME,
CONF_CAMERAS_ARRAY_CLIENT_ID,
CONF_CAMERAS_ARRAY_DEPENDENT_CAMERAS,
CONF_CAMERAS_ARRAY_DEPENDENT_CAMERAS_ALL,
CONF_CAMERAS_ARRAY_DEPENDENCIES_ALL_CAMERAS,
CONF_CAMERAS_ARRAY_DEPENDENCIES_CAMERAS,
CONF_CAMERAS_ARRAY_ICON,
CONF_CAMERAS_ARRAY_ID,
CONF_CAMERAS_ARRAY_LABEL,
@@ -884,11 +884,14 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
getArrayConfigPath(CONF_CAMERAS_ARRAY_WEBRTC_CARD_URL, cameraIndex),
)}
${this._renderSwitch(
getArrayConfigPath(CONF_CAMERAS_ARRAY_DEPENDENT_CAMERAS_ALL, cameraIndex),
frigateCardConfigDefaults.cameras.dependent_cameras_all,
getArrayConfigPath(
CONF_CAMERAS_ARRAY_DEPENDENCIES_ALL_CAMERAS,
cameraIndex,
),
frigateCardConfigDefaults.cameras.dependencies.all_cameras,
)}
${this._renderOptionSelector(
getArrayConfigPath(CONF_CAMERAS_ARRAY_DEPENDENT_CAMERAS, cameraIndex),
getArrayConfigPath(CONF_CAMERAS_ARRAY_DEPENDENCIES_CAMERAS, cameraIndex),
dependentCameras,
{
multiple: true,
+4 -2
View File
@@ -15,8 +15,10 @@
"camera_entity": "Camera Entity",
"camera_name": "Frigate camera name (Autodetected from entity)",
"client_id": "Frigate client id (For >1 Frigate server)",
"dependent_cameras": "Show events for specific cameras with this camera",
"dependent_cameras_all": "Show events for all cameras with this camera",
"dependencies": {
"cameras": "Show events for specific cameras with this camera",
"all_cameras": "Show events for all cameras with this camera"
},
"id": "Unique id for this camera in this card",
"label": "Frigate label/object filter",
"frigate_url": "Frigate server URL",
+10 -6
View File
@@ -375,7 +375,10 @@ export const cameraConfigDefault = {
trigger_by_motion: false,
trigger_by_occupancy: true,
trigger_by_entities: [],
dependent_cameras_all: false,
dependencies: {
all_cameras: false,
cameras: [],
},
};
const webrtcCardCameraConfigSchema = z.object({
entity: z.string().optional(),
@@ -404,11 +407,12 @@ const cameraConfigSchema = z
// Camera identifiers for WebRTC.
webrtc_card: webrtcCardCameraConfigSchema.optional(),
// Set of cameras IDs upon which this camera depends.
dependent_cameras: z.string().array().optional(),
dependent_cameras_all: z
.boolean()
.default(cameraConfigDefault.dependent_cameras_all),
dependencies: z
.object({
all_cameras: z.boolean().default(cameraConfigDefault.dependencies.all_cameras),
cameras: z.string().array().default(cameraConfigDefault.dependencies.cameras),
})
.default(cameraConfigDefault.dependencies),
trigger_by_motion: z.boolean().default(cameraConfigDefault.trigger_by_motion),
trigger_by_occupancy: z.boolean().default(cameraConfigDefault.trigger_by_occupancy),
+2 -2
View File
@@ -265,10 +265,10 @@ export const getFullDependentBrowseMediaQueryParameters = (
if (cameraConfig) {
cameraIDs.add(camera);
const dependentCameras: Set<string> = new Set();
(cameraConfig.dependent_cameras || []).forEach((item) =>
(cameraConfig.dependencies.cameras || []).forEach((item) =>
dependentCameras.add(item),
);
if (cameraConfig.dependent_cameras_all) {
if (cameraConfig.dependencies.all_cameras) {
cameras.forEach((_, key) => dependentCameras.add(key));
}
for (const eventCameraID of dependentCameras) {