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:
Dermot Duffy
2025-02-06 19:32:32 -08:00
committed by GitHub
parent 43947b49dc
commit cc376a8be1
305 changed files with 4270 additions and 3686 deletions
+12 -6
View File
@@ -1,10 +1,10 @@
import { LitElement, ReactiveController } from 'lit';
import { MediaLoadedInfo } from '../../types.js';
import {
FrigateCardMediaLoadedEventTarget,
AdvancedCameraCardMediaLoadedEventTarget,
dispatchExistingMediaLoadedInfoAsEvent,
} from '../../utils/media-info.js';
import { FrigateCardMessageEventTarget } from '../message/dispatch.js';
import { AdvancedCameraCardMessageEventTarget } from '../message/dispatch.js';
interface LiveViewContext {
// A cameraID override (used for dependencies/substreams to force a different
@@ -24,8 +24,8 @@ interface LastMediaLoadedInfo {
}
type LiveControllerHost = LitElement &
FrigateCardMediaLoadedEventTarget &
FrigateCardMessageEventTarget;
AdvancedCameraCardMediaLoadedEventTarget &
AdvancedCameraCardMessageEventTarget;
export class LiveController implements ReactiveController {
protected _host: LiveControllerHost;
@@ -56,13 +56,19 @@ export class LiveController implements ReactiveController {
public hostConnected(): void {
this._intersectionObserver.observe(this._host);
this._host.addEventListener('frigate-card:media:loaded', this._handleMediaLoaded);
this._host.addEventListener(
'advanced-camera-card:media:loaded',
this._handleMediaLoaded,
);
}
public hostDisconnected(): void {
this._intersectionObserver.disconnect();
this._host.removeEventListener('frigate-card:media:loaded', this._handleMediaLoaded);
this._host.removeEventListener(
'advanced-camera-card:media:loaded',
this._handleMediaLoaded,
);
}
public isInBackground(): boolean {
@@ -1,5 +1,5 @@
import { dispatchFrigateCardEvent } from '../../../utils/basic';
import { dispatchAdvancedCameraCardEvent } from '../../../utils/basic';
export function dispatchLiveErrorEvent(element: EventTarget): void {
dispatchFrigateCardEvent(element, 'live:error');
dispatchAdvancedCameraCardEvent(element, 'live:error');
}
@@ -5,8 +5,8 @@ import {
AutoPlayCondition,
AutoUnmuteCondition,
} from '../config/types.js';
import { FrigateCardMediaPlayer } from '../types.js';
import { FrigateCardMediaLoadedEventTarget } from '../utils/media-info.js';
import { AdvancedCameraCardMediaPlayer } from '../types.js';
import { AdvancedCameraCardMediaLoadedEventTarget } from '../utils/media-info.js';
import { Timer } from '../utils/timer.js';
export interface MediaActionsControllerOptions {
@@ -21,8 +21,8 @@ export interface MediaActionsControllerOptions {
microphoneMuteSeconds?: number;
}
type RenderRoot = HTMLElement & FrigateCardMediaLoadedEventTarget;
type PlayerElement = HTMLElement & FrigateCardMediaPlayer;
type RenderRoot = HTMLElement & AdvancedCameraCardMediaLoadedEventTarget;
type PlayerElement = HTMLElement & AdvancedCameraCardMediaPlayer;
/**
* General note: Always unmute before playing, since Chrome may pause a piece of
@@ -191,7 +191,7 @@ export class MediaActionsController {
protected _removeChildHandlers(): void {
for (const [child, callback] of this._eventListeners.entries()) {
child.removeEventListener('frigate-card:media:loaded', callback);
child.removeEventListener('advanced-camera-card:media:loaded', callback);
}
this._eventListeners.clear();
}
@@ -223,7 +223,7 @@ export class MediaActionsController {
for (const [index, child] of this._children.entries()) {
const eventListener = () => this._mediaLoadedHandler(index);
this._eventListeners.set(child, eventListener);
child.addEventListener('frigate-card:media:loaded', eventListener);
child.addEventListener('advanced-camera-card:media:loaded', eventListener);
}
}
protected async _intersectionHandler(
+9 -9
View File
@@ -4,12 +4,12 @@ import Masonry from 'masonry-layout';
import { ViewDisplayConfig } from '../config/types';
import { MediaLoadedInfo } from '../types';
import {
dispatchFrigateCardEvent,
dispatchAdvancedCameraCardEvent,
getChildrenFromElement,
setOrRemoveAttribute,
} from '../utils/basic';
import {
FrigateCardMediaLoadedEventTarget,
AdvancedCameraCardMediaLoadedEventTarget,
dispatchExistingMediaLoadedInfoAsEvent,
dispatchMediaUnloadedEvent,
} from '../utils/media-info';
@@ -24,7 +24,7 @@ const MEDIA_GRID_DEFAULT_SELECTED_WIDTH_FACTOR = 2.0;
const MEDIA_GRID_HORIZONTAL_GUTTER_WIDTH = 1;
type GridID = string;
type MediaGridChild = HTMLElement & FrigateCardMediaLoadedEventTarget;
type MediaGridChild = HTMLElement & AdvancedCameraCardMediaLoadedEventTarget;
type MediaGridContents = Map<GridID, MediaGridChild>;
export interface MediaGridSelected {
@@ -137,7 +137,7 @@ export class MediaGridController {
}
this._selected = id;
dispatchFrigateCardEvent(this._host, 'media-grid:selected', { selected: id });
dispatchAdvancedCameraCardEvent(this._host, 'media-grid:selected', { selected: id });
const mediaLoadedInfo = this._mediaLoadedInfoMap.get(id);
if (mediaLoadedInfo) {
@@ -155,7 +155,7 @@ export class MediaGridController {
public unselectAll() {
if (this._selected !== null) {
dispatchMediaUnloadedEvent(this._host);
dispatchFrigateCardEvent(this._host, 'media-grid:unselected');
dispatchAdvancedCameraCardEvent(this._host, 'media-grid:unselected');
}
this._selected = null;
this._updateSelectedStylesOnElements();
@@ -251,7 +251,7 @@ export class MediaGridController {
});
child.addEventListener(
'frigate-card:media:loaded',
'advanced-camera-card:media:loaded',
this._handleMediaLoadedInfoEvent,
);
}
@@ -262,7 +262,7 @@ export class MediaGridController {
});
child.removeEventListener(
'frigate-card:media:loaded',
'advanced-camera-card:media:loaded',
this._handleMediaLoadedInfoEvent,
);
}
@@ -345,12 +345,12 @@ export class MediaGridController {
protected _setColumnSizeStyles(): void {
this._host.style.setProperty(
'--frigate-card-grid-column-size',
'--advanced-camera-card-grid-column-size',
`${this._getColumnSize()}px`,
);
this._host.style.setProperty(
'--frigate-card-grid-selected-width-factor',
'--advanced-camera-card-grid-selected-width-factor',
`${
this._displayConfig?.grid_selected_width_factor ??
MEDIA_GRID_DEFAULT_SELECTED_WIDTH_FACTOR
+94 -91
View File
@@ -6,12 +6,11 @@ import { MediaPlayerManager } from '../card-controller/media-player-manager';
import { MicrophoneManager } from '../card-controller/microphone-manager';
import { ViewManager } from '../card-controller/view/view-manager';
import {
FRIGATE_CARD_VIEWS_USER_SPECIFIED,
FrigateCardConfig,
FrigateCardCustomAction,
AdvancedCameraCardConfig,
AdvancedCameraCardCustomAction,
MenuItem,
VIEWS_USER_SPECIFIED,
} from '../config/types';
import { FRIGATE_BUTTON_MENU_ICON } from '../const';
import { localize } from '../localize/localize.js';
import { MediaLoadedInfo } from '../types';
import {
@@ -63,12 +62,12 @@ export class MenuButtonController {
*/
public calculateButtons(
hass: HomeAssistant,
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
cameraManager: CameraManager,
options?: MenuButtonControllerOptions,
): MenuItem[] {
return [
this._getDefaultButton(config),
this._getIrisButton(config),
this._getCamerasButton(config, cameraManager, options?.view),
this._getSubstreamsButton(config, cameraManager, options?.view),
this._getLiveButton(config, options?.view, options?.viewManager),
@@ -107,27 +106,25 @@ export class MenuButtonController {
].filter(isTruthy);
}
protected _getDefaultButton(config: FrigateCardConfig): MenuItem {
protected _getIrisButton(config: AdvancedCameraCardConfig): MenuItem {
return {
// Use a magic icon value that the menu will use to render the custom
// Frigate icon.
icon: FRIGATE_BUTTON_MENU_ICON,
...config.menu.buttons.frigate,
type: 'custom:frigate-card-menu-icon',
title: localize('config.menu.buttons.frigate'),
icon: 'iris',
...config.menu.buttons.iris,
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.iris'),
// The default button always shows regardless of whether the menu is
// hidden or not.
permanent: true,
tap_action:
config.menu?.style === 'hidden'
? (createGeneralAction('menu_toggle') as FrigateCardCustomAction)
: (createGeneralAction('default') as FrigateCardCustomAction),
hold_action: createGeneralAction('diagnostics') as FrigateCardCustomAction,
? (createGeneralAction('menu_toggle') as AdvancedCameraCardCustomAction)
: (createGeneralAction('default') as AdvancedCameraCardCustomAction),
hold_action: createGeneralAction('diagnostics') as AdvancedCameraCardCustomAction,
};
}
protected _getCamerasButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
cameraManager: CameraManager,
view?: View | null,
): MenuItem | null {
@@ -153,7 +150,7 @@ export class MenuButtonController {
return {
icon: 'mdi:video-switch',
...config.menu.buttons.cameras,
type: 'custom:frigate-card-menu-submenu',
type: 'custom:advanced-camera-card-menu-submenu',
title: localize('config.menu.buttons.cameras'),
items: submenuItems,
};
@@ -162,7 +159,7 @@ export class MenuButtonController {
}
protected _getSubstreamsButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
cameraManager: CameraManager,
view?: View | null,
): MenuItem | null {
@@ -190,10 +187,10 @@ export class MenuButtonController {
substreamAwareCameraID !== view.camera ? this._getEmphasizedStyle() : {},
title: localize('config.menu.buttons.substreams'),
...config.menu.buttons.substreams,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
tap_action: createGeneralAction(
hasSubstream(view) ? 'live_substream_off' : 'live_substream_on',
) as FrigateCardCustomAction,
) as AdvancedCameraCardCustomAction,
};
} else if (streams.length > 2) {
const menuItems = Array.from(streams, (streamID) => {
@@ -216,7 +213,7 @@ export class MenuButtonController {
style:
substreamAwareCameraID !== view.camera ? this._getEmphasizedStyle() : {},
...config.menu.buttons.substreams,
type: 'custom:frigate-card-menu-submenu',
type: 'custom:advanced-camera-card-menu-submenu',
items: menuItems,
};
}
@@ -225,7 +222,7 @@ export class MenuButtonController {
}
protected _getLiveButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
view?: View | null,
viewManager?: ViewManager | null,
): MenuItem | null {
@@ -233,16 +230,16 @@ export class MenuButtonController {
? {
icon: 'mdi:cctv',
...config.menu.buttons.live,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.view.views.live'),
style: view.is('live') ? this._getEmphasizedStyle() : {},
tap_action: createGeneralAction('live') as FrigateCardCustomAction,
tap_action: createGeneralAction('live') as AdvancedCameraCardCustomAction,
}
: null;
}
protected _getClipsButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
view?: View | null,
viewManager?: ViewManager | null,
): MenuItem | null {
@@ -250,17 +247,17 @@ export class MenuButtonController {
? {
icon: 'mdi:filmstrip',
...config.menu.buttons.clips,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.view.views.clips'),
style: view?.is('clips') ? this._getEmphasizedStyle() : {},
tap_action: createGeneralAction('clips') as FrigateCardCustomAction,
hold_action: createGeneralAction('clip') as FrigateCardCustomAction,
tap_action: createGeneralAction('clips') as AdvancedCameraCardCustomAction,
hold_action: createGeneralAction('clip') as AdvancedCameraCardCustomAction,
}
: null;
}
protected _getSnapshotsButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
view?: View | null,
viewManager?: ViewManager | null,
): MenuItem | null {
@@ -268,17 +265,17 @@ export class MenuButtonController {
? {
icon: 'mdi:camera',
...config.menu.buttons.snapshots,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.view.views.snapshots'),
style: view?.is('snapshots') ? this._getEmphasizedStyle() : {},
tap_action: createGeneralAction('snapshots') as FrigateCardCustomAction,
hold_action: createGeneralAction('snapshot') as FrigateCardCustomAction,
tap_action: createGeneralAction('snapshots') as AdvancedCameraCardCustomAction,
hold_action: createGeneralAction('snapshot') as AdvancedCameraCardCustomAction,
}
: null;
}
protected _getRecordingsButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
view?: View | null,
viewManager?: ViewManager | null,
): MenuItem | null {
@@ -286,17 +283,21 @@ export class MenuButtonController {
? {
icon: 'mdi:album',
...config.menu.buttons.recordings,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.view.views.recordings'),
style: view.is('recordings') ? this._getEmphasizedStyle() : {},
tap_action: createGeneralAction('recordings') as FrigateCardCustomAction,
hold_action: createGeneralAction('recording') as FrigateCardCustomAction,
tap_action: createGeneralAction(
'recordings',
) as AdvancedCameraCardCustomAction,
hold_action: createGeneralAction(
'recording',
) as AdvancedCameraCardCustomAction,
}
: null;
}
protected _getImageButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
view?: View | null,
viewManager?: ViewManager | null,
): MenuItem | null {
@@ -304,16 +305,16 @@ export class MenuButtonController {
? {
icon: 'mdi:image',
...config.menu.buttons.image,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.view.views.image'),
style: view?.is('image') ? this._getEmphasizedStyle() : {},
tap_action: createGeneralAction('image') as FrigateCardCustomAction,
tap_action: createGeneralAction('image') as AdvancedCameraCardCustomAction,
}
: null;
}
protected _getTimelineButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
view?: View | null,
viewManager?: ViewManager | null,
): MenuItem | null {
@@ -321,16 +322,16 @@ export class MenuButtonController {
? {
icon: 'mdi:chart-gantt',
...config.menu.buttons.timeline,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.view.views.timeline'),
style: view.is('timeline') ? this._getEmphasizedStyle() : {},
tap_action: createGeneralAction('timeline') as FrigateCardCustomAction,
tap_action: createGeneralAction('timeline') as AdvancedCameraCardCustomAction,
}
: null;
}
protected _getDownloadButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
cameraManager: CameraManager,
view?: View | null,
): MenuItem | null {
@@ -342,31 +343,31 @@ export class MenuButtonController {
return {
icon: 'mdi:download',
...config.menu.buttons.download,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.download'),
tap_action: createGeneralAction('download') as FrigateCardCustomAction,
tap_action: createGeneralAction('download') as AdvancedCameraCardCustomAction,
};
}
return null;
}
protected _getCameraUIButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
showCameraUIButton?: boolean,
): MenuItem | null {
return showCameraUIButton
? {
icon: 'mdi:web',
...config.menu.buttons.camera_ui,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.camera_ui'),
tap_action: createGeneralAction('camera_ui') as FrigateCardCustomAction,
tap_action: createGeneralAction('camera_ui') as AdvancedCameraCardCustomAction,
}
: null;
}
protected _getMicrophoneButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
microphoneManager?: MicrophoneManager | null,
currentMediaLoadedInfo?: MediaLoadedInfo | null,
): MenuItem | null {
@@ -382,23 +383,23 @@ export class MenuButtonController {
? 'mdi:microphone-off'
: 'mdi:microphone',
...config.menu.buttons.microphone,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.microphone'),
style: unavailable || muted ? {} : this._getEmphasizedStyle(true),
...(!unavailable &&
buttonType === 'momentary' && {
start_tap_action: createGeneralAction(
'microphone_unmute',
) as FrigateCardCustomAction,
) as AdvancedCameraCardCustomAction,
end_tap_action: createGeneralAction(
'microphone_mute',
) as FrigateCardCustomAction,
) as AdvancedCameraCardCustomAction,
}),
...(!unavailable &&
buttonType === 'toggle' && {
tap_action: createGeneralAction(
muted ? 'microphone_unmute' : 'microphone_mute',
) as FrigateCardCustomAction,
) as AdvancedCameraCardCustomAction,
}),
};
}
@@ -406,21 +407,21 @@ export class MenuButtonController {
}
protected _getExpandButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
inExpandedMode?: boolean,
): MenuItem {
return {
icon: inExpandedMode ? 'mdi:arrow-collapse-all' : 'mdi:arrow-expand-all',
...config.menu.buttons.expand,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.expand'),
tap_action: createGeneralAction('expand') as FrigateCardCustomAction,
tap_action: createGeneralAction('expand') as AdvancedCameraCardCustomAction,
style: inExpandedMode ? this._getEmphasizedStyle() : {},
};
}
protected _getFullscreenButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
fullscreenManager?: FullscreenManager | null,
): MenuItem | null {
const inFullscreen = fullscreenManager?.isInFullscreen();
@@ -428,9 +429,11 @@ export class MenuButtonController {
? {
icon: inFullscreen ? 'mdi:fullscreen-exit' : 'mdi:fullscreen',
...config.menu.buttons.fullscreen,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.fullscreen'),
tap_action: createGeneralAction('fullscreen') as FrigateCardCustomAction,
tap_action: createGeneralAction(
'fullscreen',
) as AdvancedCameraCardCustomAction,
style: inFullscreen ? this._getEmphasizedStyle() : {},
}
: null;
@@ -438,7 +441,7 @@ export class MenuButtonController {
protected _getCastButton(
hass: HomeAssistant,
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
cameraManager: CameraManager,
view?: View | null,
mediaPlayerController?: MediaPlayerManager | null,
@@ -475,7 +478,7 @@ export class MenuButtonController {
return {
icon: 'mdi:cast',
...config.menu.buttons.media_player,
type: 'custom:frigate-card-menu-submenu',
type: 'custom:advanced-camera-card-menu-submenu',
title: localize('config.menu.buttons.media_player'),
items: mediaPlayerItems,
};
@@ -484,7 +487,7 @@ export class MenuButtonController {
}
protected _getPlayPauseButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
currentMediaLoadedInfo?: MediaLoadedInfo | null,
): MenuItem | null {
if (
@@ -496,18 +499,18 @@ export class MenuButtonController {
return {
icon: paused ? 'mdi:play' : 'mdi:pause',
...config.menu.buttons.play,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.play'),
tap_action: createGeneralAction(
paused ? 'play' : 'pause',
) as FrigateCardCustomAction,
) as AdvancedCameraCardCustomAction,
};
}
return null;
}
protected _getMuteUnmuteButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
currentMediaLoadedInfo?: MediaLoadedInfo | null,
): MenuItem | null {
if (
@@ -519,34 +522,34 @@ export class MenuButtonController {
return {
icon: muted ? 'mdi:volume-off' : 'mdi:volume-high',
...config.menu.buttons.mute,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.mute'),
tap_action: createGeneralAction(
muted ? 'unmute' : 'mute',
) as FrigateCardCustomAction,
) as AdvancedCameraCardCustomAction,
};
}
return null;
}
protected _getScreenshotButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
currentMediaLoadedInfo?: MediaLoadedInfo | null,
): MenuItem | null {
if (currentMediaLoadedInfo && currentMediaLoadedInfo.player) {
return {
icon: 'mdi:monitor-screenshot',
...config.menu.buttons.screenshot,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.screenshot'),
tap_action: createGeneralAction('screenshot') as FrigateCardCustomAction,
tap_action: createGeneralAction('screenshot') as AdvancedCameraCardCustomAction,
};
}
return null;
}
protected _getDisplayModeButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
cameraManager: CameraManager,
view?: View | null,
): MenuItem | null {
@@ -563,7 +566,7 @@ export class MenuButtonController {
icon: isGrid ? 'mdi:grid-off' : 'mdi:grid',
...config.menu.buttons.display_mode,
style: isGrid ? this._getEmphasizedStyle() : {},
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: isGrid
? localize('display_modes.single')
: localize('display_modes.grid'),
@@ -574,7 +577,7 @@ export class MenuButtonController {
}
protected _getPTZControlsButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
cameraManager: CameraManager,
view?: View | null,
): MenuItem | null {
@@ -602,7 +605,7 @@ export class MenuButtonController {
icon: 'mdi:pan',
...config.menu.buttons.ptz_controls,
style: isOn ? this._getEmphasizedStyle() : {},
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.ptz_controls'),
tap_action: createPTZControlsAction(!isOn),
};
@@ -611,7 +614,7 @@ export class MenuButtonController {
}
protected _getPTZHomeButton(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
cameraManager: CameraManager,
view?: View | null,
): MenuItem | null {
@@ -633,11 +636,11 @@ export class MenuButtonController {
return {
icon: 'mdi:home',
...config.menu.buttons.ptz_home,
type: 'custom:frigate-card-menu-icon',
type: 'custom:advanced-camera-card-menu-icon',
title: localize('config.menu.buttons.ptz_home'),
tap_action: createPTZMultiAction({
targetID: target.targetID,
}) as FrigateCardCustomAction,
}) as AdvancedCameraCardCustomAction,
};
}
@@ -649,11 +652,11 @@ export class MenuButtonController {
if (critical) {
return {
animation: 'pulse 3s infinite',
color: 'var(--frigate-card-menu-button-critical-color)',
color: 'var(--advanced-camera-card-menu-button-critical-color)',
};
}
return {
color: 'var(--frigate-card-menu-button-active-color)',
color: 'var(--advanced-camera-card-menu-button-active-color)',
};
}
@@ -664,7 +667,7 @@ export class MenuButtonController {
* @returns A StyleInfo object.
*/
protected _getStyleFromActions(
config: FrigateCardConfig,
config: AdvancedCameraCardConfig,
button: MenuItem,
options?: MenuButtonControllerOptions,
): StyleInfo {
@@ -677,28 +680,28 @@ export class MenuButtonController {
]) {
const actions = Array.isArray(actionSet) ? actionSet : [actionSet];
for (const action of actions) {
// All frigate card actions will have action of 'fire-dom-event' and
// All advanced camera card actions will have action of 'fire-dom-event' and
// styling only applies to those.
if (
!action ||
action.action !== 'fire-dom-event' ||
!('frigate_card_action' in action)
!('advanced_camera_card_action' in action)
) {
continue;
}
const frigateCardAction = action as FrigateCardCustomAction;
const customCardAction = action as AdvancedCameraCardCustomAction;
if (
FRIGATE_CARD_VIEWS_USER_SPECIFIED.some(
VIEWS_USER_SPECIFIED.some(
(viewName) =>
viewName === frigateCardAction.frigate_card_action &&
options?.view?.is(frigateCardAction.frigate_card_action),
viewName === customCardAction.advanced_camera_card_action &&
options?.view?.is(customCardAction.advanced_camera_card_action),
) ||
(frigateCardAction.frigate_card_action === 'default' &&
(customCardAction.advanced_camera_card_action === 'default' &&
options?.view?.is(config.view.default)) ||
(frigateCardAction.frigate_card_action === 'fullscreen' &&
(customCardAction.advanced_camera_card_action === 'fullscreen' &&
!!options?.fullscreenManager?.isInFullscreen()) ||
(frigateCardAction.frigate_card_action === 'camera_select' &&
options?.view?.camera === frigateCardAction.camera)
(customCardAction.advanced_camera_card_action === 'camera_select' &&
options?.view?.camera === customCardAction.camera)
) {
return this._getEmphasizedStyle();
}
+4 -5
View File
@@ -3,7 +3,7 @@ import { LitElement } from 'lit';
import { orderBy } from 'lodash-es';
import { dispatchActionExecutionRequest } from '../card-controller/actions/utils/execution-request.js';
import {
FRIGATE_MENU_PRIORITY_MAX,
MENU_PRIORITY_MAX,
type ActionType,
type ActionsConfig,
type MenuConfig,
@@ -28,7 +28,7 @@ export class MenuController {
public setMenuConfig(config: MenuConfig): void {
this._config = config;
this._host.style.setProperty(
'--frigate-card-menu-button-size',
'--advanced-camera-card-menu-button-size',
`${config.button_size}px`,
);
@@ -164,8 +164,7 @@ export class MenuController {
// If the menu is hidden, the buttons that toggle the menu must come
// first.
return (
priority +
(this._isHidingMenu() && button.permanent ? FRIGATE_MENU_PRIORITY_MAX : 0)
priority + (this._isHidingMenu() && button.permanent ? MENU_PRIORITY_MAX : 0)
);
},
['desc'],
@@ -178,6 +177,6 @@ export class MenuController {
protected _isUnknownActionMenuToggleAction(action: ActionType): boolean {
const parsedAction = convertActionToCardCustomAction(action);
return !!parsedAction && parsedAction.frigate_card_action == 'menu_toggle';
return !!parsedAction && parsedAction.advanced_camera_card_action == 'menu_toggle';
}
}
+16 -10
View File
@@ -1,11 +1,14 @@
import { FrigateCardError, Message } from '../../types';
import { dispatchFrigateCardEvent } from '../../utils/basic';
import { AdvancedCameraCardError, Message } from '../../types';
import { dispatchAdvancedCameraCardEvent } from '../../utils/basic';
// Facilitates correct typing of event handlers.
export interface FrigateCardMessageEventTarget extends EventTarget {
export interface AdvancedCameraCardMessageEventTarget extends EventTarget {
addEventListener(
event: 'frigate-card:message',
listener: (this: FrigateCardMessageEventTarget, ev: CustomEvent<Message>) => void,
event: 'advanced-camera-card:message',
listener: (
this: AdvancedCameraCardMessageEventTarget,
ev: CustomEvent<Message>,
) => void,
options?: AddEventListenerOptions | boolean,
): void;
addEventListener(
@@ -14,8 +17,11 @@ export interface FrigateCardMessageEventTarget extends EventTarget {
options?: AddEventListenerOptions | boolean,
): void;
removeEventListener(
event: 'frigate-card:message',
listener: (this: FrigateCardMessageEventTarget, ev: CustomEvent<Message>) => void,
event: 'advanced-camera-card:message',
listener: (
this: AdvancedCameraCardMessageEventTarget,
ev: CustomEvent<Message>,
) => void,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
@@ -33,15 +39,15 @@ export interface FrigateCardMessageEventTarget extends EventTarget {
* @param element The element to send the event.
* @param message The message to show.
*/
export const dispatchFrigateCardErrorEvent = (
export const dispatchAdvancedCameraCardErrorEvent = (
element: EventTarget,
error: unknown,
): void => {
if (error instanceof Error) {
dispatchFrigateCardEvent<Message>(element, 'message', {
dispatchAdvancedCameraCardEvent<Message>(element, 'message', {
message: error.message,
type: 'error',
...(error instanceof FrigateCardError && { context: error.context }),
...(error instanceof AdvancedCameraCardError && { context: error.context }),
});
}
};
+6 -6
View File
@@ -5,7 +5,7 @@ import orderBy from 'lodash-es/orderBy';
import { dispatchActionExecutionRequest } from '../card-controller/actions/utils/execution-request';
import {
ActionsConfig,
FRIGATE_STATUS_BAR_PRIORITY_DEFAULT,
STATUS_BAR_PRIORITY_DEFAULT,
StatusBarConfig,
StatusBarItem,
} from '../config/types';
@@ -33,7 +33,7 @@ export class StatusBarController {
const newItems = orderBy(
exclusiveItems.length ? exclusiveItems : items,
(item) => item.priority ?? FRIGATE_STATUS_BAR_PRIORITY_DEFAULT,
(item) => item.priority ?? STATUS_BAR_PRIORITY_DEFAULT,
'desc',
);
@@ -53,7 +53,7 @@ export class StatusBarController {
public setConfig(config: StatusBarConfig): void {
this._config = config;
this._host.style.setProperty(
'--frigate-card-status-bar-height',
'--advanced-camera-card-status-bar-height',
`${config.height}px`,
);
@@ -97,11 +97,11 @@ export class StatusBarController {
protected _getSufficientValue(item: StatusBarItem): string | null {
/* istanbul ignore else: cannot happen -- @preserve */
if (item.type === 'custom:frigate-card-status-bar-icon') {
if (item.type === 'custom:advanced-camera-card-status-bar-icon') {
return item.icon;
} else if (item.type === 'custom:frigate-card-status-bar-string') {
} else if (item.type === 'custom:advanced-camera-card-status-bar-string') {
return item.string;
} else if (item.type === 'custom:frigate-card-status-bar-image') {
} else if (item.type === 'custom:advanced-camera-card-status-bar-image') {
return item.image;
} else {
return null;
+13 -11
View File
@@ -24,7 +24,7 @@ const TIMELINE_FRESHNESS_TOLERANCE_SECONDS = 30;
// instead of clean recording blocks.
const TIMELINE_RECORDING_SEGMENT_CONSECUTIVE_TOLERANCE_SECONDS = 60;
export interface FrigateCardTimelineItem extends TimelineItem {
export interface AdvancedCameraCardTimelineItem extends TimelineItem {
// Use numbers to avoid significant volumes of Date object construction (for
// high-quantity recording segments).
start: number;
@@ -38,7 +38,7 @@ export interface FrigateCardTimelineItem extends TimelineItem {
export class TimelineDataSource {
protected _cameraManager: CameraManager;
protected _dataset: DataSet<FrigateCardTimelineItem> = new DataSet();
protected _dataset: DataSet<AdvancedCameraCardTimelineItem> = new DataSet();
// The ranges in which recordings have been calculated and added for.
// Calculating recordings is a very expensive process since it is based on
@@ -66,7 +66,7 @@ export class TimelineDataSource {
this._showRecordings = showRecordings;
}
get dataset(): DataSet<FrigateCardTimelineItem> {
get dataset(): DataSet<AdvancedCameraCardTimelineItem> {
return this._dataset;
}
@@ -135,7 +135,7 @@ export class TimelineDataSource {
}
const mediaArray = await this._cameraManager.executeMediaQueries(eventQueries);
const data: FrigateCardTimelineItem[] = [];
const data: AdvancedCameraCardTimelineItem[] = [];
for (const media of mediaArray ?? []) {
const startTime = media.getStartTime();
const id = media.getID();
@@ -160,15 +160,15 @@ export class TimelineDataSource {
}
protected async _refreshRecordings(window: TimelineWindow): Promise<void> {
type FrigateCardTimelineItemWithEnd = ModifyInterface<
FrigateCardTimelineItem,
type AdvancedCameraCardTimelineItemWithEnd = ModifyInterface<
AdvancedCameraCardTimelineItem,
{ end: number }
>;
const convertSegmentToRecording = (
cameraID: string,
segment: RecordingSegment,
): FrigateCardTimelineItemWithEnd => {
): AdvancedCameraCardTimelineItemWithEnd => {
return {
id: `recording-${cameraID}-${segment.id}`,
group: cameraID,
@@ -181,11 +181,11 @@ export class TimelineDataSource {
const getExistingRecordingsForCameraID = (
cameraID: string,
): FrigateCardTimelineItemWithEnd[] => {
): AdvancedCameraCardTimelineItemWithEnd[] => {
return this._dataset.get({
filter: (item) =>
item.type == 'background' && item.group === cameraID && item.end !== undefined,
}) as FrigateCardTimelineItemWithEnd[];
}) as AdvancedCameraCardTimelineItemWithEnd[];
};
const deleteRecordingsForCameraID = (cameraID: string): void => {
@@ -196,7 +196,9 @@ export class TimelineDataSource {
);
};
const addRecordings = (recordings: FrigateCardTimelineItemWithEnd[]): void => {
const addRecordings = (
recordings: AdvancedCameraCardTimelineItemWithEnd[],
): void => {
this._dataset.add(recordings);
};
@@ -247,7 +249,7 @@ export class TimelineDataSource {
const compressedRecordings = compressRanges(
mergedRecordings,
TIMELINE_RECORDING_SEGMENT_CONSECUTIVE_TOLERANCE_SECONDS,
) as FrigateCardTimelineItemWithEnd[];
) as AdvancedCameraCardTimelineItemWithEnd[];
deleteRecordingsForCameraID(cameraID);
addRecordings(compressedRecordings);
+9 -9
View File
@@ -1,9 +1,9 @@
import Panzoom, { PanzoomEventDetail, PanzoomObject } from '@dermotduffy/panzoom';
import throttle from 'lodash-es/throttle';
import round from 'lodash-es/round';
import throttle from 'lodash-es/throttle';
import {
arefloatsApproximatelyEqual,
dispatchFrigateCardEvent,
dispatchAdvancedCameraCardEvent,
isHoverableDevice,
} from '../../utils/basic';
import {
@@ -76,7 +76,7 @@ export class ZoomController {
// Even though the click is stopped,the card still needs to gain focus so
// that keyboard shortcuts will work immediately after the card is clicked
// upon.
dispatchFrigateCardEvent(this._element, 'focus');
dispatchAdvancedCameraCardEvent(this._element, 'focus');
}
this._allowClick = true;
};
@@ -133,7 +133,7 @@ export class ZoomController {
// Disable automatic touchAction setting from Panzoom() as otherwise it
// effectively disables dashboard scrolling. See:
// https://github.com/dermotduffy/frigate-hass-card/issues/1181
// https://github.com/dermotduffy/advanced-camera-card/issues/1181
touchAction: '',
// Set the initial pan/zoom values to avoid an initial unzoomed view.
@@ -211,11 +211,11 @@ export class ZoomController {
if (unzoomed && this._zoomed) {
this._zoomed = false;
this._setTouchAction(true);
dispatchFrigateCardEvent(this._element, 'zoom:unzoomed');
dispatchAdvancedCameraCardEvent(this._element, 'zoom:unzoomed');
} else if (!unzoomed && !this._zoomed) {
this._zoomed = true;
this._setTouchAction(false);
dispatchFrigateCardEvent(this._element, 'zoom:zoomed');
dispatchAdvancedCameraCardEvent(this._element, 'zoom:zoomed');
}
const converted = this._convertXYPanToPercent(pz.x, pz.y, pz.scale);
@@ -229,7 +229,7 @@ export class ZoomController {
unzoomed: unzoomed,
};
dispatchFrigateCardEvent(this._element, 'zoom:change', observed);
dispatchAdvancedCameraCardEvent(this._element, 'zoom:change', observed);
}
protected _isZoomEqual(a: PartialZoomSettings, b: PartialZoomSettings): boolean {
@@ -319,7 +319,7 @@ export class ZoomController {
}
/**
* Convert from Frigate card pan % values to Panzoom X/Y transformation
* Convert from Advanced Camera Card pan % values to Panzoom X/Y transformation
* coordinates.
* @param x The x translation value.
* @param y The y translation value.
@@ -439,7 +439,7 @@ export class ZoomController {
return (
!this._isUnzoomed(this._panzoom?.getScale()) ||
// TouchEvent does not exist on Firefox on non-touch events. See:
// https://github.com/dermotduffy/frigate-hass-card/issues/1174
// https://github.com/dermotduffy/advanced-camera-card/issues/1174
(window.TouchEvent && ev instanceof TouchEvent && ev.touches.length > 1) ||
(ev instanceof WheelEvent && ev.ctrlKey)
);