Fix incorrect engine detection.

This commit is contained in:
Dermot Duffy
2023-04-29 15:09:50 -07:00
parent bd4866669a
commit 2b00d95176
5 changed files with 239 additions and 7 deletions
+10 -3
View File
@@ -10,6 +10,7 @@ import { MemoryRequestCache, RecordingSegmentsCache, RequestCache } from './cach
import { CameraManagerEngine } from './engine';
import { CameraInitializationError } from './error';
import { Engine } from './types';
import { getCameraEntityFromConfig } from './util';
export class CameraManagerEngineFactory {
protected _entityRegistryManager: EntityRegistryManager;
@@ -63,16 +64,22 @@ export class CameraManagerEngineFactory {
engine = Engine.Frigate;
} else if (cameraConfig.engine === 'motioneye') {
engine = Engine.MotionEye;
} else if (cameraConfig.engine === 'generic') {
engine = Engine.Generic;
} else if (cameraConfig.engine === 'auto') {
const cameraEntity = cameraConfig.camera_entity;
const cameraEntity = getCameraEntityFromConfig(cameraConfig);
if (cameraEntity) {
let entity: Entity | null;
try {
entity = await this._entityRegistryManager.getEntity(hass, cameraEntity);
} catch (e) {
// Throw a slightly friendlier exception (as a typo in the entity is
// likely to be a common failure mode).
// If the camera is not in the registry, but is in the HA states it is
// assumed to be a generic camera.
if (hass.states[cameraEntity]) {
return Engine.Generic;
}
// Otherwise, it's probably a typo so throw an exception.
throw new CameraInitializationError(
localize('error.no_camera_entity'),
cameraConfig,