feat: Rename the card to advanced-camera-card (#1873)
Whilst the Frigate support in this card is the best among camera engines, the name incorrectly suggests that Frigate is a requirement. Instead, to broaden the appeal, change to more camera agnostic name. This does not suggest any change in priority, role or support for Frigate. This change is likely to be bug prone, due to the size of the rename -- the code contains 1500+ references to "Frigate" most of which make sense to rename, some which do not, all of which needed human assessment. - Closes #1298 BREAKING CHANGE: References to `frigate-card` in all kinds of configuration need to be updated to `advanced-camera-card`. An automated config upgrade should take care of the majority of usecases (click `Edit -> Upgrade -> Save`), though may not be perfect.
This commit is contained in:
@@ -67,9 +67,9 @@ export class ActionsManager {
|
||||
if (
|
||||
config &&
|
||||
interaction &&
|
||||
// Don't call frigateCardHandleActionConfig() unless there is explicitly an
|
||||
// action defined (as it uses a default that is unhelpful for views that
|
||||
// have default tap/click actions).
|
||||
// Don't execute unless there is explicitly an action defined (as it uses
|
||||
// a default that is unhelpful for views that have default tap/click
|
||||
// actions).
|
||||
actionConfig
|
||||
) {
|
||||
this.executeActions(actionConfig, config);
|
||||
@@ -91,8 +91,8 @@ export class ActionsManager {
|
||||
};
|
||||
|
||||
/**
|
||||
* This method handles actions requested by components of the Frigate card
|
||||
* itself (e.g. menu, PTZ controller).
|
||||
* This method handles actions requested by components of the Advanced Camera
|
||||
* Card itself (e.g. menu, PTZ controller).
|
||||
*/
|
||||
public handleActionExecutionRequestEvent = async (
|
||||
ev: CustomEvent<ActionExecutionRequest>,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ActionContext } from 'action';
|
||||
import { FrigateCardCustomAction } from '../../../config/types';
|
||||
import { AdvancedCameraCardCustomAction } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { Action, AuxillaryActionConfig } from '../types';
|
||||
|
||||
@@ -24,6 +24,6 @@ export class BaseAction<T> implements Action {
|
||||
}
|
||||
}
|
||||
|
||||
export class FrigateCardAction<
|
||||
T extends FrigateCardCustomAction,
|
||||
export class AdvancedCameraCardAction<
|
||||
T extends AdvancedCameraCardCustomAction,
|
||||
> extends BaseAction<T> {}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { CameraSelectActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class CameraSelectAction extends FrigateCardAction<CameraSelectActionConfig> {
|
||||
export class CameraSelectAction extends AdvancedCameraCardAction<CameraSelectActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
const selectCameraID =
|
||||
this._action.camera ??
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class CameraUIAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class CameraUIAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
api.getCameraURLManager().openURL();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class DefaultAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class DefaultAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getViewManager().setViewDefaultWithNewQuery();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { DisplayModeActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class DisplayModeSelectAction extends FrigateCardAction<DisplayModeActionConfig> {
|
||||
export class DisplayModeSelectAction extends AdvancedCameraCardAction<DisplayModeActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getViewManager().setViewByParametersWithNewQuery({
|
||||
params: {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class DownloadAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class DownloadAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getDownloadManager().downloadViewerMedia();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class ExpandAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class ExpandAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
api.getExpandManager().toggleExpanded();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class FullscreenAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class FullscreenAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
api.getFullscreenManager().toggleFullscreen();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CardActionsAPI } from '../../types';
|
||||
import { BaseAction } from './base';
|
||||
|
||||
/**
|
||||
* Handles generic HA (non-Frigate) actions (e.g. 'more-info')
|
||||
* Handles generic HA actions (e.g. 'more-info')
|
||||
*/
|
||||
export class GenericAction extends BaseAction<ActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { LogActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class LogAction extends FrigateCardAction<LogActionConfig> {
|
||||
export class LogAction extends AdvancedCameraCardAction<LogActionConfig> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public async execute(_api: CardActionsAPI): Promise<void> {
|
||||
console[this._action.level](this._action.message);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { MediaPlayerActionConfig } from '../../../config/types';
|
||||
import { getStreamCameraID } from '../../../utils/substream';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class MediaPlayerAction extends FrigateCardAction<MediaPlayerActionConfig> {
|
||||
export class MediaPlayerAction extends AdvancedCameraCardAction<MediaPlayerActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
const mediaPlayer = this._action.media_player;
|
||||
const mediaPlayerController = api.getMediaPlayerManager();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class MenuToggleAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class MenuToggleAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
api.getCardElementManager().toggleMenu();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class MicrophoneConnectAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class MicrophoneConnectAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getMicrophoneManager().connect();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class MicrophoneDisconnectAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class MicrophoneDisconnectAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
api.getMicrophoneManager().disconnect();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class MicrophoneMuteAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class MicrophoneMuteAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
api.getMicrophoneManager().mute();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class MicrophoneUnmuteAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class MicrophoneUnmuteAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getMicrophoneManager().unmute();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class MuteAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class MuteAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getMediaLoadedInfoManager().get()?.player?.mute();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class PauseAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class PauseAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getMediaLoadedInfoManager().get()?.player?.pause();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class PlayAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class PlayAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getMediaLoadedInfoManager().get()?.player?.play();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { PTZControlsActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class PTZControlsAction extends FrigateCardAction<PTZControlsActionConfig> {
|
||||
export class PTZControlsAction extends AdvancedCameraCardAction<PTZControlsActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
api.getViewManager().setViewWithMergedContext({
|
||||
ptzControls: { enabled: this._action.enabled },
|
||||
|
||||
@@ -10,12 +10,12 @@ import { PTZDigitialActionConfig, ZOOM_MAX, ZOOM_MIN } from '../../../config/typ
|
||||
import { getPTZTarget } from '../../../utils/ptz';
|
||||
import { Timer } from '../../../utils/timer';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { TargetedActionContext } from '../types';
|
||||
import {
|
||||
setInProgressForThisTarget,
|
||||
stopInProgressForThisTarget,
|
||||
} from '../utils/action-state';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
const STEP_DELAY_SECONDS = 0.1;
|
||||
const STEP_ZOOM = 0.1;
|
||||
@@ -27,7 +27,7 @@ declare module 'action' {
|
||||
}
|
||||
}
|
||||
|
||||
export class PTZDigitalAction extends FrigateCardAction<PTZDigitialActionConfig> {
|
||||
export class PTZDigitalAction extends AdvancedCameraCardAction<PTZDigitialActionConfig> {
|
||||
protected _timer = new Timer();
|
||||
|
||||
protected async _stepChange(api: CardActionsAPI, targetID: string): Promise<void> {
|
||||
|
||||
@@ -2,11 +2,11 @@ import { PTZMultiActionConfig } from '../../../config/types';
|
||||
import { createPTZAction, createPTZDigitalAction } from '../../../utils/action';
|
||||
import { PTZType, getPTZTarget, hasCameraTruePTZ } from '../../../utils/ptz';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
import { PTZAction } from './ptz';
|
||||
import { PTZDigitalAction } from './ptz-digital';
|
||||
|
||||
export class PTZMultiAction extends FrigateCardAction<PTZMultiActionConfig> {
|
||||
export class PTZMultiAction extends AdvancedCameraCardAction<PTZMultiActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
const view = api.getViewManager().getView();
|
||||
let targetID: string | null = null;
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
setInProgressForThisTarget,
|
||||
stopInProgressForThisTarget,
|
||||
} from '../utils/action-state';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
interface PTZContext {
|
||||
[cameraID: string]: {
|
||||
@@ -20,7 +20,7 @@ declare module 'action' {
|
||||
}
|
||||
}
|
||||
|
||||
export class PTZAction extends FrigateCardAction<PTZActionConfig> {
|
||||
export class PTZAction extends AdvancedCameraCardAction<PTZActionConfig> {
|
||||
protected _timer = new Timer();
|
||||
|
||||
public async stop(): Promise<void> {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class ScreenshotAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class ScreenshotAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getDownloadManager().downloadScreenshot();
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ import { SleepActionConfig } from '../../../config/types';
|
||||
import { sleep } from '../../../utils/basic';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { timeDeltaToSeconds } from '../utils/time-delta';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class SleepAction extends FrigateCardAction<SleepActionConfig> {
|
||||
export class SleepAction extends AdvancedCameraCardAction<SleepActionConfig> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public async execute(_api: CardActionsAPI): Promise<void> {
|
||||
await sleep(timeDeltaToSeconds(this._action.duration));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { StatusBarActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class StatusBarAction extends FrigateCardAction<StatusBarActionConfig> {
|
||||
export class StatusBarAction extends AdvancedCameraCardAction<StatusBarActionConfig> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
switch (this._action.status_bar_action) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { SubstreamOffViewModifier } from '../../view/modifiers/substream-off';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class SubstreamOffAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class SubstreamOffAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
api.getViewManager().setViewByParameters({
|
||||
modifiers: [new SubstreamOffViewModifier()],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { SubstreamOnViewModifier } from '../../view/modifiers/substream-on';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class SubstreamOnAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class SubstreamOnAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
api.getViewManager().setViewByParameters({
|
||||
modifiers: [new SubstreamOnViewModifier(api)],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { SubstreamSelectActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { SubstreamSelectViewModifier } from '../../view/modifiers/substream-select';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class SubstreamSelectAction extends FrigateCardAction<SubstreamSelectActionConfig> {
|
||||
export class SubstreamSelectAction extends AdvancedCameraCardAction<SubstreamSelectActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
api.getViewManager().setViewByParameters({
|
||||
modifiers: [new SubstreamSelectViewModifier(this._action.camera)],
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GeneralActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class UnmuteAction extends FrigateCardAction<GeneralActionConfig> {
|
||||
export class UnmuteAction extends AdvancedCameraCardAction<GeneralActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getMediaLoadedInfoManager().get()?.player?.unmute();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { ViewActionConfig } from '../../../config/types';
|
||||
import { CardActionsAPI } from '../../types';
|
||||
import { FrigateCardAction } from './base';
|
||||
import { AdvancedCameraCardAction } from './base';
|
||||
|
||||
export class ViewAction extends FrigateCardAction<ViewActionConfig> {
|
||||
export class ViewAction extends AdvancedCameraCardAction<ViewActionConfig> {
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await api.getViewManager().setViewByParametersWithNewQuery({
|
||||
params: {
|
||||
view: this._action.frigate_card_action,
|
||||
view: this._action.advanced_camera_card_action,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ export class ActionFactory {
|
||||
cardID?: string;
|
||||
},
|
||||
): Action | null {
|
||||
const frigateCardAction = convertActionToCardCustomAction(action);
|
||||
if (action.action !== 'fire-dom-event' || !frigateCardAction) {
|
||||
const cardCustomAction = convertActionToCardCustomAction(action);
|
||||
if (action.action !== 'fire-dom-event' || !cardCustomAction) {
|
||||
// * There is a slight typing (but not functional) difference between
|
||||
// ActionType in this card and ActionConfig in `custom-card-helpers`. See
|
||||
// `ExtendedConfirmationRestrictionConfig` in `types.ts` for the source and
|
||||
@@ -54,15 +54,15 @@ export class ActionFactory {
|
||||
|
||||
if (
|
||||
// Command not intended for this card (e.g. query string command).
|
||||
frigateCardAction.card_id &&
|
||||
frigateCardAction.card_id !== options?.cardID
|
||||
cardCustomAction.card_id &&
|
||||
cardCustomAction.card_id !== options?.cardID
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (frigateCardAction.frigate_card_action) {
|
||||
switch (cardCustomAction.advanced_camera_card_action) {
|
||||
case 'default':
|
||||
return new DefaultAction(context, frigateCardAction, options?.config);
|
||||
return new DefaultAction(context, cardCustomAction, options?.config);
|
||||
case 'clip':
|
||||
case 'clips':
|
||||
case 'image':
|
||||
@@ -73,70 +73,70 @@ export class ActionFactory {
|
||||
case 'snapshots':
|
||||
case 'timeline':
|
||||
case 'diagnostics':
|
||||
return new ViewAction(context, frigateCardAction, options?.config);
|
||||
return new ViewAction(context, cardCustomAction, options?.config);
|
||||
case 'sleep':
|
||||
return new SleepAction(context, frigateCardAction, options?.config);
|
||||
return new SleepAction(context, cardCustomAction, options?.config);
|
||||
case 'download':
|
||||
return new DownloadAction(context, frigateCardAction, options?.config);
|
||||
return new DownloadAction(context, cardCustomAction, options?.config);
|
||||
case 'camera_ui':
|
||||
return new CameraUIAction(context, frigateCardAction, options?.config);
|
||||
return new CameraUIAction(context, cardCustomAction, options?.config);
|
||||
case 'expand':
|
||||
return new ExpandAction(context, frigateCardAction, options?.config);
|
||||
return new ExpandAction(context, cardCustomAction, options?.config);
|
||||
case 'fullscreen':
|
||||
return new FullscreenAction(context, frigateCardAction, options?.config);
|
||||
return new FullscreenAction(context, cardCustomAction, options?.config);
|
||||
case 'menu_toggle':
|
||||
return new MenuToggleAction(context, frigateCardAction, options?.config);
|
||||
return new MenuToggleAction(context, cardCustomAction, options?.config);
|
||||
case 'camera_select':
|
||||
return new CameraSelectAction(context, frigateCardAction, options?.config);
|
||||
return new CameraSelectAction(context, cardCustomAction, options?.config);
|
||||
case 'live_substream_select':
|
||||
return new SubstreamSelectAction(context, frigateCardAction, options?.config);
|
||||
return new SubstreamSelectAction(context, cardCustomAction, options?.config);
|
||||
case 'live_substream_off':
|
||||
return new SubstreamOffAction(context, frigateCardAction, options?.config);
|
||||
return new SubstreamOffAction(context, cardCustomAction, options?.config);
|
||||
case 'live_substream_on':
|
||||
return new SubstreamOnAction(context, frigateCardAction, options?.config);
|
||||
return new SubstreamOnAction(context, cardCustomAction, options?.config);
|
||||
case 'media_player':
|
||||
return new MediaPlayerAction(context, frigateCardAction, options?.config);
|
||||
return new MediaPlayerAction(context, cardCustomAction, options?.config);
|
||||
case 'microphone_connect':
|
||||
return new MicrophoneConnectAction(context, frigateCardAction, options?.config);
|
||||
return new MicrophoneConnectAction(context, cardCustomAction, options?.config);
|
||||
case 'microphone_disconnect':
|
||||
return new MicrophoneDisconnectAction(
|
||||
context,
|
||||
frigateCardAction,
|
||||
cardCustomAction,
|
||||
options?.config,
|
||||
);
|
||||
case 'microphone_mute':
|
||||
return new MicrophoneMuteAction(context, frigateCardAction, options?.config);
|
||||
return new MicrophoneMuteAction(context, cardCustomAction, options?.config);
|
||||
case 'microphone_unmute':
|
||||
return new MicrophoneUnmuteAction(context, frigateCardAction, options?.config);
|
||||
return new MicrophoneUnmuteAction(context, cardCustomAction, options?.config);
|
||||
case 'mute':
|
||||
return new MuteAction(context, frigateCardAction, options?.config);
|
||||
return new MuteAction(context, cardCustomAction, options?.config);
|
||||
case 'unmute':
|
||||
return new UnmuteAction(context, frigateCardAction, options?.config);
|
||||
return new UnmuteAction(context, cardCustomAction, options?.config);
|
||||
case 'play':
|
||||
return new PlayAction(context, frigateCardAction, options?.config);
|
||||
return new PlayAction(context, cardCustomAction, options?.config);
|
||||
case 'pause':
|
||||
return new PauseAction(context, frigateCardAction, options?.config);
|
||||
return new PauseAction(context, cardCustomAction, options?.config);
|
||||
case 'screenshot':
|
||||
return new ScreenshotAction(context, frigateCardAction, options?.config);
|
||||
return new ScreenshotAction(context, cardCustomAction, options?.config);
|
||||
case 'display_mode_select':
|
||||
return new DisplayModeSelectAction(context, frigateCardAction, options?.config);
|
||||
return new DisplayModeSelectAction(context, cardCustomAction, options?.config);
|
||||
case 'ptz':
|
||||
return new PTZAction(context, frigateCardAction, options?.config);
|
||||
return new PTZAction(context, cardCustomAction, options?.config);
|
||||
case 'ptz_digital':
|
||||
return new PTZDigitalAction(context, frigateCardAction, options?.config);
|
||||
return new PTZDigitalAction(context, cardCustomAction, options?.config);
|
||||
case 'ptz_multi':
|
||||
return new PTZMultiAction(context, frigateCardAction, options?.config);
|
||||
return new PTZMultiAction(context, cardCustomAction, options?.config);
|
||||
case 'ptz_controls':
|
||||
return new PTZControlsAction(context, frigateCardAction, options?.config);
|
||||
return new PTZControlsAction(context, cardCustomAction, options?.config);
|
||||
case 'log':
|
||||
return new LogAction(context, frigateCardAction, options?.config);
|
||||
return new LogAction(context, cardCustomAction, options?.config);
|
||||
case 'status_bar':
|
||||
return new StatusBarAction(context, frigateCardAction, options?.config);
|
||||
return new StatusBarAction(context, cardCustomAction, options?.config);
|
||||
}
|
||||
|
||||
/* istanbul ignore next: this path cannot be reached -- @preserve */
|
||||
console.warn(
|
||||
`Frigate card received unknown card action: ${frigateCardAction['frigate_card_action']}`,
|
||||
`Advanced Camera Card received unknown card action: ${cardCustomAction['advanced_camera_card_action']}`,
|
||||
);
|
||||
/* istanbul ignore next: this path cannot be reached -- @preserve */
|
||||
return null;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { dispatchFrigateCardEvent } from '../../../utils/basic';
|
||||
import { dispatchAdvancedCameraCardEvent } from '../../../utils/basic';
|
||||
import { ActionExecutionRequest } from '../types';
|
||||
|
||||
export const dispatchActionExecutionRequest = (
|
||||
element: HTMLElement,
|
||||
request: ActionExecutionRequest,
|
||||
) => {
|
||||
dispatchFrigateCardEvent(element, 'action:execution-request', request);
|
||||
dispatchAdvancedCameraCardEvent(element, 'action:execution-request', request);
|
||||
};
|
||||
|
||||
export interface ActionExecutionRequestEventTarget extends EventTarget {
|
||||
addEventListener(
|
||||
event: 'frigate-card:action:execution-request',
|
||||
event: 'advanced-camera-card:action:execution-request',
|
||||
listener: (
|
||||
this: ActionExecutionRequestEventTarget,
|
||||
ev: CustomEvent<ActionExecutionRequest>,
|
||||
@@ -23,7 +23,7 @@ export interface ActionExecutionRequestEventTarget extends EventTarget {
|
||||
options?: AddEventListenerOptions | boolean,
|
||||
): void;
|
||||
removeEventListener(
|
||||
event: 'frigate-card:action:execution-request',
|
||||
event: 'advanced-camera-card:action:execution-request',
|
||||
listener: (
|
||||
this: ActionExecutionRequestEventTarget,
|
||||
ev: CustomEvent<ActionExecutionRequest>,
|
||||
|
||||
@@ -31,7 +31,7 @@ export class AutomationsManager {
|
||||
!this._api.getHASSManager().hasHASS() ||
|
||||
// Never execute automations if the card hasn't finished initializing, as
|
||||
// it could cause a view change when camera loads are not finished.
|
||||
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1407
|
||||
// See: https://github.com/dermotduffy/advanced-camera-card/issues/1407
|
||||
!this._api.getInitializationManager().isInitializedMandatory() ||
|
||||
// Never execute automations if there's an error (as our automation loop
|
||||
// avoidance -- which shows as an error -- would not work!).
|
||||
|
||||
@@ -78,7 +78,7 @@ export class CardElementManager {
|
||||
...(this._api.getConfigManager().getConfig()?.view.render_entities ?? []),
|
||||
|
||||
// Refresh the card if media player state changes:
|
||||
// https://github.com/dermotduffy/frigate-hass-card/issues/881
|
||||
// https://github.com/dermotduffy/advanced-camera-card/issues/881
|
||||
...(this._api.getMediaPlayerManager().getMediaPlayers() ?? []),
|
||||
]);
|
||||
|
||||
@@ -109,7 +109,7 @@ export class CardElementManager {
|
||||
this._api.getInteractionManager().reportInteraction,
|
||||
);
|
||||
this._element.addEventListener(
|
||||
'frigate-card:action:execution-request',
|
||||
'advanced-camera-card:action:execution-request',
|
||||
this._api.getActionsManager().handleActionExecutionRequestEvent,
|
||||
);
|
||||
|
||||
@@ -179,7 +179,7 @@ export class CardElementManager {
|
||||
this._api.getInteractionManager().reportInteraction,
|
||||
);
|
||||
this._element.removeEventListener(
|
||||
'frigate-card:action:execution-request',
|
||||
'advanced-camera-card:action:execution-request',
|
||||
this._api.getActionsManager().handleActionExecutionRequestEvent,
|
||||
);
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ import {
|
||||
setConfigValue,
|
||||
} from '../config/management';
|
||||
import {
|
||||
FrigateCardCondition,
|
||||
frigateConditionalSchema,
|
||||
AdvancedCameraCardCondition,
|
||||
advancedCameraCardConditionalSchema,
|
||||
Overrides,
|
||||
RawFrigateCardConfig,
|
||||
RawAdvancedCameraCardConfig,
|
||||
ViewDisplayMode,
|
||||
} from '../config/types';
|
||||
import { localize } from '../localize/localize';
|
||||
import { FrigateCardError, MediaLoadedInfo } from '../types';
|
||||
import { AdvancedCameraCardError, MediaLoadedInfo } from '../types';
|
||||
import { desparsifyArrays } from '../utils/basic';
|
||||
import { isCompanionApp } from '../utils/companion';
|
||||
import { CardConditionAPI, KeysState, MicrophoneState } from './types';
|
||||
@@ -38,25 +38,26 @@ export interface ConditionState {
|
||||
view?: string;
|
||||
}
|
||||
|
||||
class OverrideConfigurationError extends FrigateCardError {}
|
||||
class OverrideConfigurationError extends AdvancedCameraCardError {}
|
||||
|
||||
export class ConditionsEvaluateRequestEvent extends Event {
|
||||
public conditions: FrigateCardCondition[];
|
||||
public conditions: AdvancedCameraCardCondition[];
|
||||
public evaluation?: boolean;
|
||||
|
||||
constructor(conditions: FrigateCardCondition[], eventInitDict?: EventInit) {
|
||||
super('frigate-card:conditions:evaluate', eventInitDict);
|
||||
constructor(conditions: AdvancedCameraCardCondition[], eventInitDict?: EventInit) {
|
||||
super('advanced-camera-card:conditions:evaluate', eventInitDict);
|
||||
this.conditions = conditions;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate whether a frigateCardCondition is met using an event to evaluate.
|
||||
* Evaluate whether an AdvancedCameraCardCondition is met using an event to
|
||||
* evaluate.
|
||||
* @returns A boolean indicating whether the condition is met.
|
||||
*/
|
||||
export function evaluateConditionViaEvent(
|
||||
element: HTMLElement,
|
||||
conditions?: FrigateCardCondition[],
|
||||
conditions?: AdvancedCameraCardCondition[],
|
||||
): boolean {
|
||||
if (!conditions) {
|
||||
return true;
|
||||
@@ -69,7 +70,7 @@ export function evaluateConditionViaEvent(
|
||||
|
||||
/* Special note on what's going on here:
|
||||
*
|
||||
* Some parts of the card (e.g. <frigate-card-elements>) may have arbitrary
|
||||
* Some parts of the card (e.g. <advanced-camera-card-elements>) may have arbitrary
|
||||
* complexity and layers (that this card doesn't control) between that master
|
||||
* element and the element that needs to evaluate the condition. In these
|
||||
* cases there's no clean way to pass state from the rest of card down through
|
||||
@@ -83,7 +84,7 @@ export function evaluateConditionViaEvent(
|
||||
return evaluateEvent.evaluation ?? false;
|
||||
}
|
||||
|
||||
export function getOverriddenConfig<RT extends RawFrigateCardConfig>(
|
||||
export function getOverriddenConfig<RT extends RawAdvancedCameraCardConfig>(
|
||||
manager: Readonly<ConditionsManager>,
|
||||
config: Readonly<RT>,
|
||||
options?: {
|
||||
@@ -198,9 +199,9 @@ export class ConditionsManager {
|
||||
public setConditionsFromConfig(): void {
|
||||
this.removeConditions();
|
||||
|
||||
const getAllConditions = (): FrigateCardCondition[] => {
|
||||
const getAllConditions = (): AdvancedCameraCardCondition[] => {
|
||||
const config = this._api.getConfigManager().getConfig();
|
||||
const conditions: FrigateCardCondition[] = [];
|
||||
const conditions: AdvancedCameraCardCondition[] = [];
|
||||
config?.overrides?.forEach((override) => conditions.push(...override.conditions));
|
||||
config?.automations?.forEach((automation) =>
|
||||
conditions.push(...automation.conditions),
|
||||
@@ -210,7 +211,7 @@ export class ConditionsManager {
|
||||
// custom elements that this card may not known. Here we recursively parse
|
||||
// down the elements tree, parsing as we go to find valid conditions.
|
||||
const getElementsConditions = (data: unknown): void => {
|
||||
const parseResult = frigateConditionalSchema.safeParse(data);
|
||||
const parseResult = advancedCameraCardConditionalSchema.safeParse(data);
|
||||
if (parseResult.success) {
|
||||
conditions.push(...parseResult.data.conditions);
|
||||
parseResult.data.elements?.forEach(getElementsConditions);
|
||||
@@ -265,7 +266,7 @@ export class ConditionsManager {
|
||||
}
|
||||
|
||||
public evaluateConditions(
|
||||
conditions: Readonly<FrigateCardCondition>[],
|
||||
conditions: Readonly<AdvancedCameraCardCondition>[],
|
||||
stateOverrides?: Partial<ConditionState>,
|
||||
): boolean {
|
||||
return conditions.every((conditionObj) =>
|
||||
@@ -274,7 +275,7 @@ export class ConditionsManager {
|
||||
}
|
||||
|
||||
protected _evaluateCondition(
|
||||
conditionObj: Readonly<FrigateCardCondition>,
|
||||
conditionObj: Readonly<AdvancedCameraCardCondition>,
|
||||
stateOverrides?: Partial<ConditionState>,
|
||||
): boolean {
|
||||
const state = {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import isEqual from 'lodash-es/isEqual';
|
||||
import { isConfigUpgradeable } from '../../config/management.js';
|
||||
import { setProfiles } from '../../config/profiles/index.js';
|
||||
import {
|
||||
AdvancedCameraCardConfig,
|
||||
advancedCameraCardConfigSchema,
|
||||
CardWideConfig,
|
||||
FrigateCardConfig,
|
||||
frigateCardConfigSchema,
|
||||
RawFrigateCardConfig,
|
||||
RawAdvancedCameraCardConfig,
|
||||
} from '../../config/types.js';
|
||||
import { localize } from '../../localize/localize.js';
|
||||
import { setProfiles } from '../../config/profiles/index.js';
|
||||
import { getParseErrorPaths } from '../../utils/zod.js';
|
||||
import { getOverriddenConfig } from '../conditions-manager.js';
|
||||
import { InitializationAspect } from '../initialization-manager.js';
|
||||
@@ -22,9 +22,9 @@ export class ConfigManager {
|
||||
// get the correct configuration (which will return overrides as appropriate).
|
||||
// This variable must be called `_config` or `config` to be compatible with
|
||||
// card-mod.
|
||||
protected _config: FrigateCardConfig | null = null;
|
||||
protected _overriddenConfig: FrigateCardConfig | null = null;
|
||||
protected _rawConfig: RawFrigateCardConfig | null = null;
|
||||
protected _config: AdvancedCameraCardConfig | null = null;
|
||||
protected _overriddenConfig: AdvancedCameraCardConfig | null = null;
|
||||
protected _rawConfig: RawAdvancedCameraCardConfig | null = null;
|
||||
protected _cardWideConfig: CardWideConfig | null = null;
|
||||
|
||||
constructor(api: CardConfigAPI) {
|
||||
@@ -35,7 +35,7 @@ export class ConfigManager {
|
||||
return !!this.getConfig();
|
||||
}
|
||||
|
||||
public getConfig(): FrigateCardConfig | null {
|
||||
public getConfig(): AdvancedCameraCardConfig | null {
|
||||
return this._overriddenConfig ?? this._config;
|
||||
}
|
||||
|
||||
@@ -43,20 +43,20 @@ export class ConfigManager {
|
||||
return this._cardWideConfig;
|
||||
}
|
||||
|
||||
public getNonOverriddenConfig(): FrigateCardConfig | null {
|
||||
public getNonOverriddenConfig(): AdvancedCameraCardConfig | null {
|
||||
return this._config;
|
||||
}
|
||||
|
||||
public getRawConfig(): RawFrigateCardConfig | null {
|
||||
public getRawConfig(): RawAdvancedCameraCardConfig | null {
|
||||
return this._rawConfig;
|
||||
}
|
||||
|
||||
public setConfig(inputConfig?: RawFrigateCardConfig): void {
|
||||
public setConfig(inputConfig?: RawAdvancedCameraCardConfig): void {
|
||||
if (!inputConfig) {
|
||||
throw new Error(localize('error.invalid_configuration'));
|
||||
}
|
||||
|
||||
const parseResult = frigateCardConfigSchema.safeParse(inputConfig);
|
||||
const parseResult = advancedCameraCardConfigSchema.safeParse(inputConfig);
|
||||
if (!parseResult.success) {
|
||||
const configUpgradeable = isConfigUpgradeable(inputConfig);
|
||||
const hint = getParseErrorPaths(parseResult.error);
|
||||
@@ -113,11 +113,11 @@ export class ConfigManager {
|
||||
return;
|
||||
}
|
||||
|
||||
let overriddenConfig: FrigateCardConfig | null = null;
|
||||
let overriddenConfig: AdvancedCameraCardConfig | null = null;
|
||||
try {
|
||||
overriddenConfig = getOverriddenConfig(conditionsManager, this._config, {
|
||||
configOverrides: this._config.overrides,
|
||||
schema: frigateCardConfigSchema,
|
||||
schema: advancedCameraCardConfigSchema,
|
||||
});
|
||||
} catch (ev) {
|
||||
this._api.getMessageManager().setErrorIfHigherPriority(ev);
|
||||
@@ -162,7 +162,7 @@ export class ConfigManager {
|
||||
* card hard requires, use InitializationManager instead.
|
||||
*/
|
||||
protected async _initializeBackground(
|
||||
previousConfig: FrigateCardConfig | null,
|
||||
previousConfig: AdvancedCameraCardConfig | null,
|
||||
): Promise<void> {
|
||||
await this._api.getDefaultManager().initializeIfNecessary(previousConfig);
|
||||
await this._api.getMediaPlayerManager().initializeIfNecessary(previousConfig);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LovelaceCardEditor } from '@dermotduffy/custom-card-helpers';
|
||||
import { ReactiveController } from 'lit';
|
||||
import { CameraManager } from '../camera-manager/manager';
|
||||
import { FrigateCardConfig } from '../config/types';
|
||||
import { AdvancedCameraCardConfig } from '../config/types';
|
||||
import {
|
||||
createDeviceRegistryCache,
|
||||
DeviceRegistryManager,
|
||||
@@ -177,7 +177,7 @@ export class CardController
|
||||
|
||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||
await import('../editor.js');
|
||||
return document.createElement('frigate-card-editor');
|
||||
return document.createElement('advanced-camera-card-editor');
|
||||
}
|
||||
|
||||
public getConfigManager(): ConfigManager {
|
||||
@@ -255,7 +255,7 @@ export class CardController
|
||||
return this._statusBarItemManager;
|
||||
}
|
||||
|
||||
public static getStubConfig(entities: string[]): FrigateCardConfig {
|
||||
public static getStubConfig(entities: string[]): AdvancedCameraCardConfig {
|
||||
const cameraEntity = entities.find((element) => element.startsWith('camera.'));
|
||||
return {
|
||||
cameras: [
|
||||
@@ -266,7 +266,7 @@ export class CardController
|
||||
// Need to use 'as unknown' to convince Typescript that this really isn't a
|
||||
// mistake, despite the miniscule size of the configuration vs the full type
|
||||
// description.
|
||||
} as unknown as FrigateCardConfig;
|
||||
} as unknown as AdvancedCameraCardConfig;
|
||||
}
|
||||
|
||||
public getStyleManager(): StyleManager {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import isEqual from 'lodash-es/isEqual';
|
||||
import { FrigateCardConfig } from '../config/types';
|
||||
import { AdvancedCameraCardConfig } from '../config/types';
|
||||
import { createGeneralAction } from '../utils/action';
|
||||
import { isActionAllowedBasedOnInteractionState } from '../utils/interaction-mode';
|
||||
import { Timer } from '../utils/timer';
|
||||
@@ -17,7 +17,7 @@ export class DefaultManager {
|
||||
}
|
||||
|
||||
public async initializeIfNecessary(
|
||||
previousConfig: FrigateCardConfig | null,
|
||||
previousConfig: AdvancedCameraCardConfig | null,
|
||||
): Promise<void> {
|
||||
if (
|
||||
!isEqual(
|
||||
|
||||
@@ -9,7 +9,7 @@ const WEBKIT_PLAY_SECONDS = 0.5;
|
||||
/**
|
||||
* Fullscreen implementation for webkit based browsers that do not support the
|
||||
* standard Fullscreen API (expected to be exclusively iOS on an iPhone).
|
||||
* See: https://github.com/dermotduffy/frigate-hass-card/issues/1444
|
||||
* See: https://github.com/dermotduffy/advanced-camera-card/issues/1444
|
||||
*/
|
||||
export class WebkitFullScreenProvider
|
||||
extends FullscreenProviderBase
|
||||
|
||||
@@ -94,8 +94,8 @@ export class InitializationManager {
|
||||
!(await this._initializer.initializeMultipleIfNecessary({
|
||||
[InitializationAspect.CAMERAS]: async () => {
|
||||
// Recreate the camera manager to guarantee an immediate re-render.
|
||||
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1811
|
||||
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1769
|
||||
// See: https://github.com/dermotduffy/advanced-camera-card/issues/1811
|
||||
// See: https://github.com/dermotduffy/advanced-camera-card/issues/1769
|
||||
this._api.createCameraManager();
|
||||
return await this._api.getCameraManager().initializeCamerasFromConfig();
|
||||
},
|
||||
@@ -103,7 +103,7 @@ export class InitializationManager {
|
||||
// Connecting the microphone (if configured) is considered mandatory to
|
||||
// avoid issues with some cameras that only allow 2-way audio on the
|
||||
// first stream initialized.
|
||||
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1235
|
||||
// See: https://github.com/dermotduffy/advanced-camera-card/issues/1235
|
||||
...(this._api.getMicrophoneManager().shouldConnectOnInitialization() && {
|
||||
[InitializationAspect.MICROPHONE_CONNECT]: async () => {
|
||||
// Recreate the microphone manager to guarantee an immediate
|
||||
|
||||
@@ -23,7 +23,7 @@ export class MediaLoadedInfoManager {
|
||||
|
||||
log(
|
||||
this._api.getConfigManager().getCardWideConfig(),
|
||||
`Frigate Card media load: `,
|
||||
`Advanced Camera Card media load: `,
|
||||
mediaLoadedInfo,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CameraConfig, FrigateCardConfig } from '../config/types';
|
||||
import { AdvancedCameraCardConfig, CameraConfig } from '../config/types';
|
||||
import {
|
||||
MEDIA_PLAYER_SUPPORT_BROWSE_MEDIA,
|
||||
MEDIA_PLAYER_SUPPORT_STOP,
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
} from '../const';
|
||||
import { localize } from '../localize/localize';
|
||||
import { errorToConsole } from '../utils/basic';
|
||||
import { Entity } from '../utils/ha/registry/entity/types';
|
||||
import { supportsFeature } from '../utils/ha';
|
||||
import { Entity } from '../utils/ha/registry/entity/types';
|
||||
import { ViewMedia } from '../view/media';
|
||||
import { ViewMediaClassifier } from '../view/media-classifier';
|
||||
import { CardMediaPlayerAPI } from './types';
|
||||
@@ -30,7 +30,7 @@ export class MediaPlayerManager {
|
||||
}
|
||||
|
||||
public async initializeIfNecessary(
|
||||
previousConfig: FrigateCardConfig | null,
|
||||
previousConfig: AdvancedCameraCardConfig | null,
|
||||
): Promise<void> {
|
||||
if (
|
||||
previousConfig?.menu.buttons.media_player.enabled !==
|
||||
@@ -80,7 +80,7 @@ export class MediaPlayerManager {
|
||||
// available in the HA state, only in the registry).
|
||||
this._mediaPlayers = mediaPlayers.filter((entityID) => {
|
||||
// Specifically allow for media players that are not found in the entity registry:
|
||||
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1016
|
||||
// See: https://github.com/dermotduffy/advanced-camera-card/issues/1016
|
||||
const entity = mediaPlayerEntities?.get(entityID);
|
||||
return !entity || !entity.hidden_by;
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FrigateCardError, Message, MessageType } from '../types';
|
||||
import { AdvancedCameraCardError, Message, MessageType } from '../types';
|
||||
import { errorToConsole } from '../utils/basic';
|
||||
import { CardMessageAPI } from './types';
|
||||
|
||||
@@ -60,7 +60,7 @@ export class MessageManager {
|
||||
this.setMessageIfHigherPriority({
|
||||
message: prefix ? `${prefix}: ${error.message}` : String(error.message),
|
||||
type: 'error',
|
||||
...(error instanceof FrigateCardError && { context: error.context }),
|
||||
...(error instanceof AdvancedCameraCardError && { context: error.context }),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export class MicrophoneManager {
|
||||
public isSupported(): boolean {
|
||||
// Some browsers will have mediaDevices/getUserMedia as undefined if
|
||||
// accessed over http.
|
||||
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1543
|
||||
// See: https://github.com/dermotduffy/advanced-camera-card/issues/1543
|
||||
return !!navigator.mediaDevices?.getUserMedia;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FrigateCardCustomAction, ViewActionConfig } from '../config/types';
|
||||
import { AdvancedCameraCardCustomAction, ViewActionConfig } from '../config/types';
|
||||
import { createCameraAction, createGeneralAction } from '../utils/action.js';
|
||||
import { ViewParameters } from '../view/view';
|
||||
import { CardQueryStringAPI } from './types';
|
||||
@@ -9,7 +9,7 @@ interface QueryStringViewIntent {
|
||||
default?: boolean;
|
||||
substream?: string;
|
||||
};
|
||||
other?: FrigateCardCustomAction[];
|
||||
other?: AdvancedCameraCardCustomAction[];
|
||||
}
|
||||
|
||||
export class QueryStringManager {
|
||||
@@ -72,14 +72,14 @@ export class QueryStringManager {
|
||||
const result: QueryStringViewIntent = {};
|
||||
for (const action of this._getActions()) {
|
||||
if (this._isViewAction(action)) {
|
||||
(result.view ??= {}).view = action.frigate_card_action;
|
||||
(result.view ??= {}).view = action.advanced_camera_card_action;
|
||||
(result.view ??= {}).default = undefined;
|
||||
} else if (action.frigate_card_action === 'default') {
|
||||
} else if (action.advanced_camera_card_action === 'default') {
|
||||
(result.view ??= {}).default = true;
|
||||
(result.view ??= {}).view = undefined;
|
||||
} else if (action.frigate_card_action === 'camera_select') {
|
||||
} else if (action.advanced_camera_card_action === 'camera_select') {
|
||||
(result.view ??= {}).camera = action.camera;
|
||||
} else if (action.frigate_card_action === 'live_substream_select') {
|
||||
} else if (action.advanced_camera_card_action === 'live_substream_select') {
|
||||
(result.view ??= {}).substream = action.camera;
|
||||
} else {
|
||||
(result.other ??= []).push(action);
|
||||
@@ -88,11 +88,11 @@ export class QueryStringManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected _getActions(): FrigateCardCustomAction[] {
|
||||
protected _getActions(): AdvancedCameraCardCustomAction[] {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const actions: FrigateCardCustomAction[] = [];
|
||||
const actions: AdvancedCameraCardCustomAction[] = [];
|
||||
const actionRE = new RegExp(
|
||||
/^frigate-card-action([.:](?<cardID>\w+))?[.:](?<action>\w+)/,
|
||||
/^(advanced-camera-card|frigate-card)-action([.:](?<cardID>\w+))?[.:](?<action>\w+)/,
|
||||
);
|
||||
for (const [key, value] of params.entries()) {
|
||||
const match = key.match(actionRE);
|
||||
@@ -102,7 +102,7 @@ export class QueryStringManager {
|
||||
const cardID: string | undefined = match.groups['cardID'];
|
||||
const action = match.groups['action'];
|
||||
|
||||
let customAction: FrigateCardCustomAction | null = null;
|
||||
let customAction: AdvancedCameraCardCustomAction | null = null;
|
||||
switch (action) {
|
||||
case 'camera_select':
|
||||
case 'live_substream_select':
|
||||
@@ -133,7 +133,7 @@ export class QueryStringManager {
|
||||
break;
|
||||
default:
|
||||
console.warn(
|
||||
`Frigate card received unknown card action in query string: ${action}`,
|
||||
`Advanced Camera Card received unknown card action in query string: ${action}`,
|
||||
);
|
||||
}
|
||||
if (customAction) {
|
||||
@@ -144,9 +144,9 @@ export class QueryStringManager {
|
||||
}
|
||||
|
||||
protected _isViewAction = (
|
||||
action: FrigateCardCustomAction,
|
||||
action: AdvancedCameraCardCustomAction,
|
||||
): action is ViewActionConfig => {
|
||||
switch (action.frigate_card_action) {
|
||||
switch (action.advanced_camera_card_action) {
|
||||
case 'clip':
|
||||
case 'clips':
|
||||
case 'diagnostics':
|
||||
|
||||
@@ -62,7 +62,7 @@ export class StatusBarItemManager {
|
||||
...(title
|
||||
? [
|
||||
{
|
||||
type: 'custom:frigate-card-status-bar-string' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-string' as const,
|
||||
string: title,
|
||||
expand: true,
|
||||
sufficient: true,
|
||||
@@ -74,7 +74,7 @@ export class StatusBarItemManager {
|
||||
...(resolution
|
||||
? [
|
||||
{
|
||||
type: 'custom:frigate-card-status-bar-string' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-string' as const,
|
||||
string: resolution,
|
||||
...options?.statusConfig?.items.resolution,
|
||||
},
|
||||
@@ -84,7 +84,7 @@ export class StatusBarItemManager {
|
||||
...(technology && technology === 'webrtc'
|
||||
? [
|
||||
{
|
||||
type: 'custom:frigate-card-status-bar-icon' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-icon' as const,
|
||||
icon: 'mdi:webrtc',
|
||||
...options?.statusConfig?.items.technology,
|
||||
},
|
||||
@@ -92,7 +92,7 @@ export class StatusBarItemManager {
|
||||
: !!technology
|
||||
? [
|
||||
{
|
||||
type: 'custom:frigate-card-status-bar-string' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-string' as const,
|
||||
string: technology.toUpperCase(),
|
||||
...options?.statusConfig?.items.technology,
|
||||
},
|
||||
@@ -102,7 +102,7 @@ export class StatusBarItemManager {
|
||||
...(engineIcon
|
||||
? [
|
||||
{
|
||||
type: 'custom:frigate-card-status-bar-icon' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-icon' as const,
|
||||
icon: engineIcon,
|
||||
...options?.statusConfig?.items.engine,
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { StyleInfo } from 'lit/directives/style-map';
|
||||
import {
|
||||
FrigateCardConfig,
|
||||
frigateCardConfigDefaults,
|
||||
AdvancedCameraCardConfig,
|
||||
configDefaults,
|
||||
ThemeConfig,
|
||||
ThemeName,
|
||||
} from '../config/types';
|
||||
@@ -25,7 +25,7 @@ export class StyleManager {
|
||||
// as dimension configuration does not apply in fullscreen or expanded mode.
|
||||
const lastKnown = this._api.getMediaLoadedInfoManager().getLastKnown();
|
||||
card.style.setProperty(
|
||||
'--frigate-card-expand-aspect-ratio',
|
||||
'--advanced-camera-card-expand-aspect-ratio',
|
||||
view?.isAnyMediaView() && lastKnown
|
||||
? `${lastKnown.width} / ${lastKnown.height}`
|
||||
: 'unset',
|
||||
@@ -35,16 +35,16 @@ export class StyleManager {
|
||||
// space.
|
||||
const isGrid = view?.isGrid();
|
||||
card.style.setProperty(
|
||||
'--frigate-card-expand-width',
|
||||
'--advanced-camera-card-expand-width',
|
||||
!isGrid && view?.isAnyMediaView()
|
||||
? 'none'
|
||||
: 'var(--frigate-card-expand-max-width)',
|
||||
: 'var(--advanced-camera-card-expand-max-width)',
|
||||
);
|
||||
card.style.setProperty(
|
||||
'--frigate-card-expand-height',
|
||||
'--advanced-camera-card-expand-height',
|
||||
!isGrid && view?.isAnyMediaView()
|
||||
? 'none'
|
||||
: 'var(--frigate-card-expand-max-height)',
|
||||
: 'var(--advanced-camera-card-expand-max-height)',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ export class StyleManager {
|
||||
protected _getThemeNames(themeConfig: ThemeConfig): ThemeName[] | null {
|
||||
return themeConfig.themes.length
|
||||
? themeConfig.themes
|
||||
: frigateCardConfigDefaults.view.theme.themes;
|
||||
: configDefaults.view.theme.themes;
|
||||
}
|
||||
|
||||
protected _setDimmable(): void {
|
||||
@@ -92,7 +92,7 @@ export class StyleManager {
|
||||
const config = this._api.getConfigManager().getConfig();
|
||||
if (config) {
|
||||
const card = this._api.getCardElementManager().getElement();
|
||||
card.style.setProperty('--frigate-card-height', config.dimensions.height);
|
||||
card.style.setProperty('--advanced-camera-card-height', config.dimensions.height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ export class StyleManager {
|
||||
|
||||
const styles = performance?.style ?? {};
|
||||
for (const configKey of Object.keys(styles)) {
|
||||
const CSSKey = `--frigate-card-css-${configKey.replaceAll('_', '-')}`;
|
||||
const CSSKey = `--advanced-camera-card-css-${configKey.replaceAll('_', '-')}`;
|
||||
if (styles[configKey] === false) {
|
||||
element.style.setProperty(CSSKey, STYLE_DISABLE_MAP[configKey]);
|
||||
} else {
|
||||
@@ -116,7 +116,7 @@ export class StyleManager {
|
||||
}
|
||||
|
||||
protected _isAspectRatioEnforced(
|
||||
config: FrigateCardConfig,
|
||||
config: AdvancedCameraCardConfig,
|
||||
view?: View | null,
|
||||
): boolean {
|
||||
const aspectRatioMode = config.dimensions.aspect_ratio_mode;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
FRIGATE_CARD_VIEW_DEFAULT,
|
||||
FrigateCardConfig,
|
||||
FrigateCardView,
|
||||
VIEW_DEFAULT,
|
||||
AdvancedCameraCardConfig,
|
||||
AdvancedCameraCardView,
|
||||
ViewDisplayMode,
|
||||
} from '../../config/types';
|
||||
import { localize } from '../../localize/localize';
|
||||
@@ -26,7 +26,7 @@ export class ViewFactory {
|
||||
|
||||
// Neither options.baseView.camera nor options.baseView.view are respected
|
||||
// here, since this is the default view / camera.
|
||||
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1564
|
||||
// See: https://github.com/dermotduffy/advanced-camera-card/issues/1564
|
||||
|
||||
let cameraID: string | null = null;
|
||||
const viewName = options?.params?.view ?? config.view.default;
|
||||
@@ -101,11 +101,8 @@ export class ViewFactory {
|
||||
}
|
||||
|
||||
if (!this.isViewSupportedByCamera(cameraID, viewName)) {
|
||||
if (
|
||||
options?.failSafe &&
|
||||
this.isViewSupportedByCamera(cameraID, FRIGATE_CARD_VIEW_DEFAULT)
|
||||
) {
|
||||
viewName = FRIGATE_CARD_VIEW_DEFAULT;
|
||||
if (options?.failSafe && this.isViewSupportedByCamera(cameraID, VIEW_DEFAULT)) {
|
||||
viewName = VIEW_DEFAULT;
|
||||
} else {
|
||||
const capabilities = this._api
|
||||
.getCameraManager()
|
||||
@@ -124,7 +121,7 @@ export class ViewFactory {
|
||||
const configuredDisplayMode = this._getDefaultDisplayModeForView(viewName, config);
|
||||
const displayMode =
|
||||
// Prioritize the configured display mode (if present).
|
||||
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1812
|
||||
// See: https://github.com/dermotduffy/advanced-camera-card/issues/1812
|
||||
(viewName !== options?.baseView?.view ? configuredDisplayMode : null) ??
|
||||
options?.params?.displayMode ??
|
||||
options?.baseView?.displayMode ??
|
||||
@@ -147,13 +144,16 @@ export class ViewFactory {
|
||||
return view;
|
||||
}
|
||||
|
||||
public isViewSupportedByCamera(cameraID: string, view: FrigateCardView): boolean {
|
||||
public isViewSupportedByCamera(
|
||||
cameraID: string,
|
||||
view: AdvancedCameraCardView,
|
||||
): boolean {
|
||||
return !!getCameraIDsForViewName(this._api.getCameraManager(), view, cameraID).size;
|
||||
}
|
||||
|
||||
protected _getDefaultDisplayModeForView(
|
||||
viewName: FrigateCardView,
|
||||
config: FrigateCardConfig,
|
||||
viewName: AdvancedCameraCardView,
|
||||
config: AdvancedCameraCardConfig,
|
||||
): ViewDisplayMode | null {
|
||||
let mode: ViewDisplayMode | null = null;
|
||||
switch (viewName) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ViewContext } from 'view';
|
||||
import { FrigateCardView } from '../../config/types.js';
|
||||
import { FrigateCardError } from '../../types.js';
|
||||
import { AdvancedCameraCardView } from '../../config/types.js';
|
||||
import { AdvancedCameraCardError } from '../../types.js';
|
||||
import { MediaQueriesResults } from '../../view/media-queries-results.js';
|
||||
import { MediaQueries } from '../../view/media-queries.js';
|
||||
import { ViewMedia } from '../../view/media.js';
|
||||
@@ -72,9 +72,9 @@ export interface ViewManagerInterface {
|
||||
|
||||
setViewWithMergedContext(context: ViewContext | null): void;
|
||||
|
||||
isViewSupportedByCamera(cameraID: string, view: FrigateCardView): boolean;
|
||||
isViewSupportedByCamera(cameraID: string, view: AdvancedCameraCardView): boolean;
|
||||
hasMajorMediaChange(oldView?: View | null, newView?: View | null): boolean;
|
||||
}
|
||||
|
||||
export class ViewNoCameraError extends FrigateCardError {}
|
||||
export class ViewIncompatible extends FrigateCardError {}
|
||||
export class ViewNoCameraError extends AdvancedCameraCardError {}
|
||||
export class ViewIncompatible extends AdvancedCameraCardError {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ViewContext } from 'view';
|
||||
import { FrigateCardView } from '../../config/types';
|
||||
import { AdvancedCameraCardView } from '../../config/types';
|
||||
import { log } from '../../utils/debug';
|
||||
import { getStreamCameraID } from '../../utils/substream';
|
||||
import { MediaQueriesClassifier } from '../../view/media-queries-classifier';
|
||||
@@ -217,7 +217,7 @@ export class ViewManager implements ViewManagerInterface {
|
||||
// target media of the gallery (e.g. clips, snapshots or recordings) is
|
||||
// equal to the queries that are currently used in the viewer.
|
||||
//
|
||||
// See: https://github.com/dermotduffy/frigate-hass-card/issues/885
|
||||
// See: https://github.com/dermotduffy/advanced-camera-card/issues/885
|
||||
|
||||
const switchingFromViewerToGallery =
|
||||
this._view?.isViewerView() && newView?.isGalleryView();
|
||||
@@ -233,7 +233,10 @@ export class ViewManager implements ViewManagerInterface {
|
||||
}
|
||||
}
|
||||
|
||||
public isViewSupportedByCamera(cameraID: string, view: FrigateCardView): boolean {
|
||||
public isViewSupportedByCamera(
|
||||
cameraID: string,
|
||||
view: AdvancedCameraCardView,
|
||||
): boolean {
|
||||
return !!getCameraIDsForViewName(this._api.getCameraManager(), view, cameraID).size;
|
||||
}
|
||||
|
||||
@@ -266,7 +269,7 @@ export class ViewManager implements ViewManagerInterface {
|
||||
// If the query string contains a view related action, we don't set any view
|
||||
// here and allow that action to be triggered by the next call of to execute
|
||||
// query actions (called at least once per render cycle).
|
||||
// Related: https://github.com/dermotduffy/frigate-hass-card/issues/1200
|
||||
// Related: https://github.com/dermotduffy/advanced-camera-card/issues/1200
|
||||
if (!this._api.getQueryStringManager().hasViewRelatedActionsToRun()) {
|
||||
// This is not awaited to allow the initialization to complete before the
|
||||
// query is answered.
|
||||
@@ -280,7 +283,7 @@ export class ViewManager implements ViewManagerInterface {
|
||||
|
||||
log(
|
||||
this._api.getConfigManager().getCardWideConfig(),
|
||||
`Frigate Card view change: `,
|
||||
`Advanced Camera Card view change: `,
|
||||
view,
|
||||
);
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ export class ViewQueryExecutor {
|
||||
new MergeContextViewModifier({
|
||||
// Force the window to start at the most recent time, not
|
||||
// necessarily when the most recent event/recording was:
|
||||
// https://github.com/dermotduffy/frigate-hass-card/issues/1301
|
||||
// https://github.com/dermotduffy/advanced-camera-card/issues/1301
|
||||
timeline: {
|
||||
window: {
|
||||
start: sub(now, {
|
||||
|
||||
Reference in New Issue
Block a user