Skip to content

@camera.ui/sdk / sensor / MotionDetectorSensor

Abstract Class: MotionDetectorSensor<TStorage>

Defined in: sensor/motion.ts:149

Motion detector that receives video frames from the backend pipeline. Extend this class and implement detectMotion to analyze frames for motion. The backend calls detectMotion() at the configured frame interval, zone-filters the returned detections and applies them. detected is re-derived from the surviving detections, so a result with no detections reports no motion.

Extends

Type Parameters

TStorage

TStorage extends object = Record<string, any>

Constructors

Constructor

new MotionDetectorSensor<TStorage>(name?, options?): MotionDetectorSensor<TStorage>

Defined in: sensor/motion.ts:59

Parameters

name?

string = 'Motion Sensor'

options?

SensorOptions

Returns

MotionDetectorSensor<TStorage>

Inherited from

MotionSensor.constructor

Properties

_requiresFrames

_requiresFrames: boolean = true

Defined in: sensor/motion.ts:150

Overrides

MotionSensor._requiresFrames


category

readonly category: Sensor = SensorCategory.Sensor

Defined in: sensor/motion.ts:55

Inherited from

MotionSensor.category


name

readonly name: string

Defined in: sensor/base.ts:223

Inherited from

Sensor.name


onAssignmentChanged

readonly onAssignmentChanged: Observable<readonly string[]>

Defined in: sensor/base.ts:250

Inherited from

Sensor.onAssignmentChanged


onCapabilitiesChanged

readonly onCapabilitiesChanged: Observable<string[]>

Defined in: sensor/base.ts:242

Inherited from

MotionSensor.onCapabilitiesChanged


onConnectedChanged

readonly onConnectedChanged: Observable<boolean>

Defined in: sensor/base.ts:252

Inherited from

Sensor.onConnectedChanged


onPropertyChanged

readonly onPropertyChanged: Observable<PropertyChangeOf<MotionSensorProperties>>

Defined in: sensor/base.ts:240

Inherited from

MotionSensor.onPropertyChanged


type

readonly type: Motion = SensorType.Motion

Defined in: sensor/motion.ts:54

Inherited from

MotionSensor.type

Accessors

assignedCameraIds

Get Signature

get assignedCameraIds(): readonly string[]

Defined in: sensor/base.ts:293

Returns

readonly string[]

Inherited from

Sensor.assignedCameraIds


assignmentLocked

Get Signature

get assignmentLocked(): boolean

Defined in: sensor/base.ts:297

Returns

boolean

Inherited from

Sensor.assignmentLocked


blocked

Get Signature

get blocked(): boolean

Defined in: sensor/motion.ts:77

Returns

boolean

Inherited from

MotionSensor.blocked


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

Inherited from

MotionSensor.capabilities


connected

Get Signature

get connected(): boolean

Defined in: sensor/base.ts:289

Returns

boolean

Inherited from

Sensor.connected


detected

Get Signature

get detected(): boolean

Defined in: sensor/motion.ts:69

Returns

boolean

Inherited from

MotionSensor.detected


detections

Get Signature

get detections(): Detection[]

Defined in: sensor/motion.ts:73

Returns

Detection[]

Inherited from

MotionSensor.detections


displayName

Get Signature

get displayName(): string

Defined in: sensor/base.ts:281

Returns

string

Inherited from

Sensor.displayName


id

Get Signature

get id(): string

Defined in: sensor/base.ts:269

Returns

string

Inherited from

Sensor.id


isAssigned

Get Signature

get isAssigned(): boolean

Defined in: sensor/base.ts:285

Returns

boolean

Inherited from

VibrationSensor.isAssigned


nativeId

Get Signature

get nativeId(): string | undefined

Defined in: sensor/base.ts:273

Returns

string | undefined

Inherited from

Sensor.nativeId


origin

Get Signature

get origin(): string | undefined

Defined in: sensor/base.ts:277

Returns

string | undefined

Inherited from

VibrationSensor.origin


pluginId

Get Signature

get pluginId(): string | undefined

Defined in: sensor/base.ts:301

Returns

string | undefined

Inherited from

Sensor.pluginId


props

Get Signature

get protected props(): Readonly<TProperties>

Defined in: sensor/base.ts:546

Returns

Readonly<TProperties>

Inherited from

MotionSensor.props


storage

Get Signature

get storage(): DeviceStorage<TStorage>

Defined in: sensor/base.ts:305

Returns

DeviceStorage<TStorage>

Inherited from

MotionSensor.storage


storageSchema

Get Signature

get storageSchema(): JsonSchema[]

Defined in: sensor/base.ts:312

Returns

JsonSchema[]

Inherited from

VibrationSensor.storageSchema

Methods

clearDetections()

clearDetections(): void

Defined in: sensor/motion.ts:121

Explicitly clear motion state (detected = false, detections = []).

Returns

void

Example

ts
sensor.clearDetections();

Inherited from

MotionSensor.clearDetections


detectMotion()

abstract detectMotion(frame): Promise<MotionResult>

Defined in: sensor/motion.ts:153

Analyze a single video frame for motion. Called by the backend at the configured interval.

Parameters

frame

VideoFrameData

Returns

Promise<MotionResult>


getValue()

Call Signature

getValue<K>(property): MotionSensorProperties[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 keyof MotionSensorProperties

Parameters
property

K

Returns

MotionSensorProperties[K] | undefined

Inherited from

MotionSensor.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

Inherited from

MotionSensor.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);

Inherited from

MotionSensor.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');

Inherited from

MotionSensor.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);
}

Inherited from

MotionSensor.onStart


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);
}

Inherited from

MotionSensor.onStop


reportDetections()

reportDetections(detected, detections?): void

Defined in: sensor/motion.ts:104

Report a motion detection result.

  • reportDetections(true): motion detected without bbox (e.g. Ring camera). The SDK synthesizes a single full-frame 'motion' detection.
  • reportDetections(true, [...]): motion detected with explicit detections.
  • reportDetections(false): no motion (clears detections).

No-op while the sensor is blocked by backend dwell logic.

Parameters

detected

boolean

Whether motion is currently detected.

detections?

Detection[]

Optional explicit detections produced for this frame.

Returns

void

Example

ts
import type { Detection } from '@camera.ui/sdk';
sensor.reportDetections(true, [
  { label: 'motion', confidence: 0.85, box: { x: 0.1, y: 0.2, width: 0.3, height: 0.4 } } satisfies Detection,
]);
sensor.reportDetections(false);

Inherited from

MotionSensor.reportDetections


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');

Inherited from

MotionSensor.setDisplayName


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();
}

Inherited from

MotionSensor.updateModelSpec