feat: Add out of the box support for Reolink PTZ (#1982)
- Closes: #1964
This commit is contained in:
@@ -258,7 +258,7 @@ describe('ActionsManager', () => {
|
||||
const consoleSpy = vi.spyOn(global.console, 'info').mockReturnValue(undefined);
|
||||
await manager.handleActionExecutionRequestEvent(
|
||||
new CustomEvent('advanced-camera-card:action:execution-request', {
|
||||
detail: { action: createLogAction('Hello, world!') },
|
||||
detail: { actions: createLogAction('Hello, world!') },
|
||||
}),
|
||||
);
|
||||
expect(consoleSpy).toBeCalled();
|
||||
@@ -271,7 +271,7 @@ describe('ActionsManager', () => {
|
||||
const manager = new ActionsManager(api);
|
||||
|
||||
const consoleSpy = vi.spyOn(global.console, 'info').mockReturnValue(undefined);
|
||||
await manager.executeActions(createLogAction('Hello, world!'));
|
||||
await manager.executeActions({ actions: createLogAction('Hello, world!') });
|
||||
expect(consoleSpy).toBeCalled();
|
||||
});
|
||||
|
||||
@@ -280,7 +280,7 @@ describe('ActionsManager', () => {
|
||||
const manager = new ActionsManager(api);
|
||||
|
||||
const consoleSpy = vi.spyOn(global.console, 'info').mockReturnValue(undefined);
|
||||
await manager.executeActions(createLogAction('Hello, world!'));
|
||||
await manager.executeActions({ actions: createLogAction('Hello, world!') });
|
||||
expect(consoleSpy).toBeCalled();
|
||||
});
|
||||
|
||||
@@ -303,10 +303,7 @@ describe('ActionsManager', () => {
|
||||
const config = { entity: 'light.office' };
|
||||
const triggerData = { view: { from: 'previous-view', to: 'view' } };
|
||||
|
||||
await manager.executeActions(action, {
|
||||
config,
|
||||
triggerData,
|
||||
});
|
||||
await manager.executeActions({ actions: action, config, triggerData });
|
||||
|
||||
expect(templateRenderer.renderRecursively).toBeCalledWith(hass, action, {
|
||||
conditionState,
|
||||
@@ -326,7 +323,7 @@ describe('ActionsManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ActionsManager(api);
|
||||
|
||||
await manager.executeActions({ action: 'none' });
|
||||
await manager.executeActions({ actions: { action: 'none' } });
|
||||
|
||||
expect(handler).toBeCalledWith(expect.objectContaining({ detail: 'success' }));
|
||||
});
|
||||
@@ -340,7 +337,9 @@ describe('ActionsManager', () => {
|
||||
|
||||
vi.stubGlobal('confirm', vi.fn().mockReturnValue(false));
|
||||
|
||||
await manager.executeActions({ action: 'none', confirmation: true });
|
||||
await manager.executeActions({
|
||||
actions: { action: 'none', confirmation: true },
|
||||
});
|
||||
|
||||
expect(handler).toBeCalledWith(expect.objectContaining({ detail: 'warning' }));
|
||||
});
|
||||
@@ -360,16 +359,18 @@ describe('ActionsManager', () => {
|
||||
const manager = new ActionsManager(api);
|
||||
|
||||
const consoleSpy = vi.spyOn(global.console, 'info').mockReturnValue(undefined);
|
||||
const promise = manager.executeActions([
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'sleep',
|
||||
duration: {
|
||||
m: 1,
|
||||
const promise = manager.executeActions({
|
||||
actions: [
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'sleep',
|
||||
duration: {
|
||||
m: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
createLogAction('Hello, world!'),
|
||||
]);
|
||||
createLogAction('Hello, world!'),
|
||||
],
|
||||
});
|
||||
|
||||
// Stop inflight actions.
|
||||
await manager.uninitialize();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
|
||||
import { Capabilities } from '../../../../src/camera-manager/capabilities';
|
||||
import { PTZAction } from '../../../../src/card-controller/actions/actions/ptz';
|
||||
import { PTZMovementType } from '../../../../src/types';
|
||||
import {
|
||||
createCameraConfig,
|
||||
createCameraManager,
|
||||
@@ -7,7 +9,6 @@ import {
|
||||
createStore,
|
||||
createView,
|
||||
} from '../../../test-utils';
|
||||
import { Capabilities } from '../../../../src/camera-manager/capabilities';
|
||||
|
||||
describe('should handle ptz action', () => {
|
||||
it('should execute simple action', async () => {
|
||||
@@ -20,7 +21,7 @@ describe('should handle ptz action', () => {
|
||||
const store = createStore([
|
||||
{
|
||||
cameraID: 'camera.office',
|
||||
capabilities: new Capabilities({ ptz: { left: ['relative'] } }),
|
||||
capabilities: new Capabilities({ ptz: { left: [PTZMovementType.Relative] } }),
|
||||
},
|
||||
]);
|
||||
vi.mocked(api.getCameraManager).mockReturnValue(createCameraManager(store));
|
||||
@@ -53,7 +54,7 @@ describe('should handle ptz action', () => {
|
||||
const store = createStore([
|
||||
{
|
||||
cameraID: 'camera.office',
|
||||
capabilities: new Capabilities({ ptz: { left: ['relative'] } }),
|
||||
capabilities: new Capabilities({ ptz: { left: [PTZMovementType.Relative] } }),
|
||||
},
|
||||
]);
|
||||
vi.mocked(api.getCameraManager).mockReturnValue(createCameraManager(store));
|
||||
@@ -93,7 +94,7 @@ describe('should handle ptz action', () => {
|
||||
},
|
||||
{
|
||||
cameraID: 'camera.office_hd',
|
||||
capabilities: new Capabilities({ ptz: { left: ['relative'] } }),
|
||||
capabilities: new Capabilities({ ptz: { left: [PTZMovementType.Relative] } }),
|
||||
},
|
||||
]);
|
||||
vi.mocked(api.getCameraManager).mockReturnValue(createCameraManager(store));
|
||||
@@ -210,7 +211,7 @@ describe('should handle ptz action', () => {
|
||||
cameraID: 'camera.office',
|
||||
capabilities: new Capabilities({
|
||||
ptz: {
|
||||
left: ['relative'],
|
||||
left: [PTZMovementType.Relative],
|
||||
presets: [],
|
||||
},
|
||||
}),
|
||||
@@ -281,7 +282,7 @@ describe('should handle ptz action', () => {
|
||||
cameraID: 'camera.office',
|
||||
capabilities: new Capabilities({
|
||||
ptz: {
|
||||
left: ['continuous'],
|
||||
left: [PTZMovementType.Continuous],
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -329,7 +330,7 @@ describe('should handle ptz action', () => {
|
||||
cameraID: 'camera.office',
|
||||
capabilities: new Capabilities({
|
||||
ptz: {
|
||||
left: ['continuous'],
|
||||
left: [PTZMovementType.Continuous],
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -375,7 +376,7 @@ describe('should handle ptz action', () => {
|
||||
cameraID: 'camera.office',
|
||||
capabilities: new Capabilities({
|
||||
ptz: {
|
||||
left: ['continuous'],
|
||||
left: [PTZMovementType.Continuous],
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -419,7 +420,7 @@ describe('should handle ptz action', () => {
|
||||
cameraID: 'camera.office',
|
||||
capabilities: new Capabilities({
|
||||
ptz: {
|
||||
left: ['relative'],
|
||||
left: [PTZMovementType.Relative],
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -473,7 +474,7 @@ describe('should handle ptz action', () => {
|
||||
cameraID: 'camera.office',
|
||||
capabilities: new Capabilities({
|
||||
ptz: {
|
||||
left: ['relative'],
|
||||
left: [PTZMovementType.Relative],
|
||||
},
|
||||
}),
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { ActionsExecutionRequest } from '../../src/card-controller/actions/types.js';
|
||||
import { AutomationsManager } from '../../src/card-controller/automations-manager.js';
|
||||
import { ConditionStateManager } from '../../src/conditions/state-manager.js';
|
||||
import { ActionConfig } from '../../src/config/schema/actions/types.js';
|
||||
import { createCardAPI } from '../test-utils.js';
|
||||
|
||||
describe('AutomationsManager', () => {
|
||||
@@ -150,9 +150,7 @@ describe('AutomationsManager', () => {
|
||||
vi.mocked(api.getActionsManager().executeActions).mockImplementation(
|
||||
async (
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_action: ActionConfig | ActionConfig[],
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_options?: unknown,
|
||||
_request: ActionsExecutionRequest,
|
||||
): Promise<void> => {
|
||||
fullscreen = !fullscreen;
|
||||
stateManager.setState({ fullscreen: fullscreen });
|
||||
|
||||
@@ -29,7 +29,7 @@ import { ViewManager } from '../../src/card-controller/view/view-manager';
|
||||
import { ConditionStateManager } from '../../src/conditions/state-manager';
|
||||
import { AdvancedCameraCardEditor } from '../../src/editor';
|
||||
import { DeviceRegistryManager } from '../../src/utils/ha/registry/device';
|
||||
import { EntityRegistryManager } from '../../src/utils/ha/registry/entity';
|
||||
import { EntityRegistryManagerLive } from '../../src/utils/ha/registry/entity';
|
||||
import { ResolvedMediaCache } from '../../src/utils/ha/resolved-media';
|
||||
|
||||
vi.mock('../../src/camera-manager/manager');
|
||||
@@ -160,7 +160,7 @@ describe('CardController', () => {
|
||||
|
||||
it('getEntityRegistryManager', () => {
|
||||
expect(createController().getEntityRegistryManager()).toBe(
|
||||
vi.mocked(EntityRegistryManager).mock.instances[0],
|
||||
vi.mocked(EntityRegistryManagerLive).mock.instances[0],
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
MEDIA_PLAYER_SUPPORT_TURN_OFF,
|
||||
} from '../../src/const';
|
||||
import { HomeAssistant } from '../../src/ha/types.js';
|
||||
import { EntityRegistryManager } from '../../src/utils/ha/registry/entity/index.js';
|
||||
import { EntityRegistryManager } from '../../src/utils/ha/registry/entity/types.js';
|
||||
import {
|
||||
createCameraConfig,
|
||||
createCameraManager,
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
createStore,
|
||||
TestViewMedia,
|
||||
} from '../test-utils.js';
|
||||
import { EntityRegistryManagerMock } from '../utils/ha/registry/entity/mock.js';
|
||||
|
||||
const createHASSWithMediaPlayers = (): HomeAssistant => {
|
||||
const attributesSupported = {
|
||||
@@ -68,13 +69,16 @@ describe('MediaPlayerManager', () => {
|
||||
|
||||
describe('should initialize', () => {
|
||||
it('correctly', async () => {
|
||||
const entityRegistryManager = mock<EntityRegistryManager>();
|
||||
entityRegistryManager.getEntities.mockResolvedValue(
|
||||
new Map([
|
||||
['media_player.ok1', createRegistryEntity({ hidden_by: '' })],
|
||||
['media_player.ok2', createRegistryEntity({ hidden_by: 'user' })],
|
||||
]),
|
||||
);
|
||||
const entityRegistryManager = new EntityRegistryManagerMock([
|
||||
createRegistryEntity({
|
||||
entity_id: 'media_player.ok1',
|
||||
hidden_by: '',
|
||||
}),
|
||||
createRegistryEntity({
|
||||
entity_id: 'media_player.ok2',
|
||||
hidden_by: 'user',
|
||||
}),
|
||||
]);
|
||||
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getHASSManager().getHASS).mockReturnValue(
|
||||
@@ -150,13 +154,16 @@ describe('MediaPlayerManager', () => {
|
||||
});
|
||||
|
||||
it('should reinitialize when there is a config change', async () => {
|
||||
const entityRegistryManager = mock<EntityRegistryManager>();
|
||||
entityRegistryManager.getEntities.mockResolvedValue(
|
||||
new Map([
|
||||
['media_player.ok1', createRegistryEntity({ hidden_by: '' })],
|
||||
['media_player.ok2', createRegistryEntity({ hidden_by: 'user' })],
|
||||
]),
|
||||
);
|
||||
const entityRegistryManager = new EntityRegistryManagerMock([
|
||||
createRegistryEntity({
|
||||
entity_id: 'media_player.ok1',
|
||||
hidden_by: '',
|
||||
}),
|
||||
createRegistryEntity({
|
||||
entity_id: 'media_player.ok2',
|
||||
hidden_by: 'user',
|
||||
}),
|
||||
]);
|
||||
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getHASSManager().getHASS).mockReturnValue(
|
||||
|
||||
@@ -77,13 +77,15 @@ describe('QueryStringManager', () => {
|
||||
expect(manager.hasViewRelatedActionsToRun()).toBeFalsy();
|
||||
await manager.executeIfNecessary();
|
||||
|
||||
expect(api.getActionsManager().executeActions).toBeCalledWith([
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
card_id: 'id',
|
||||
advanced_camera_card_action: action,
|
||||
},
|
||||
]);
|
||||
expect(api.getActionsManager().executeActions).toBeCalledWith({
|
||||
actions: [
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
card_id: 'id',
|
||||
advanced_camera_card_action: action,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user