Allow camera engines to signal events to the card.
This commit is contained in:
+94
-46
@@ -4,6 +4,7 @@ import {
|
||||
createRangedTransform,
|
||||
deleteConfigValue,
|
||||
deleteTransform,
|
||||
deleteWithOverrides,
|
||||
getArrayConfigPath,
|
||||
getConfigValue,
|
||||
isConfigUpgradeable,
|
||||
@@ -344,6 +345,12 @@ describe('upgrade functions', () => {
|
||||
it('should have upgrades with bad input data', () => {
|
||||
expect(upgradeConfig(3 as unknown as RawFrigateCardConfig)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should delete properties', () => {
|
||||
const config = { c: 10, d: 10 };
|
||||
expect(deleteWithOverrides('c')(config)).toBeTruthy();
|
||||
expect(config).toEqual({ d: 10 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('should handle version specific upgrades', () => {
|
||||
@@ -1167,52 +1174,6 @@ describe('should handle version specific upgrades', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('should move and transform untrigger_reset', () => {
|
||||
it('when true', () => {
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
view: {
|
||||
scan: {
|
||||
untrigger_reset: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(upgradeConfig(config)).toBeTruthy();
|
||||
expect(config).toEqual({
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
view: {
|
||||
scan: {
|
||||
actions: {
|
||||
untrigger: 'default',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('when false', () => {
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
view: {
|
||||
scan: {
|
||||
untrigger_reset: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(upgradeConfig(config)).toBeTruthy();
|
||||
expect(config).toEqual({
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
view: {
|
||||
scan: {},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should move view.timeout_seconds', () => {
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
@@ -1690,5 +1651,92 @@ describe('should handle version specific upgrades', () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('should transform scan mode', () => {
|
||||
describe('should move and transform untrigger_reset', () => {
|
||||
it('when true', () => {
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
view: {
|
||||
scan: {
|
||||
untrigger_reset: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(upgradeConfig(config)).toBeTruthy();
|
||||
expect(config).toEqual({
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
view: {
|
||||
triggers: {
|
||||
actions: {
|
||||
untrigger: 'default',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('when false', () => {
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
view: {
|
||||
scan: {
|
||||
untrigger_reset: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(upgradeConfig(config)).toBeTruthy();
|
||||
expect(config).toEqual({
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
view: {
|
||||
triggers: {},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('should rename view.scan.enabled to a trigger action', () => {
|
||||
it('when true', () => {
|
||||
const config = {
|
||||
view: {
|
||||
scan: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(upgradeConfig(config)).toBeTruthy();
|
||||
expect(config).toEqual({
|
||||
view: {
|
||||
triggers: {
|
||||
filter_selected_camera: false,
|
||||
actions: {
|
||||
trigger: 'live',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('when false', () => {
|
||||
const config = {
|
||||
view: {
|
||||
scan: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(upgradeConfig(config)).toBeTruthy();
|
||||
expect(config).toEqual({
|
||||
view: {
|
||||
triggers: {},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user