@camera.ui/sdk / sensor / Sensor
Abstract Class: Sensor<TProperties, TStorage, TCapability> ​
Defined in: sensor/base.ts:234
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 ​
AudioSensorBatteryInfoCarbonDioxideInfoCarbonMonoxideSensorClassifierSensorClipDetectorSensorColdSensorContactSensorDoorbellTriggerFaceSensorFaceEmbedderSensorGarageControlGasSensorHeatSensorHumidityInfoIlluminanceInfoLeakSensorLicensePlateSensorLightControlLockControlMotionSensorObjectSensorOccupancySensorPersonEmbedderSensorPowerSensorProblemSensorPTZControlSecuritySystemSegmenterSensorSirenControlSmokeSensorSwitchControlTamperSensorTemperatureInfoVibrationSensor
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:274
Parameters ​
name ​
string
options? ​
Returns ​
Sensor<TProperties, TStorage, TCapability>
Properties ​
category ​
abstractreadonlycategory:SensorCategory
Defined in: sensor/base.ts:236
name ​
readonlyname:string
Defined in: sensor/base.ts:238
Implementation of ​
onAssignmentChanged ​
readonlyonAssignmentChanged:Observable<readonlystring[]>
Defined in: sensor/base.ts:266
Implementation of ​
SensorLike.onAssignmentChanged
onCapabilitiesChanged ​
readonlyonCapabilitiesChanged:Observable<TCapability[]>
Defined in: sensor/base.ts:258
Implementation of ​
SensorLike.onCapabilitiesChanged
onConnectedChanged ​
readonlyonConnectedChanged:Observable<boolean>
Defined in: sensor/base.ts:268
Implementation of ​
onPropertyChanged ​
readonlyonPropertyChanged:Observable<PropertyChangeOf<TProperties>>
Defined in: sensor/base.ts:256
Implementation of ​
type ​
abstractreadonlytype:SensorType
Defined in: sensor/base.ts:235
Implementation of ​
Accessors ​
address ​
Get Signature ​
get address():
string|undefined
Defined in: sensor/base.ts:300
Returns ​
string | undefined
assignedCameraIds ​
Get Signature ​
get assignedCameraIds(): readonly
string[]
Defined in: sensor/base.ts:316
Returns ​
readonly string[]
Implementation of ​
assignmentLocked ​
Get Signature ​
get assignmentLocked():
boolean
Defined in: sensor/base.ts:320
Returns ​
boolean
Implementation of ​
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
Implementation of ​
connected ​
Get Signature ​
get connected():
boolean
Defined in: sensor/base.ts:312
Returns ​
boolean
Implementation of ​
displayName ​
Get Signature ​
get displayName():
string
Defined in: sensor/base.ts:304
Returns ​
string
Implementation of ​
id ​
Get Signature ​
get id():
string
Defined in: sensor/base.ts:284
Returns ​
string
Implementation of ​
isAssigned ​
Get Signature ​
get isAssigned():
boolean
Defined in: sensor/base.ts:308
Returns ​
boolean
nativeId ​
Get Signature ​
get nativeId():
string|undefined
Defined in: sensor/base.ts:288
Returns ​
string | undefined
Implementation of ​
origin ​
Get Signature ​
get origin():
string|undefined
Defined in: sensor/base.ts:292
Returns ​
string | undefined
pluginId ​
Get Signature ​
get pluginId():
string|undefined
Defined in: sensor/base.ts:324
Returns ​
string | undefined
Implementation of ​
props ​
Get Signature ​
get
protectedprops():Readonly<TProperties>
Defined in: sensor/base.ts:558
Returns ​
Readonly<TProperties>
sourceState ​
Get Signature ​
get sourceState():
SensorSourceState|undefined
Defined in: sensor/base.ts:296
Returns ​
SensorSourceState | undefined
storage ​
Get Signature ​
get storage():
DeviceStorage<TStorage>
Defined in: sensor/base.ts:328
Returns ​
DeviceStorage<TStorage>
storageSchema ​
Get Signature ​
get storageSchema():
JsonSchema[]
Defined in: sensor/base.ts:335
Returns ​
Methods ​
getValue() ​
Call Signature ​
getValue<
K>(property):TProperties[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 string | number | symbol
Parameters ​
property ​
K
Returns ​
TProperties[K] | undefined
Implementation of ​
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
Implementation of ​
SensorLike.getValue
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);Implementation of ​
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');Implementation of ​
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);
}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);
}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);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');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');updateModelSpec() ​
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();
}updateValue() ​
abstractupdateValue(property,value):void|Promise<void>
Defined in: sensor/base.ts:397
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>