feat: Add experimental reolink media support (#1694)

* feat: Add experimental rich reolink support.

* Formatting fix
This commit is contained in:
Dermot Duffy
2024-11-25 20:19:12 -08:00
committed by GitHub
parent e898b73d63
commit dada65e008
63 changed files with 3402 additions and 483 deletions
+38 -1
View File
@@ -18,6 +18,7 @@ import {
createRegistryEntity,
createStateEntity,
} from '../test-utils';
import { ReolinkCameraManagerEngine } from '../../src/camera-manager/reolink/engine-reolink.js';
vi.mock('../../src/utils/ha/entity-registry');
vi.mock('../../src/utils/ha/entity-registry/cache');
@@ -70,7 +71,7 @@ describe('getEngineForCamera()', () => {
});
});
describe('should get a motionEye camera', () => {
describe('should get a motioneye camera', () => {
it('from manually set engine', async () => {
const config = createCameraConfig({ engine: 'motioneye' });
expect(await createFactory().getEngineForCamera(createHASS(), config)).toBe(
@@ -98,6 +99,34 @@ describe('getEngineForCamera()', () => {
});
});
describe('should get a reolink camera', () => {
it('from manually set engine', async () => {
const config = createCameraConfig({ engine: 'reolink' });
expect(await createFactory().getEngineForCamera(createHASS(), config)).toBe(
Engine.Reolink,
);
});
it('from auto detection', async () => {
const config = createCameraConfig({ engine: 'auto', camera_entity: 'camera.foo' });
const entityRegistryManager = new EntityRegistryManager(
createEntityRegistryCache(),
);
entityRegistryManager.getEntity = vi
.fn()
.mockResolvedValue(
createRegistryEntity({ entity_id: 'camera.foo', platform: 'reolink' }),
);
expect(
await createFactory({
entityRegistryManager: entityRegistryManager,
}).getEngineForCamera(createHASS(), config),
).toBe(Engine.Reolink);
});
});
describe('should get a generic camera', () => {
it('from manually set engine', async () => {
const config = createCameraConfig({ engine: 'generic' });
@@ -233,4 +262,12 @@ describe('createEngine()', () => {
}),
).toBeInstanceOf(MotionEyeCameraManagerEngine);
});
it('should create reolink engine', async () => {
expect(
await createFactory().createEngine(Engine.Reolink, {
stateWatcher: mock<StateWatcherSubscriptionInterface>(),
resolvedMediaCache: mock<ResolvedMediaCache>(),
}),
).toBeInstanceOf(ReolinkCameraManagerEngine);
});
});