fix: Substream only cameras should not be triggerable (#1848)

- Closes #1846
This commit is contained in:
Dermot Duffy
2025-01-21 07:17:09 -08:00
committed by GitHub
parent 596a724714
commit 0212840688
13 changed files with 100 additions and 9 deletions
+33 -1
View File
@@ -81,6 +81,9 @@ describe('Camera', () => {
},
}),
new GenericCameraManagerEngine(mock<StateWatcherSubscriptionInterface>()),
{
capabilities: createCapabilities({ trigger: true }),
},
);
const stateWatcher = mock<StateWatcherSubscriptionInterface>();
@@ -117,7 +120,10 @@ describe('Camera', () => {
},
}),
new GenericCameraManagerEngine(mock<StateWatcherSubscriptionInterface>()),
{ eventCallback: eventCallback },
{
capabilities: createCapabilities({ trigger: true }),
eventCallback: eventCallback,
},
);
const stateWatcher = mock<StateWatcherSubscriptionInterface>();
@@ -125,6 +131,8 @@ describe('Camera', () => {
stateWatcher: stateWatcher,
});
expect(stateWatcher.subscribe).toBeCalled();
const diff = {
entityID: 'sensor.force_update',
oldState: createStateEntity({ state: stateFrom }),
@@ -138,6 +146,30 @@ describe('Camera', () => {
});
},
);
it('should not trigger without trigger capability', async () => {
const eventCallback = vi.fn();
const camera = new Camera(
createCameraConfig({
id: 'camera_1',
triggers: {
entities: ['binary_sensor.foo'],
},
}),
new GenericCameraManagerEngine(mock<StateWatcherSubscriptionInterface>()),
{
capabilities: createCapabilities({ trigger: false }),
eventCallback: eventCallback,
},
);
const stateWatcher = mock<StateWatcherSubscriptionInterface>();
await camera.initialize({
stateWatcher: stateWatcher,
});
expect(stateWatcher.subscribe).not.toBeCalled();
});
});
describe('should get proxy config', () => {