Always render a view even if default is unsupported.

This commit is contained in:
Dermot Duffy
2024-03-08 20:00:35 -08:00
parent e261c17f75
commit ecdd02c7ce
7 changed files with 98 additions and 7 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ export class FrigateCamera extends Camera {
hass: HomeAssistant,
cameraConfig: CameraConfig,
): Promise<PTZCapabilities | null> {
if (!cameraConfig.frigate.camera_name) {
if (!cameraConfig.frigate.camera_name || isBirdseye(cameraConfig)) {
return null;
}
+5
View File
@@ -24,6 +24,7 @@ export interface CameraManagerReadOnlyConfigStore {
getCameraIDs(): Set<string>;
getVisibleCameraIDs(): Set<string>;
getDefaultCameraID(): string | null;
getAllDependentCameras(cameraID: string): Set<string>;
}
@@ -61,6 +62,10 @@ export class CameraManagerStore implements CameraManagerReadOnlyConfigStore {
return this.getVisibleCameraIDs().size;
}
public getDefaultCameraID(): string | null {
return this._cameras.keys().next().value ?? null;
}
public getCameras(): Map<string, Camera> {
return this._cameras;
}
@@ -98,7 +98,7 @@ export class InitializationManager {
if (hasViewRelatedActions) {
this._api.getQueryStringManager().executeViewRelated();
} else {
this._api.getViewManager().setViewDefault();
this._api.getViewManager().setViewDefault({ failSafe: true });
}
}
+22 -4
View File
@@ -1,13 +1,23 @@
import { ViewContext } from 'view';
import { FrigateCardConfig, FrigateCardView, ViewDisplayMode } from '../config/types';
import { View } from '../view/view';
import {
FRIGATE_CARD_VIEW_DEFAULT,
FrigateCardConfig,
FrigateCardView,
ViewDisplayMode,
} from '../config/types';
import { log } from '../utils/debug';
import { executeMediaQueryForView } from '../utils/media-to-view';
import { View } from '../view/view';
import { CardViewAPI } from './types';
interface ViewManagerSetViewDefaultParameters {
cameraID?: string;
substream?: string;
// When failSafe is true, the view will be changed to an "always-works" view
// (e.g. `live`) if the proposed view is unsupported. By default the view will
// just not be changed.
failSafe?: boolean;
}
export interface ViewManagerSetViewParameters
@@ -75,8 +85,16 @@ export class ViewManager {
cameraID = cameras.keys().next().value;
}
}
const viewName = params?.viewName ?? this._view?.view ?? config.view.default;
if (cameraID && viewName && this.isViewSupportedByCamera(cameraID, viewName)) {
let viewName = params?.viewName ?? this._view?.view ?? config.view.default;
if (cameraID && viewName) {
if (!this.isViewSupportedByCamera(cameraID, viewName)) {
if (params.failSafe) {
viewName = FRIGATE_CARD_VIEW_DEFAULT;
} else {
return;
}
}
const displayMode =
this._view?.displayMode ??
this._getDefaultDisplayModeForView(viewName, config);