feat: Add out of the box support for Reolink PTZ (#1982)
- Closes: #1964
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { ActionsExecutor } from '../card-controller/actions/types';
|
||||
import { StateWatcherSubscriptionInterface } from '../card-controller/hass/state-watcher';
|
||||
import { PTZAction, PTZActionPhase } from '../config/schema/actions/custom/ptz';
|
||||
import { CameraConfig } from '../config/schema/cameras';
|
||||
import { localize } from '../localize/localize';
|
||||
import { HassStateDifference, isTriggeredState } from '../utils/ha';
|
||||
@@ -6,6 +8,7 @@ import { Capabilities } from './capabilities';
|
||||
import { CameraManagerEngine } from './engine';
|
||||
import { CameraNoIDError } from './error';
|
||||
import { CameraEventCallback, CameraProxyConfig } from './types';
|
||||
import { getConfiguredPTZAction } from './utils/ptz';
|
||||
|
||||
export interface CameraInitializationOptions {
|
||||
stateWatcher: StateWatcherSubscriptionInterface;
|
||||
@@ -83,6 +86,22 @@ export class Camera {
|
||||
};
|
||||
}
|
||||
|
||||
public async executePTZAction(
|
||||
executor: ActionsExecutor,
|
||||
action: PTZAction,
|
||||
options?: {
|
||||
phase?: PTZActionPhase;
|
||||
preset?: string;
|
||||
},
|
||||
): Promise<boolean> {
|
||||
const configuredAction = getConfiguredPTZAction(this.getConfig(), action, options);
|
||||
if (configuredAction) {
|
||||
await executor.executeActions({ actions: configuredAction });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected _stateChangeHandler = (difference: HassStateDifference): void => {
|
||||
this._eventCallback?.({
|
||||
cameraID: this.getID(),
|
||||
|
||||
Reference in New Issue
Block a user