@camera.ui/sdk / sensor / ClassifierDetectorSensor
Abstract Class: ClassifierDetectorSensor<TStorage> ​
Defined in: sensor/classifier.ts:152
Classifier detector that receives video frames from the backend pipeline. Extend this class and implement detectClassifications to run image classification models against trigger regions.
Extends ​
ClassifierSensor<TStorage>
Type Parameters ​
TStorage ​
TStorage extends object = Record<string, any>
Constructors ​
Constructor ​
new ClassifierDetectorSensor<
TStorage>(name?,options?):ClassifierDetectorSensor<TStorage>
Defined in: sensor/classifier.ts:57
Parameters ​
name? ​
string = 'Classifier'
options? ​
Returns ​
ClassifierDetectorSensor<TStorage>
Inherited from ​
Properties ​
_requiresFrames ​
_requiresFrames:
boolean=true
Defined in: sensor/classifier.ts:153
Overrides ​
ClassifierSensor._requiresFrames
category ​
readonlycategory:Sensor=SensorCategory.Sensor
Defined in: sensor/classifier.ts:53
Inherited from ​
name ​
readonlyname:string
Defined in: sensor/base.ts:238
Inherited from ​
onAssignmentChanged ​
readonlyonAssignmentChanged:Observable<readonlystring[]>
Defined in: sensor/base.ts:266
Inherited from ​
ClassifierSensor.onAssignmentChanged
onCapabilitiesChanged ​
readonlyonCapabilitiesChanged:Observable<string[]>
Defined in: sensor/base.ts:258
Inherited from ​
ClassifierSensor.onCapabilitiesChanged
onConnectedChanged ​
readonlyonConnectedChanged:Observable<boolean>
Defined in: sensor/base.ts:268
Inherited from ​
ClassifierSensor.onConnectedChanged
onPropertyChanged ​
readonlyonPropertyChanged:Observable<PropertyChangeOf<ClassifierSensorProperties>>
Defined in: sensor/base.ts:256
Inherited from ​
ClassifierSensor.onPropertyChanged
type ​
readonlytype:Classifier=SensorType.Classifier
Defined in: sensor/classifier.ts:52
Inherited from ​
Accessors ​
address ​
Get Signature ​
get address():
string|undefined
Defined in: sensor/base.ts:300
Returns ​
string | undefined
Inherited from ​
assignedCameraIds ​
Get Signature ​
get assignedCameraIds(): readonly
string[]
Defined in: sensor/base.ts:316
Returns ​
readonly string[]
Inherited from ​
ClassifierSensor.assignedCameraIds
assignmentLocked ​
Get Signature ​
get assignmentLocked():
boolean
Defined in: sensor/base.ts:320
Returns ​
boolean
Inherited from ​
ClassifierSensor.assignmentLocked
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
Inherited from ​
connected ​
Get Signature ​
get connected():
boolean
Defined in: sensor/base.ts:312
Returns ​
boolean
Inherited from ​
detected ​
Get Signature ​
get detected():
boolean
Defined in: sensor/classifier.ts:67
Returns ​
boolean
Inherited from ​
detections ​
Get Signature ​
get detections():
ClassifierDetection[]
Defined in: sensor/classifier.ts:71
Returns ​
Inherited from ​
displayName ​
Get Signature ​
get displayName():
string
Defined in: sensor/base.ts:304
Returns ​
string
Inherited from ​
id ​
Get Signature ​
get id():
string
Defined in: sensor/base.ts:284
Returns ​
string
Inherited from ​
isAssigned ​
Get Signature ​
get isAssigned():
boolean
Defined in: sensor/base.ts:308
Returns ​
boolean
Inherited from ​
labels ​
Get Signature ​
get labels():
string[]
Defined in: sensor/classifier.ts:75
Returns ​
string[]
Inherited from ​
modelSpec ​
Get Signature ​
get
abstractmodelSpec():ModelSpec
Defined in: sensor/classifier.ts:155
Returns ​
nativeId ​
Get Signature ​
get nativeId():
string|undefined
Defined in: sensor/base.ts:288
Returns ​
string | undefined
Inherited from ​
origin ​
Get Signature ​
get origin():
string|undefined
Defined in: sensor/base.ts:292
Returns ​
string | undefined
Inherited from ​
pluginId ​
Get Signature ​
get pluginId():
string|undefined
Defined in: sensor/base.ts:324
Returns ​
string | undefined
Inherited from ​
props ​
Get Signature ​
get
protectedprops():Readonly<TProperties>
Defined in: sensor/base.ts:558
Returns ​
Readonly<TProperties>
Inherited from ​
sourceState ​
Get Signature ​
get sourceState():
SensorSourceState|undefined
Defined in: sensor/base.ts:296
Returns ​
SensorSourceState | undefined
Inherited from ​
storage ​
Get Signature ​
get storage():
DeviceStorage<TStorage>
Defined in: sensor/base.ts:328
Returns ​
DeviceStorage<TStorage>
Inherited from ​
storageSchema ​
Get Signature ​
get storageSchema():
JsonSchema[]
Defined in: sensor/base.ts:335
Returns ​
Inherited from ​
ClassifierSensor.storageSchema
Methods ​
clearDetections() ​
clearDetections():
void
Defined in: sensor/classifier.ts:131
Explicitly clear classifier state (detected = false, detections = [], labels = []).
Returns ​
void
Example ​
sensor.clearDetections();Inherited from ​
ClassifierSensor.clearDetections
detectClassifications() ​
abstractdetectClassifications(frames):Promise<ClassifierResult[]>
Defined in: sensor/classifier.ts:163
Classify frames in batch. Each frame is pre-scaled to modelSpec.input: normally a trigger region cropped by the upstream object detector, but the whole scene when no decoded frame is available. Must return exactly one ClassifierResult per input frame, in the same order.
Parameters ​
frames ​
Returns ​
Promise<ClassifierResult[]>
getValue() ​
Call Signature ​
getValue<
K>(property):ClassifierSensorProperties[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 keyof ClassifierSensorProperties
Parameters ​
property ​
K
Returns ​
ClassifierSensorProperties[K] | undefined
Inherited from ​
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
Inherited from ​
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);Inherited from ​
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');Inherited from ​
ClassifierSensor.hasCapability
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);
}Inherited from ​
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);
}Inherited from ​
reportDetections() ​
reportDetections(
detected,detections?):void
Defined in: sensor/classifier.ts:106
Report classification results. Auto-derives detected and labels from the list.
reportDetections(true): generic classification trigger. The SDK synthesizes a single full-frame detection with empty attribute and sub-attribute.reportDetections(true, [...]): explicit classifier detections.reportDetections(false): clear.
Parameters ​
detected ​
boolean
Whether any classification result is active.
detections? ​
Optional explicit classifier detections to publish.
Returns ​
void
Example ​
import type { ClassifierDetection } from '@camera.ui/sdk';
sensor.reportDetections(true, [
{
label: 'animal',
confidence: 0.88,
box: { x: 0.1, y: 0.2, width: 0.3, height: 0.4 },
attribute: 'bird',
subAttribute: 'woodpecker',
} satisfies ClassifierDetection,
]);
sensor.reportDetections(false);Inherited from ​
ClassifierSensor.reportDetections
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);Inherited from ​
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');Inherited from ​
ClassifierSensor.setDisplayName
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');Inherited from ​
ClassifierSensor.setSourceState
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();
}