fix: Fix triggering for Reolink cameras (#2230)

- Fix inspired by #2228
This commit is contained in:
Dermot Duffy
2025-11-02 15:04:44 -08:00
committed by GitHub
parent 1f41781a84
commit 071dca07bf
3 changed files with 27 additions and 13 deletions
+10 -6
View File
@@ -38,12 +38,7 @@ export class Camera {
}
async initialize(options: CameraInitializationOptions): Promise<Camera> {
if (this._capabilities?.has('trigger')) {
options.stateWatcher.subscribe(
this._stateChangeHandler,
this._config.triggers.entities,
);
}
this._subscribeBasedOnCapabilities(options.stateWatcher);
this._onDestroy(() => options.stateWatcher.unsubscribe(this._stateChangeHandler));
return this;
}
@@ -120,4 +115,13 @@ export class Camera {
protected _onDestroy(callback: DestroyCallback): void {
this._destroyCallbacks.push(callback);
}
protected _subscribeBasedOnCapabilities(
stateWatcher: StateWatcherSubscriptionInterface,
): void {
if (this._capabilities?.has('trigger')) {
stateWatcher.unsubscribe(this._stateChangeHandler);
stateWatcher.subscribe(this._stateChangeHandler, this._config.triggers.entities);
}
}
}