Initial version of substream support.
This commit is contained in:
+11
-11
@@ -1,16 +1,16 @@
|
||||
import {
|
||||
ActionConfig,
|
||||
handleActionConfig,
|
||||
hasAction,
|
||||
HomeAssistant
|
||||
ActionConfig,
|
||||
handleActionConfig,
|
||||
hasAction,
|
||||
HomeAssistant,
|
||||
} from 'custom-card-helpers';
|
||||
import {
|
||||
Actions,
|
||||
ActionsConfig,
|
||||
ActionType,
|
||||
FrigateCardAction,
|
||||
FrigateCardCustomAction,
|
||||
frigateCardCustomActionSchema
|
||||
Actions,
|
||||
ActionsConfig,
|
||||
ActionType,
|
||||
FrigateCardAction,
|
||||
FrigateCardCustomAction,
|
||||
frigateCardCustomActionSchema,
|
||||
} from '../types.js';
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ export function createFrigateCardCustomAction(
|
||||
media_player_action?: 'play' | 'stop';
|
||||
},
|
||||
): FrigateCardCustomAction | null {
|
||||
if (action === 'camera_select') {
|
||||
if (action === 'camera_select' || action === 'live_substream_select') {
|
||||
if (!args?.camera) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+10
-4
@@ -1,3 +1,4 @@
|
||||
import { CameraManager } from '../camera-manager/manager.js';
|
||||
import { CameraConfig, RawFrigateCardConfig } from '../types.js';
|
||||
|
||||
/**
|
||||
@@ -25,14 +26,19 @@ export function getCameraID(
|
||||
|
||||
/**
|
||||
* Get all cameras that depend on a given camera.
|
||||
* @param cameras Cameras map.
|
||||
* @param cameraManager The camera manager.
|
||||
* @param cameraID ID of the target camera.
|
||||
* @returns A set of query parameters.
|
||||
* @returns A set of dependent cameraIDs or null.
|
||||
*/
|
||||
export const getAllDependentCameras = (
|
||||
cameras: Map<string, CameraConfig>,
|
||||
cameraManager?: CameraManager,
|
||||
cameraID?: string,
|
||||
): Set<string> => {
|
||||
): Set<string> | null => {
|
||||
if (!cameraManager || !cameraID) {
|
||||
return null;
|
||||
}
|
||||
const cameras = cameraManager.getStore().getCameras();
|
||||
|
||||
const cameraIDs: Set<string> = new Set();
|
||||
const getDependentCameras = (cameraID: string): void => {
|
||||
const cameraConfig = cameras.get(cameraID);
|
||||
|
||||
@@ -53,7 +53,7 @@ export class EntityRegistryManager {
|
||||
public async getExtendedEntity(
|
||||
hass: HomeAssistant,
|
||||
entityID: string,
|
||||
): Promise<ExtendedEntity | null> {
|
||||
): Promise<ExtendedEntity> {
|
||||
const cachedValue = this._extendedCache.get(entityID);
|
||||
if (cachedValue) {
|
||||
return cachedValue;
|
||||
|
||||
@@ -27,11 +27,11 @@ export const changeViewToRecentEventsForCameraAndDependents = async (
|
||||
targetView?: FrigateCardView;
|
||||
},
|
||||
): Promise<void> => {
|
||||
const cameras = cameraManager.getCameras();
|
||||
if (!cameras) {
|
||||
const cameraIDs = getAllDependentCameras(cameraManager, view.camera);
|
||||
if (!cameraIDs) {
|
||||
return;
|
||||
}
|
||||
const cameraIDs = new Set(getAllDependentCameras(cameras, view.camera));
|
||||
|
||||
const queries = createQueriesForEventsView(cameraManager, cardWideConfig, cameraIDs, {
|
||||
mediaType: options?.mediaType,
|
||||
});
|
||||
@@ -83,18 +83,16 @@ export const changeViewToRecentRecordingForCameraAndDependents = async (
|
||||
targetView?: 'recording' | 'recordings';
|
||||
},
|
||||
): Promise<void> => {
|
||||
const cameras = cameraManager.getCameras();
|
||||
if (!cameras) {
|
||||
const cameraIDs = getAllDependentCameras(cameraManager, view.camera);
|
||||
if (!cameraIDs) {
|
||||
return;
|
||||
}
|
||||
|
||||
const cameraIDs = new Set(getAllDependentCameras(cameras, view.camera));
|
||||
const queries = createQueriesForRecordingsView(
|
||||
cameraManager,
|
||||
cardWideConfig,
|
||||
cameraIDs,
|
||||
);
|
||||
|
||||
if (!queries) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user