@camera.ui/sdk / sensor / PTZControl
Class: PTZControl<TStorage> ​
Defined in: sensor/ptz.ts:120
Pan-tilt-zoom camera control. Override setPosition() / setVelocity() / setTargetPreset() to drive hardware, then call the corresponding super.X() method after success to sync the SDK state. For hardware-pushed state updates (e.g. PTZ position change events), call the super methods from your event handler. That bypasses any plugin override and only syncs state.
Set capabilities to advertise supported axes and features. Use setPresets() to publish the discovered preset list and setMoving() to publish movement state.
Extends ​
Sensor<PTZControlProperties,TStorage,PTZCapability>
Type Parameters ​
TStorage ​
TStorage extends object = Record<string, any>
Constructors ​
Constructor ​
new PTZControl<
TStorage>(name?,options?):PTZControl<TStorage>
Defined in: sensor/ptz.ts:124
Parameters ​
name? ​
string = 'PTZ'
options? ​
Returns ​
PTZControl<TStorage>
Overrides ​
Properties ​
category ​
readonlycategory:Control=SensorCategory.Control
Defined in: sensor/ptz.ts:122
Overrides ​
name ​
readonlyname:string
Defined in: sensor/base.ts:238
Inherited from ​
onAssignmentChanged ​
readonlyonAssignmentChanged:Observable<readonlystring[]>
Defined in: sensor/base.ts:266
Inherited from ​
onCapabilitiesChanged ​
readonlyonCapabilitiesChanged:Observable<PTZCapability[]>
Defined in: sensor/base.ts:258
Inherited from ​
onConnectedChanged ​
readonlyonConnectedChanged:Observable<boolean>
Defined in: sensor/base.ts:268
Inherited from ​
onPropertyChanged ​
readonlyonPropertyChanged:Observable<PropertyChangeOf<PTZControlProperties>>
Defined in: sensor/base.ts:256
Inherited from ​
type ​
readonlytype:PTZ=SensorType.PTZ
Defined in: sensor/ptz.ts:121
Overrides ​
Accessors ​
address ​
Get Signature ​
get address():
string|undefined
Defined in: sensor/base.ts:300
Returns ​
string | undefined
Inherited from ​
assignedCameraIds ​
Get Signature ​
get assignedCameraIds(): readonly
string[]
Defined in: sensor/base.ts:316
Returns ​
readonly string[]
Inherited from ​
assignmentLocked ​
Get Signature ​
get assignmentLocked():
boolean
Defined in: sensor/base.ts:320
Returns ​
boolean
Inherited from ​
capabilities ​
Get Signature ​
get capabilities():
TCapability[]
Defined in: sensor/base.ts:339
Returns ​
TCapability[]
Set Signature ​
set capabilities(
value):void
Defined in: sensor/base.ts:344
Set capabilities, deduplicated, and notify backend plus local listeners.
Parameters ​
value ​
TCapability[]
Returns ​
void
Inherited from ​
connected ​
Get Signature ​
get connected():
boolean
Defined in: sensor/base.ts:312
Returns ​
boolean
Inherited from ​
displayName ​
Get Signature ​
get displayName():
string
Defined in: sensor/base.ts:304
Returns ​
string
Inherited from ​
id ​
Get Signature ​
get id():
string
Defined in: sensor/base.ts:284
Returns ​
string
Inherited from ​
isAssigned ​
Get Signature ​
get isAssigned():
boolean
Defined in: sensor/base.ts:308
Returns ​
boolean
Inherited from ​
moving ​
Get Signature ​
get moving():
boolean
Defined in: sensor/ptz.ts:138
Returns ​
boolean
nativeId ​
Get Signature ​
get nativeId():
string|undefined
Defined in: sensor/base.ts:288
Returns ​
string | undefined
Inherited from ​
origin ​
Get Signature ​
get origin():
string|undefined
Defined in: sensor/base.ts:292
Returns ​
string | undefined
Inherited from ​
pluginId ​
Get Signature ​
get pluginId():
string|undefined
Defined in: sensor/base.ts:324
Returns ​
string | undefined
Inherited from ​
position ​
Get Signature ​
get position():
PTZPosition
Defined in: sensor/ptz.ts:134
Returns ​
presets ​
Get Signature ​
get presets():
string[]
Defined in: sensor/ptz.ts:142
Returns ​
string[]
props ​
Get Signature ​
get
protectedprops():Readonly<TProperties>
Defined in: sensor/base.ts:558
Returns ​
Readonly<TProperties>
Inherited from ​
sourceState ​
Get Signature ​
get sourceState():
SensorSourceState|undefined
Defined in: sensor/base.ts:296
Returns ​
SensorSourceState | undefined
Inherited from ​
storage ​
Get Signature ​
get storage():
DeviceStorage<TStorage>
Defined in: sensor/base.ts:328
Returns ​
DeviceStorage<TStorage>
Inherited from ​
storageSchema ​
Get Signature ​
get storageSchema():
JsonSchema[]
Defined in: sensor/base.ts:335
Returns ​
Inherited from ​
targetPreset ​
Get Signature ​
get targetPreset():
string|undefined
Defined in: sensor/ptz.ts:150
Returns ​
string | undefined
velocity ​
Get Signature ​
get velocity():
PTZDirection|undefined
Defined in: sensor/ptz.ts:146
Returns ​
PTZDirection | undefined
Methods ​
getValue() ​
Call Signature ​
getValue<
K>(property):PTZControlProperties[K] |undefined
Defined in: sensor/base.ts:368
Get the current value of a sensor property. Calling the generic overload with a property enum value gives a properly typed result.
Type Parameters ​
K ​
K extends keyof PTZControlProperties
Parameters ​
property ​
K
Returns ​
PTZControlProperties[K] | undefined
Inherited from ​
Call Signature ​
getValue(
property):unknown
Defined in: sensor/base.ts:369
Get the current value of a sensor property. Calling the generic overload with a property enum value gives a properly typed result.
Parameters ​
property ​
string
Returns ​
unknown
Inherited from ​
getValues() ​
getValues():
Readonly<TProperties>
Defined in: sensor/base.ts:385
Get a read-only snapshot of all property values.
Returns ​
Readonly<TProperties>
Shallow copy of every property currently held by the sensor.
Example ​
const snapshot = sensor.getValues();
console.log(snapshot);Inherited from ​
goHome() ​
goHome():
Promise<void>
Defined in: sensor/ptz.ts:256
Move the camera to the home position (pan=0, tilt=0, zoom=0).
Returns ​
Promise<void>
Example ​
await ptz.goHome();hasCapability() ​
hasCapability(
capability):boolean
Defined in: sensor/base.ts:411
Check whether the sensor advertises a capability.
Parameters ​
capability ​
string
Capability flag to look for.
Returns ​
boolean
True if the sensor currently advertises it.
Example ​
const dimmable = sensor.hasCapability('brightness');Inherited from ​
onStart() ​
protectedonStart():void|Promise<void>
Defined in: sensor/base.ts:647
Lifecycle hook, called once the sensor is registered and live (storage and RPC are wired up). Override it to start work whose lifetime matches the sensor's: polling loops, event subscriptions, timers.
Errors thrown here are swallowed, not logged. Handle failures inside the override. Paired 1:1 with onStop, which runs on removal, plugin shutdown or cleanup.
Returns ​
void | Promise<void>
Example ​
protected override onStart(): void {
this._timer = setInterval(() => this.poll(), 5_000);
}Inherited from ​
onStop() ​
protectedonStop():void|Promise<void>
Defined in: sensor/base.ts:660
Counterpart of onStart: tear down whatever it started, such as timers, subscriptions and external resources.
Returns ​
void | Promise<void>
Example ​
protected override onStop(): void {
if (this._timer) clearInterval(this._timer);
}Inherited from ​
setAddress() ​
setAddress(
address):void
Defined in: sensor/base.ts:444
Report the sensor's current address at the source, e.g. after a Home Assistant entity was renamed. The identity (nativeId) stays.
Parameters ​
address ​
string
Current address at the source
Returns ​
void
Example ​
sensor.setAddress(entry.entity_id);Inherited from ​
setDisplayName() ​
setDisplayName(
value):void
Defined in: sensor/base.ts:360
Set the display name (the only mutable identifier on a sensor).
Parameters ​
value ​
string
Human-readable label shown in the UI.
Returns ​
void
Example ​
sensor.setDisplayName('Front Door Motion');Inherited from ​
setMoving() ​
setMoving(
value):void
Defined in: sensor/ptz.ts:244
Publish movement state (e.g. when continuous-move starts/stops).
Parameters ​
value ​
boolean
True while the camera is moving.
Returns ​
void
Example ​
ptz.setMoving(true);setPosition() ​
setPosition(
value):Promise<void>
Defined in: sensor/ptz.ts:165
Move to an absolute pan/tilt/zoom position. Override to drive hardware and call await super.setPosition(value) after success to sync the SDK state.
Parameters ​
value ​
Absolute pan/tilt/zoom target position.
Returns ​
Promise<void>
Example ​
await ptz.setPosition({ pan: 0.25, tilt: -0.1, zoom: 0.5 });setPresets() ​
setPresets(
value):void
Defined in: sensor/ptz.ts:230
Publish the discovered preset list (typically called once at startup).
Parameters ​
value ​
string[]
List of preset names supported by the camera.
Returns ​
void
Example ​
ptz.setPresets(['Home', 'Driveway', 'Backyard']);setRelativeMove() ​
setRelativeMove(
value):Promise<void>
Defined in: sensor/ptz.ts:200
Relative displacement move. Override to drive hardware (e.g. ONVIF RelativeMove in a translation space) and call await super.setRelativeMove(value) after success to sync the SDK state. Advertise PTZCapability.RelativeMove when the camera supports it.
Parameters ​
value ​
Per-axis displacement, normalized to the field of view.
Returns ​
Promise<void>
Example ​
// move the view a third of a frame to the right, a tenth down
await ptz.setRelativeMove({ panDelta: 0.33, tiltDelta: -0.1, zoomDelta: 0 });setSourceState() ​
setSourceState(
state):void
Defined in: sensor/base.ts:427
Report what the source behind this sensor looks like right now. The host shows the state with its reason on the sensors page and never deletes on it. Only meaningful for adopted sensors.
Parameters ​
state ​
Current source state
Returns ​
void
Example ​
sensor.setSourceState(registryHasEntity ? 'connected' : 'removed');Inherited from ​
setTargetPreset() ​
setTargetPreset(
value):Promise<void>
Defined in: sensor/ptz.ts:216
Preset-move command. Override to drive hardware and call await super.setTargetPreset(value) after success to sync the SDK state.
Parameters ​
value ​
string | undefined
Preset name to move to. undefined is ignored and the published targetPreset keeps its last value.
Returns ​
Promise<void>
Example ​
await ptz.setTargetPreset('Driveway');setVelocity() ​
setVelocity(
value):Promise<void>
Defined in: sensor/ptz.ts:182
Continuous-move command. Override to drive hardware and call await super.setVelocity(value) after success to sync the SDK state.
Parameters ​
value ​
PTZDirection | undefined
Per-axis speeds in [-1, 1]. Stop is zero on every axis. undefined is ignored and the published velocity keeps its last value.
Returns ​
Promise<void>
Example ​
await ptz.setVelocity({ panSpeed: 0.5, tiltSpeed: 0, zoomSpeed: 0 });
await ptz.setVelocity({ panSpeed: 0, tiltSpeed: 0, zoomSpeed: 0 }); // stopupdateModelSpec() ​
updateModelSpec():
void
Defined in: sensor/base.ts:577
Re-announces the model spec, e.g. once the models finished loading.
The spec a detector reports at registration is what it knows at that moment: models that load in the background are missing from it. Call this after loading, the server replaces its copy.
Returns ​
void
Example ​
async onStart(): Promise<void> {
await this.loadModel();
this.updateModelSpec();
}