@camera.ui/sdk / sensor / Sensor
Abstract Class: Sensor<TProperties, TStorage, TCapability>
Defined in: sensor/base.ts:219
Abstract base class for all sensors. Plugins extend this (or use specialized subclasses like MotionSensor, LightControl, etc.) to implement sensor logic.
Sensors are standalone entities: the plugin supplies the durable identity (nativeId), everything else belongs to the user: camera assignments, display name and whether the sensor is exported or not. A plugin never decides where its sensor is used and never handles the export itself.
State changes go through the semantic methods on the concrete class. Writing a changed value notifies the backend and local listeners.
The id is provisional until registration, when the host swaps in the persistent entity id. Reading storage before registration throws. Override storageSchema to return a JSON schema and get a per-sensor settings UI.
Extended by
AudioSensorBatteryInfoCarbonDioxideInfoCarbonMonoxideSensorClassifierSensorClipDetectorSensorColdSensorContactSensorDoorbellTriggerFaceSensorGarageControlGasSensorHeatSensorHumidityInfoIlluminanceInfoLeakSensorLicensePlateSensorLightControlLockControlMotionSensorObjectSensorOccupancySensorPowerSensorProblemSensorPTZControlSecuritySystemSirenControlSmokeSensorSwitchControlTamperSensorTemperatureInfoVibrationSensor
Type Parameters
TProperties
TProperties extends object
Sensor-specific property interface (e.g., MotionSensorProperties)
TStorage
TStorage extends object = Record<string, any>
Persistent storage schema for per-sensor config
TCapability
TCapability extends string = string
Capability enum type (e.g., PTZCapability)
Implements
Constructors
Constructor
new Sensor<
TProperties,TStorage,TCapability>(name,options?):Sensor<TProperties,TStorage,TCapability>
Defined in: sensor/base.ts:258
Parameters
name
string
options?
Returns
Sensor<TProperties, TStorage, TCapability>
Properties
category
abstractreadonlycategory:SensorCategory
Defined in: sensor/base.ts:221
name
readonlyname:string
Defined in: sensor/base.ts:223
Implementation of
onAssignmentChanged
readonlyonAssignmentChanged:Observable<readonlystring[]>
Defined in: sensor/base.ts:250
Implementation of
SensorLike.onAssignmentChanged
onCapabilitiesChanged
readonlyonCapabilitiesChanged:Observable<TCapability[]>
Defined in: sensor/base.ts:242
Implementation of
SensorLike.onCapabilitiesChanged
onConnectedChanged
readonlyonConnectedChanged:Observable<boolean>
Defined in: sensor/base.ts:252
Implementation of
onPropertyChanged
readonlyonPropertyChanged:Observable<PropertyChangeOf<TProperties>>
Defined in: sensor/base.ts:240
Implementation of
type
abstractreadonlytype:SensorType
Defined in: sensor/base.ts:220
Implementation of
Accessors
assignedCameraIds
Get Signature
get assignedCameraIds(): readonly
string[]
Defined in: sensor/base.ts:293
Returns
readonly string[]
Implementation of
assignmentLocked
Get Signature
get assignmentLocked():
boolean
Defined in: sensor/base.ts:297
Returns
boolean
Implementation of
capabilities
Get Signature
get capabilities():
TCapability[]
Defined in: sensor/base.ts:316
Returns
TCapability[]
Set Signature
set capabilities(
value):void
Defined in: sensor/base.ts:321
Set capabilities, deduplicated, and notify backend plus local listeners.
Parameters
value
TCapability[]
Returns
void
Implementation of
connected
Get Signature
get connected():
boolean
Defined in: sensor/base.ts:289
Returns
boolean
Implementation of
displayName
Get Signature
get displayName():
string
Defined in: sensor/base.ts:281
Returns
string
Implementation of
id
Get Signature
get id():
string
Defined in: sensor/base.ts:269
Returns
string
Implementation of
isAssigned
Get Signature
get isAssigned():
boolean
Defined in: sensor/base.ts:285
Returns
boolean
nativeId
Get Signature
get nativeId():
string|undefined
Defined in: sensor/base.ts:273
Returns
string | undefined
Implementation of
origin
Get Signature
get origin():
string|undefined
Defined in: sensor/base.ts:277
Returns
string | undefined
pluginId
Get Signature
get pluginId():
string|undefined
Defined in: sensor/base.ts:301
Returns
string | undefined
Implementation of
props
Get Signature
get
protectedprops():Readonly<TProperties>
Defined in: sensor/base.ts:546
Returns
Readonly<TProperties>
storage
Get Signature
get storage():
DeviceStorage<TStorage>
Defined in: sensor/base.ts:305
Returns
DeviceStorage<TStorage>
storageSchema
Get Signature
get storageSchema():
JsonSchema[]
Defined in: sensor/base.ts:312
Returns
Methods
getValue()
Call Signature
getValue<
K>(property):TProperties[K] |undefined
Defined in: sensor/base.ts:345
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 string | number | symbol
Parameters
property
K
Returns
TProperties[K] | undefined
Implementation of
Call Signature
getValue(
property):unknown
Defined in: sensor/base.ts:346
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
Implementation of
SensorLike.getValue
getValues()
getValues():
Readonly<TProperties>
Defined in: sensor/base.ts:362
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);Implementation of
hasCapability()
hasCapability(
capability):boolean
Defined in: sensor/base.ts:388
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');Implementation of
onStart()
protectedonStart():void|Promise<void>
Defined in: sensor/base.ts:651
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);
}onStop()
protectedonStop():void|Promise<void>
Defined in: sensor/base.ts:664
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);
}setDisplayName()
setDisplayName(
value):void
Defined in: sensor/base.ts:337
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');updateModelSpec()
updateModelSpec():
void
Defined in: sensor/base.ts:565
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();
}updateValue()
abstractupdateValue(property,value):void|Promise<void>
Defined in: sensor/base.ts:374
Generic property write coming from a consumer. Read-only sensors implement it as a no-op, control sensors dispatch known properties to their semantic methods (setOn, setActive, setTargetState) so plugin overrides drive hardware. Unknown or non-writable properties are ignored.
Plugin authors call the semantic methods on the concrete class instead.
Parameters
property
string
value
unknown
Returns
void | Promise<void>