@camera.ui/sdk / sensor / MotionDetectorSensor
Abstract Class: MotionDetectorSensor<TStorage>
Defined in: sensor/motion.ts:162
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 and applies the returned result to the sensor.
Extends
MotionSensor<TStorage>
Type Parameters
TStorage
TStorage extends object = Record<string, any>
Constructors
Constructor
new MotionDetectorSensor<
TStorage>(name?):MotionDetectorSensor<TStorage>
Defined in: sensor/motion.ts:61
Parameters
name?
string = 'Motion Sensor'
Returns
MotionDetectorSensor<TStorage>
Inherited from
Properties
_requiresFrames
_requiresFrames:
boolean=true
Defined in: sensor/motion.ts:163
Overrides
category
readonlycategory:Sensor=SensorCategory.Sensor
Defined in: sensor/motion.ts:57
Inherited from
id
readonlyid:string
Defined in: sensor/base.ts:190
Inherited from
name
readonlyname:string
Defined in: sensor/base.ts:189
Inherited from
onAssignmentChanged
readonlyonAssignmentChanged:Observable<boolean>
Defined in: sensor/base.ts:209
Inherited from
ClipDetectorSensor.onAssignmentChanged
onCapabilitiesChanged
readonlyonCapabilitiesChanged:Observable<string[]>
Defined in: sensor/base.ts:200
Observable for capability changes. Emits the full capabilities array when capabilities change.
Inherited from
MotionSensor.onCapabilitiesChanged
onPropertyChanged
readonlyonPropertyChanged:Observable<PropertyChangeOf<MotionSensorProperties>>
Defined in: sensor/base.ts:198
Observable for property changes. Emits { property, value, timestamp } when any property changes.
Inherited from
MotionSensor.onPropertyChanged
type
readonlytype:Motion=SensorType.Motion
Defined in: sensor/motion.ts:56
Inherited from
Accessors
blocked
Get Signature
get blocked():
boolean
Defined in: sensor/motion.ts:82
Whether the sensor is currently blocked. Read-only — set by the backend dwell logic, not by plugin code.
Returns
boolean
Inherited from
cameraId
Get Signature
get cameraId():
string
Defined in: sensor/base.ts:257
Camera ID this sensor belongs to. Throws if sensor not yet added to a camera.
Returns
string
Inherited from
capabilities
Get Signature
get capabilities():
TCapability[]
Defined in: sensor/base.ts:277
Optional feature flags advertised by this sensor (e.g., PTZ pan/tilt/zoom)
Returns
TCapability[]
Set Signature
set capabilities(
value):void
Defined in: sensor/base.ts:282
Set capabilities and notify the backend. Automatically deduplicates.
Parameters
value
TCapability[]
Returns
void
Inherited from
detected
Get Signature
get detected():
boolean
Defined in: sensor/motion.ts:72
Whether motion is currently detected.
Returns
boolean
Inherited from
detections
Get Signature
get detections():
Detection[]
Defined in: sensor/motion.ts:77
Current detection list.
Returns
Inherited from
displayName
Get Signature
get displayName():
string
Defined in: sensor/base.ts:233
Returns
string
Inherited from
isAssigned
Get Signature
get isAssigned():
boolean
Defined in: sensor/base.ts:252
Whether this sensor has been assigned to a camera in the backend
Returns
boolean
Inherited from
pluginId
Get Signature
get pluginId():
string|undefined
Defined in: sensor/base.ts:264
Returns
string | undefined
Inherited from
props
Get Signature
get
protectedprops():Readonly<TProperties>
Defined in: sensor/base.ts:295
Read-only access to the internal property store. Subclasses use this to read current state when implementing semantic methods (e.g., if (this.blocked) return).
Returns
Readonly<TProperties>
Inherited from
storage
Get Signature
get storage():
DeviceStorage<TStorage>
Defined in: sensor/base.ts:269
Per-sensor persistent storage. Throws if sensor not yet added to a camera.
Returns
DeviceStorage<TStorage>
Inherited from
storageSchema
Get Signature
get storageSchema():
JsonSchema[]
Defined in: sensor/base.ts:216
Override to provide a JSON schema for per-sensor storage settings UI
Returns
Inherited from
ClipDetectorSensor.storageSchema
Methods
clearDetections()
clearDetections():
void
Defined in: sensor/motion.ts:126
Explicitly clear motion state (detected = false, detections = []).
Returns
void
Example
sensor.clearDetections();Inherited from
detectMotion()
abstractdetectMotion(frame):Promise<MotionResult>
Defined in: sensor/motion.ts:166
Analyze a single video frame for motion. Called by the backend at the configured interval.
Parameters
frame
Returns
Promise<MotionResult>
getValue()
Call Signature
getValue<
K>(property):MotionSensorProperties[K] |undefined
Defined in: sensor/base.ts:303
Get the current value of a sensor property. Type-safe via the generic overload — call with a property enum value to get a properly typed result.
Type Parameters
K
K extends keyof MotionSensorProperties
Parameters
property
K
Returns
MotionSensorProperties[K] | undefined
Inherited from
Call Signature
getValue(
property):unknown
Defined in: sensor/base.ts:304
Get the current value of a sensor property. Type-safe via the generic overload — call with a property enum value to get a properly typed result.
Parameters
property
string
Returns
unknown
Inherited from
getValues()
getValues():
Readonly<TProperties>
Defined in: sensor/base.ts:320
Get a read-only snapshot of all property values.
Returns
Readonly<TProperties>
Frozen view of every property currently held by the sensor.
Example
const snapshot = sensor.getValues();
console.log(snapshot);Inherited from
hasCapability()
hasCapability(
capability):boolean
Defined in: sensor/base.ts:423
Parameters
capability
string
Returns
boolean
Inherited from
onAssigned()
protectedonAssigned():void|Promise<void>
Defined in: sensor/base.ts:473
Lifecycle hook: the sensor just became assigned to a camera. Override to start background work that should only run while this sensor is live — polling loops, event subscriptions, timers, external connections.
Called AFTER cameraId, storage, and RPC channels are wired up, so the override can safely access this.cameraId, this.storage, and publish properties via the semantic helper methods.
Errors thrown here are caught and logged — they will NOT break assignment bookkeeping. If your work can fail, handle it inside the override.
Paired 1:1 with onDeassigned — for every onAssigned call there is exactly one matching onDeassigned later (on deassignment or cleanup).
Default: no-op. Most sensors don't need lifecycle hooks.
Returns
void | Promise<void>
Example
protected override async onAssigned(): Promise<void> {
this._timer = setInterval(() => this.poll(), 5_000);
}Inherited from
onDeassigned()
protectedonDeassigned():void|Promise<void>
Defined in: sensor/base.ts:493
Lifecycle hook: the sensor is being deassigned. Override to tear down whatever was started in onAssigned — clear timers, close subscriptions, release external resources.
Always called exactly once for each prior onAssigned. Also called from _cleanup if the sensor is being removed while still assigned, so you can rely on this as the single teardown point.
Default: no-op.
Returns
void | Promise<void>
Example
protected override onDeassigned(): void {
if (this._timer) clearInterval(this._timer);
}Inherited from
reportDetections()
reportDetections(
detected,detections?):void
Defined in: sensor/motion.ts:109
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?
Optional explicit detections produced for this frame.
Returns
void
Example
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
setDisplayName()
setDisplayName(
value):void
Defined in: sensor/base.ts:247
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');