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
@@ -7,9 +7,11 @@ import { PTZAction } from '../../../src/config/ptz';
describe('setKeyboardShortcutsFromConfig', () => {
it('without shortcuts', () => {
const api = createCardAPI();
setKeyboardShortcutsFromConfig(api, 'tag');
setKeyboardShortcutsFromConfig(api);
expect(api.getAutomationsManager().deleteAutomations).toBeCalledWith('tag');
expect(api.getAutomationsManager().deleteAutomations).toBeCalledWith(
setKeyboardShortcutsFromConfig,
);
expect(api.getAutomationsManager().addAutomations).not.toBeCalled();
});
@@ -24,9 +26,11 @@ describe('setKeyboardShortcutsFromConfig', () => {
},
}),
);
setKeyboardShortcutsFromConfig(api, 'tag');
setKeyboardShortcutsFromConfig(api);
expect(api.getAutomationsManager().deleteAutomations).toBeCalledWith('tag');
expect(api.getAutomationsManager().deleteAutomations).toBeCalledWith(
setKeyboardShortcutsFromConfig,
);
expect(api.getAutomationsManager().addAutomations).not.toBeCalled();
});
@@ -59,9 +63,11 @@ describe('setKeyboardShortcutsFromConfig', () => {
}),
);
setKeyboardShortcutsFromConfig(api, 'tag');
setKeyboardShortcutsFromConfig(api);
expect(api.getAutomationsManager().deleteAutomations).toBeCalledWith('tag');
expect(api.getAutomationsManager().deleteAutomations).toBeCalledWith(
setKeyboardShortcutsFromConfig,
);
expect(api.getAutomationsManager().addAutomations).toBeCalledWith([
{
actions: [
@@ -83,7 +89,7 @@ describe('setKeyboardShortcutsFromConfig', () => {
state: 'down',
},
],
tag: 'tag',
tag: setKeyboardShortcutsFromConfig,
},
{
actions: [
@@ -101,7 +107,7 @@ describe('setKeyboardShortcutsFromConfig', () => {
state: 'up',
},
],
tag: 'tag',
tag: setKeyboardShortcutsFromConfig,
},
]);
});
@@ -110,9 +116,11 @@ describe('setKeyboardShortcutsFromConfig', () => {
const api = createCardAPI();
vi.mocked(api.getConfigManager().getConfig).mockReturnValue(createConfig());
setKeyboardShortcutsFromConfig(api, 'tag');
setKeyboardShortcutsFromConfig(api);
expect(api.getAutomationsManager().deleteAutomations).toBeCalledWith('tag');
expect(api.getAutomationsManager().deleteAutomations).toBeCalledWith(
setKeyboardShortcutsFromConfig,
);
expect(api.getAutomationsManager().addAutomations).toBeCalledWith(
expect.arrayContaining([
{
@@ -133,7 +141,7 @@ describe('setKeyboardShortcutsFromConfig', () => {
state: 'down',
},
],
tag: 'tag',
tag: setKeyboardShortcutsFromConfig,
},
]),
);