feat: Add control/output of selected camera via an entity (#1895)

- Closes #1871
This commit is contained in:
Dermot Duffy
2025-02-17 13:33:10 -08:00
committed by GitHub
parent da79664a67
commit c66c3ec919
46 changed files with 677 additions and 91 deletions
+34 -2
View File
@@ -1,18 +1,20 @@
import { hasAction as customCardHasAction } from '@dermotduffy/custom-card-helpers';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { mock } from 'vitest-mock-extended';
import { actionSchema } from '../../src/config/types';
import { actionSchema, INTERNAL_CALLBACK_ACTION } from '../../src/config/types';
import {
convertActionToCardCustomAction,
createCameraAction,
createDisplayModeAction,
createGeneralAction,
createInternalCallbackAction,
createLogAction,
createMediaPlayerAction,
createPTZAction,
createPTZControlsAction,
createPTZDigitalAction,
createPTZMultiAction,
createViewAction,
getActionConfigGivenAction,
hasAction,
stopEventFromActivatingCardWideActions,
@@ -45,7 +47,21 @@ describe('convertActionToAdvancedCameraCardCustomAction', () => {
describe('createGeneralAction', () => {
it('should create general action', () => {
expect(
createGeneralAction('clips', {
createGeneralAction('camera_ui', {
cardID: 'card_id',
}),
).toEqual({
action: 'fire-dom-event',
advanced_camera_card_action: 'camera_ui',
card_id: 'card_id',
});
});
});
describe('createViewAction', () => {
it('should create view action', () => {
expect(
createViewAction('clips', {
cardID: 'card_id',
}),
).toEqual({
@@ -241,6 +257,22 @@ describe('createLogAction', () => {
});
});
describe('createInternalCallbackAction', () => {
it('should create internal callback action', () => {
const callback = vi.fn();
expect(
createInternalCallbackAction(callback, {
cardID: 'card_id',
}),
).toEqual({
action: 'fire-dom-event',
advanced_camera_card_action: INTERNAL_CALLBACK_ACTION,
callback: callback,
card_id: 'card_id',
});
});
});
describe('getActionConfigGivenAction', () => {
const action = actionSchema.parse({
action: 'fire-dom-event',