diff --git a/src/card.ts b/src/card.ts index 375eb7b9..1b57c24d 100644 --- a/src/card.ts +++ b/src/card.ts @@ -35,7 +35,7 @@ import type { Message, } from './types.js'; -import { CARD_VERSION, REPO_URL } from './const.js'; +import { CAMERA_BIRDSEYE, CARD_VERSION, REPO_URL } from './const.js'; import { FrigateCardElements } from './components/elements.js'; import { FrigateCardImage } from './components/image.js'; import { FRIGATE_BUTTON_MENU_ICON, FrigateCardMenu } from './components/menu.js'; @@ -333,7 +333,7 @@ export class FrigateCard extends LitElement { if ( this._getConfig().menu.buttons.clips && cameraConfig?.camera_name && - (cameraConfig?.camera_name !== 'birdseye' || + (cameraConfig?.camera_name !== CAMERA_BIRDSEYE || cameraConfig?.dependent_cameras?.length) ) { buttons.push({ @@ -351,7 +351,7 @@ export class FrigateCard extends LitElement { if ( this._getConfig().menu.buttons.snapshots && cameraConfig?.camera_name && - (cameraConfig?.camera_name !== 'birdseye' || + (cameraConfig?.camera_name !== CAMERA_BIRDSEYE || cameraConfig?.dependent_cameras?.length) ) { buttons.push({ diff --git a/src/components/timeline.ts b/src/components/timeline.ts index a473b3c3..3d8ad9ff 100644 --- a/src/components/timeline.ts +++ b/src/components/timeline.ts @@ -32,6 +32,7 @@ import { FrigateEvent, frigateCardConfigDefaults, } from '../types'; +import { CAMERA_BIRDSEYE } from '../const'; import { View, ViewContext } from '../view'; import { dispatchErrorMessageEvent, @@ -283,7 +284,7 @@ class TimelineEventManager { if ( this._dateEnd && this._dateStart && - cameraConfig.camera_name !== 'birdseye' + cameraConfig.camera_name !== CAMERA_BIRDSEYE ) { const param = BrowseMediaUtil.getBrowseMediaQueryParameters( hass, @@ -592,7 +593,7 @@ export class FrigateCardTimelineCore extends LitElement { protected _getGroups(): DataGroupCollectionType { const groups: FrigateCardGroupData[] = []; this.cameras?.forEach((cameraConfig, camera) => { - if (cameraConfig.camera_name !== 'birdseye') { + if (cameraConfig.camera_name !== CAMERA_BIRDSEYE) { groups.push({ id: camera, content: getCameraTitle(this.hass, cameraConfig), diff --git a/src/components/viewer.ts b/src/components/viewer.ts index 237e7560..e5862b97 100644 --- a/src/components/viewer.ts +++ b/src/components/viewer.ts @@ -77,7 +77,12 @@ export class FrigateCardViewer extends LitElement { ); if (!this.view.target) { - if (!browseMediaQueryParameters) { + // If the target is not specified, the view must tell us which mediaType + // to search for. When the target *is* specified, the view is not required + // to indicate the media type (e.g. the mixed 'events' view from the + // timeline). + const mediaType = this.view.getMediaType(); + if (!browseMediaQueryParameters || !mediaType) { return; } @@ -85,7 +90,10 @@ export class FrigateCardViewer extends LitElement { this, this.hass, this.view, - browseMediaQueryParameters, + BrowseMediaUtil.overrideMultiBrowseMediaQueryParameters( + browseMediaQueryParameters, + { mediaType: mediaType }, + ), ); return renderProgressIndicator(); } diff --git a/src/const.ts b/src/const.ts index aa3915b3..6e18ebfe 100644 --- a/src/const.ts +++ b/src/const.ts @@ -1,4 +1,6 @@ export const CARD_VERSION = '3.0.0' as const; + +export const CAMERA_BIRDSEYE = 'birdseye' as const; export const REPO_URL = 'https://github.com/dermotduffy/frigate-hass-card' as const; export const TROUBLESHOOTING_URL = `${REPO_URL}#troubleshooting` as const;