Skip to content

@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

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?

SensorOptions

Returns

Sensor<TProperties, TStorage, TCapability>

Properties

category

abstract readonly category: SensorCategory

Defined in: sensor/base.ts:221


name

readonly name: string

Defined in: sensor/base.ts:223

Implementation of

SensorLike.name


onAssignmentChanged

readonly onAssignmentChanged: Observable<readonly string[]>

Defined in: sensor/base.ts:250

Implementation of

SensorLike.onAssignmentChanged


onCapabilitiesChanged

readonly onCapabilitiesChanged: Observable<TCapability[]>

Defined in: sensor/base.ts:242

Implementation of

SensorLike.onCapabilitiesChanged


onConnectedChanged

readonly onConnectedChanged: Observable<boolean>

Defined in: sensor/base.ts:252

Implementation of

SensorLike.onConnectedChanged


onPropertyChanged

readonly onPropertyChanged: Observable<PropertyChangeOf<TProperties>>

Defined in: sensor/base.ts:240

Implementation of

SensorLike.onPropertyChanged


type

abstract readonly type: SensorType

Defined in: sensor/base.ts:220

Implementation of

SensorLike.type

Accessors

assignedCameraIds

Get Signature

get assignedCameraIds(): readonly string[]

Defined in: sensor/base.ts:293

Returns

readonly string[]

Implementation of

SensorLike.assignedCameraIds


assignmentLocked

Get Signature

get assignmentLocked(): boolean

Defined in: sensor/base.ts:297

Returns

boolean

Implementation of

SensorLike.assignmentLocked


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

SensorLike.capabilities


connected

Get Signature

get connected(): boolean

Defined in: sensor/base.ts:289

Returns

boolean

Implementation of

SensorLike.connected


displayName

Get Signature

get displayName(): string

Defined in: sensor/base.ts:281

Returns

string

Implementation of

SensorLike.displayName


id

Get Signature

get id(): string

Defined in: sensor/base.ts:269

Returns

string

Implementation of

SensorLike.id


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

SensorLike.nativeId


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

SensorLike.pluginId


props

Get Signature

get protected props(): 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

JsonSchema[]

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

SensorLike.getValue

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

ts
const snapshot = sensor.getValues();
console.log(snapshot);

Implementation of

SensorLike.getValues


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

ts
const dimmable = sensor.hasCapability('brightness');

Implementation of

SensorLike.hasCapability


onStart()

protected onStart(): 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

ts
protected override onStart(): void {
  this._timer = setInterval(() => this.poll(), 5_000);
}

onStop()

protected onStop(): 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

ts
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

ts
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

typescript
async onStart(): Promise<void> {
  await this.loadModel();
  this.updateModelSpec();
}

updateValue()

abstract updateValue(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>

Implementation of

SensorLike.updateValue