Change configuration path for Frigate options.
This commit is contained in:
@@ -639,7 +639,7 @@ export class FrigateCardLiveProvider extends LitElement {
|
||||
return 'webrtc-card';
|
||||
} else if (this.cameraConfig?.camera_entity) {
|
||||
return 'ha';
|
||||
} else if (this.cameraConfig?.camera_name) {
|
||||
} else if (this.cameraConfig?.frigate.camera_name) {
|
||||
return 'frigate-jsmpeg';
|
||||
}
|
||||
return frigateCardConfigDefaults.cameras.live_provider;
|
||||
@@ -1013,7 +1013,7 @@ export class FrigateCardLiveJSMPEG extends LitElement {
|
||||
* @returns A URL or null.
|
||||
*/
|
||||
protected async _getURL(): Promise<string | null> {
|
||||
if (!this.hass || !this.cameraConfig?.client_id || !this.cameraConfig?.camera_name) {
|
||||
if (!this.hass || !this.cameraConfig?.frigate.client_id || !this.cameraConfig?.frigate.camera_name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1021,8 +1021,8 @@ export class FrigateCardLiveJSMPEG extends LitElement {
|
||||
try {
|
||||
response = await homeAssistantSignPath(
|
||||
this.hass,
|
||||
`/api/frigate/${this.cameraConfig.client_id}` +
|
||||
`/jsmpeg/${this.cameraConfig.camera_name}`,
|
||||
`/api/frigate/${this.cameraConfig.frigate.client_id}` +
|
||||
`/jsmpeg/${this.cameraConfig.frigate.camera_name}`,
|
||||
URL_SIGN_EXPIRY_SECONDS,
|
||||
);
|
||||
} catch (err) {
|
||||
@@ -1131,7 +1131,7 @@ export class FrigateCardLiveJSMPEG extends LitElement {
|
||||
this._jsmpegCanvasElement = document.createElement('canvas');
|
||||
this._jsmpegCanvasElement.className = 'media';
|
||||
|
||||
if (!this.cameraConfig?.camera_name) {
|
||||
if (!this.cameraConfig?.frigate.camera_name) {
|
||||
return dispatchErrorMessageEvent(
|
||||
this,
|
||||
localize('error.no_camera_name'),
|
||||
|
||||
+2
-21
@@ -27,30 +27,11 @@ import {
|
||||
frigateCardHasAction,
|
||||
getActionConfigGivenAction
|
||||
} from '../utils/action.js';
|
||||
import { FRIGATE_ICON_SVG_PATH } from '../utils/frigate.js';
|
||||
import { refreshDynamicStateParameters } from '../utils/ha';
|
||||
import './submenu.js';
|
||||
|
||||
export const FRIGATE_BUTTON_MENU_ICON = 'frigate';
|
||||
export const FRIGATE_ICON_FILLED =
|
||||
'm 4.8759466,22.743573 c 0.0866,0.69274 0.811811,1.16359 0.37885,1.27183 ' +
|
||||
'-0.43297,0.10824 -2.32718,-3.43665 -2.7601492,-4.95202 -0.4329602,-1.51538 ' +
|
||||
'-0.6764993,-3.22017 -0.5682593,-4.19434 0.1082301,-0.97417 5.7097085,-2.48955 ' +
|
||||
'5.7097085,-2.89545 0,-0.4059 -1.81304,-0.0271 -1.89422,-0.35178 -0.0812,-0.32472 ' +
|
||||
'1.36925,-0.12989 1.75892,-0.64945 0.60885,-0.81181 1.3800713,-0.6765 1.8671505,' +
|
||||
'-1.1094696 0.4870902,-0.4329599 1.0824089,-2.0836399 1.1906589,-2.7871996 0.108241,' +
|
||||
'-0.70357 -1.0824084,-1.51538 -1.4071389,-2.05658 -0.3247195,-0.54121 0.7035702,' +
|
||||
'-0.92005 3.1931099,-1.94834 2.48954,-1.02829 10.39114,-3.30134994 10.49938,' +
|
||||
'-3.03074994 0.10824,0.27061 -2.59779,1.40713994 -4.492,2.11069994 -1.89422,0.70357 ' +
|
||||
'-4.97909,2.05658 -4.97909,2.43542 0,0.37885 0.16236,0.67651 0.0541,1.54244 -0.10824,' +
|
||||
'0.86593 -0.12123,1.2702597 -0.32472,1.8400997 -0.1353,0.37884 -0.2706,1.27183 ' +
|
||||
'0,2.0836295 0.21648,0.64945 0.92005,1.13653 1.24477,1.24478 0.2706,0.018 1.01746,' +
|
||||
'0.0433 1.8401,0 1.02829,-0.0541 2.48954,0.0541 2.48954,0.32472 0,0.2706 -2.21894,' +
|
||||
'0.10824 -2.21894,0.48708 0,0.37885 2.27306,-0.0541 2.21894,0.32473 -0.0541,0.37884 ' +
|
||||
'-1.89422,0.21648 -2.86839,0.21648 -0.77933,0 -1.93031,-0.0361 -2.43542,-0.21648 ' +
|
||||
'l -0.10824,0.37884 c -0.18038,0 -0.55744,0.10824 -0.94711,0.10824 -0.48708,0 ' +
|
||||
'-0.51414,0.16236 -1.40713,0.16236 -0.892989,0 -0.622391,-0.0541 -1.4341894,-0.10824 ' +
|
||||
'-0.81181,-0.0541 -3.842561,2.27306 -4.383761,3.03075 -0.54121,0.75768 ' +
|
||||
'-0.21649,2.59778 -0.21649,3.43665 0,0.75379 -0.10824,2.43542 0,3.30135 z';
|
||||
|
||||
/**
|
||||
* A menu for the FrigateCard.
|
||||
@@ -266,7 +247,7 @@ export class FrigateCardMenu extends LitElement {
|
||||
|
||||
let stateParameters: StateParameters = { ...button };
|
||||
const svgPath =
|
||||
stateParameters.icon === FRIGATE_BUTTON_MENU_ICON ? FRIGATE_ICON_FILLED : '';
|
||||
stateParameters.icon === FRIGATE_BUTTON_MENU_ICON ? FRIGATE_ICON_SVG_PATH : '';
|
||||
|
||||
if (this.hass && button.type === 'custom:frigate-card-menu-state-icon') {
|
||||
stateParameters = refreshDynamicStateParameters(this.hass, stateParameters);
|
||||
|
||||
+26
-15
@@ -324,12 +324,16 @@ class TimelineDataManager {
|
||||
camera: string,
|
||||
config: CameraConfig,
|
||||
): Promise<void> => {
|
||||
if (!config.camera_name) {
|
||||
if (!config.frigate.camera_name) {
|
||||
return;
|
||||
}
|
||||
let summary: RecordingSummary;
|
||||
try {
|
||||
summary = await getRecordingsSummary(hass, config.client_id, config.camera_name);
|
||||
summary = await getRecordingsSummary(
|
||||
hass,
|
||||
config.frigate.client_id,
|
||||
config.frigate.camera_name,
|
||||
);
|
||||
} catch (e) {
|
||||
return dispatchFrigateCardErrorEvent(element, e as FrigateCardError);
|
||||
}
|
||||
@@ -382,7 +386,7 @@ class TimelineDataManager {
|
||||
const params: BrowseMediaQueryParameters[] = [];
|
||||
cameras.forEach((cameraConfig, cameraID) => {
|
||||
(media === 'all' ? ['clips', 'snapshots'] : [media]).forEach((mediaType) => {
|
||||
if (cameraConfig.camera_name !== CAMERA_BIRDSEYE) {
|
||||
if (cameraConfig.frigate.camera_name !== CAMERA_BIRDSEYE) {
|
||||
const param = getBrowseMediaQueryParameters(hass, cameraID, cameraConfig, {
|
||||
before: end.getTime() / 1000,
|
||||
after: start.getTime() / 1000,
|
||||
@@ -584,10 +588,10 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
const processedCameras: Set<string> = new Set();
|
||||
|
||||
// Get results in the order the cameras are specified in the configuration.
|
||||
for (const camera of (this.cameras?.keys() || [])) {
|
||||
for (const camera of this.cameras?.keys() || []) {
|
||||
const recording = results.get(camera);
|
||||
const config = this.cameras?.get(camera);
|
||||
if (!recording || !config?.camera_name) {
|
||||
if (!recording || !config?.frigate.camera_name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -595,7 +599,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
// Zones on that same camera do not get separate recordings. The card may
|
||||
// have multiple instances of the same camera for different zoness, so
|
||||
// need to enforce uniqueness here.
|
||||
const uniqueID = `${config.client_id}/${config.camera_name}`;
|
||||
const uniqueID = `${config.frigate.client_id}/${config.frigate.camera_name}`;
|
||||
if (processedCameras.has(uniqueID)) {
|
||||
continue;
|
||||
}
|
||||
@@ -616,21 +620,21 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
if (!onlyMatchingHour || isMatchingHour) {
|
||||
children.push(
|
||||
createVideoChild(
|
||||
`${prettifyTitle(config.camera_name)} ${format(
|
||||
`${prettifyTitle(config.frigate.camera_name)} ${format(
|
||||
hour,
|
||||
'yyyy-MM-dd HH:mm',
|
||||
)}`,
|
||||
generateRecordingIdentifier({
|
||||
clientId: config.client_id,
|
||||
clientId: config.frigate.client_id,
|
||||
year: dayData.day.getFullYear(),
|
||||
month: dayData.day.getMonth() + 1,
|
||||
day: dayData.day.getDate(),
|
||||
hour: hourData.hour,
|
||||
cameraName: config.camera_name,
|
||||
cameraName: config.frigate.camera_name,
|
||||
}),
|
||||
{
|
||||
recording: {
|
||||
camera: config.camera_name,
|
||||
camera: config.frigate.camera_name,
|
||||
start_time: getUnixTime(startHour),
|
||||
end_time: getUnixTime(endHour),
|
||||
events: hourData.events,
|
||||
@@ -665,7 +669,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
const results: Map<string, CameraRecordings> = new Map();
|
||||
|
||||
const fetch = async (camera: string, config?: CameraConfig): Promise<void> => {
|
||||
if (!config || !config.camera_name || !this.hass) {
|
||||
if (!config || !config.frigate.camera_name || !this.hass) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -673,12 +677,16 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
const cameraResults = await Promise.all([
|
||||
getRecordingSegments(
|
||||
this.hass,
|
||||
config.client_id,
|
||||
config.camera_name,
|
||||
config.frigate.client_id,
|
||||
config.frigate.camera_name,
|
||||
before,
|
||||
after,
|
||||
),
|
||||
getRecordingsSummary(this.hass, config.client_id, config.camera_name),
|
||||
getRecordingsSummary(
|
||||
this.hass,
|
||||
config.frigate.client_id,
|
||||
config.frigate.camera_name,
|
||||
),
|
||||
]);
|
||||
results.set(camera, { segments: cameraResults[0], summary: cameraResults[1] });
|
||||
} catch (e) {}
|
||||
@@ -879,7 +887,10 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
protected _getGroups(): DataGroupCollectionType {
|
||||
const groups: FrigateCardGroupData[] = [];
|
||||
this.cameras?.forEach((cameraConfig, camera) => {
|
||||
if (cameraConfig.camera_name && cameraConfig.camera_name !== CAMERA_BIRDSEYE) {
|
||||
if (
|
||||
cameraConfig.frigate.camera_name &&
|
||||
cameraConfig.frigate.camera_name !== CAMERA_BIRDSEYE
|
||||
) {
|
||||
groups.push({
|
||||
id: camera,
|
||||
content: getCameraTitle(this.hass, cameraConfig),
|
||||
|
||||
Reference in New Issue
Block a user