Sensors¶
Typed detection sensors (motion, object, face, license-plate, audio, classifier, clip) and smart-home sensors (contact, doorbell, lock, garage, light, switch, ptz, security system, environmental).
camera_ui_sdk.sensor ¶
AudioDetectorSensor ¶
Bases: AudioSensor[TStorage], Generic[TStorage]
Audio detector that receives audio frames from the backend pipeline.
Extend this class and implement detectAudio and modelSpec. The
backend resamples and buffers audio to match modelSpec before each
call.
AudioFrameData ¶
Bases: TypedDict
Audio frame data delivered to audio detector sensors by the backend pipeline.
AudioResult ¶
Bases: TypedDict
Return type for AudioDetectorSensor.detectAudio().
AudioSensor ¶
Bases: Sensor[AudioSensorProperties, TStorage, str], Generic[TStorage]
Audio sensor that reports audio events and decibel levels.
Plugin authors call reportDetections(list) to push detected audio events
(auto-derives detected) and setDecibels(value) to update the audio level.
reportDetections ¶
Report detected audio events.
reportDetections(True)— audio detected without specifics. The SDK synthesizes a single full-frame'audio'detection.reportDetections(True, [...])— audio detected with explicit detections.reportDetections(False)— clear.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detected
|
bool
|
Whether an audio event is currently detected. |
required |
detections
|
list[Detection] | None
|
Optional explicit detections produced for this event. |
None
|
clearDetections ¶
Explicitly clear audio detection state (detected = False, detections = []).
setDecibels ¶
updateValue
async
¶
Read-only sensor: external writes are ignored.
Sensor ¶
Bases: ABC, Generic[TProperties, TStorage, TCapability]
Abstract base class for all sensors. Plugins extend this (or use specialized subclasses like MotionSensor, LightControl, etc.) to implement sensor logic.
storage_schema
property
¶
Override to provide a JSON schema for per-sensor storage settings UI.
storage
property
¶
Per-sensor persistent storage. Raises if not yet added to a camera.
onAssignmentChanged
property
¶
Observable for assignment state changes (sensor added/removed from camera).
onPropertyChanged
property
¶
Observable for property changes.
onCapabilitiesChanged
property
¶
Observable for capability changes. Emits the full capabilities array when capabilities change.
on_assigned ¶
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 self.cameraId, self.storage,
and publish properties via the semantic helper methods.
May be either a plain def or an async def. If async, the SDK
schedules it on the running event loop (fire-and-forget). Errors are
caught and swallowed — they will NOT break assignment bookkeeping.
Paired 1:1 with on_deassigned — for every on_assigned call
there is exactly one matching on_deassigned later (on deassignment
or cleanup).
Default: no-op. Most sensors don't need lifecycle hooks.
on_deassigned ¶
Lifecycle hook: the sensor is being deassigned.
Override to tear down whatever was started in on_assigned — clear
timers, close subscriptions, release external resources.
Always called exactly once for each prior on_assigned. Also called
from _cleanup if the sensor is being removed while still assigned,
so you can rely on this as the single teardown point.
May be either a plain def or an async def. See on_assigned
for scheduling semantics.
Default: no-op.
getValues ¶
updateValue
abstractmethod
async
¶
External-consumer entry point that satisfies the SensorLike.updateValue
contract. Each concrete sensor class implements this — read-only sensors
leave it as a no-op, control sensors dispatch known properties to the
appropriate semantic methods (setOn, setActive, setTargetState, ...)
so plugin overrides drive hardware. Unknown / non-writable properties are
silently ignored.
Plugin authors must not call this — they should call the semantic methods directly on the concrete sensor class.
SensorCategory ¶
Bases: str, Enum
Categorizes a sensor's role in the system.
SensorLike ¶
Bases: Protocol
Read-only proxy interface for a sensor. Use this type when consuming sensors, not creating them.
All state-modifying methods (setOn, reportDetections, etc.) live on the
concrete sensor classes, not on SensorLike. Code that holds a SensorLike
reference can only READ state and observe changes.
updateValue
async
¶
Write a property generically. Cross-process bridges (e.g. HomeKit) bind
generic property names to UI characteristics and call this on a sensor
proxy — the proxy forwards via RPC to the owning sensor, where control
sensor classes (Light, Siren, etc.) override updateValue to dispatch
to the appropriate semantic method (setOn, setActive, ...). This means
plugin-side hardware-action overrides ARE honored end-to-end.
Plugin authors must not call this — they should call the semantic methods directly on the concrete sensor class.
SensorPropertyChangeData ¶
Bases: TypedDict
Emitted on the onPropertyChanged Observable.
SensorType ¶
Bases: str, Enum
Type of sensor. Each maps to a smart-home concept (HomeKit service).
BatteryCapability ¶
BatteryInfo ¶
Bases: Sensor[BatteryInfoProperties, TStorage, BatteryCapability], Generic[TStorage]
Battery info sensor. Reports battery level, charging state, and low-battery alerts.
Plugin authors call setLevel(value), setCharging(state), and setLow(value)
to push updates from the device.
setLevel ¶
setCharging ¶
Report the current charging state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ChargingState
|
Current charging state from the |
required |
setLow ¶
updateValue
async
¶
Read-only sensor: external writes are ignored.
ChargingState ¶
ClassifierDetection ¶
ClassifierDetectorSensor ¶
Bases: ClassifierSensor[TStorage], Generic[TStorage]
Classifier detector that receives video frames from the backend pipeline.
Extend this class and implement detectClassifications to run image
classification models against trigger regions.
modelSpec
abstractmethod
property
¶
Declares the expected input dimensions and trigger labels. The backend scales frames to match.
detectClassifications
abstractmethod
async
¶
Classify frames in batch. Each frame is a pre-cropped, pre-scaled trigger region produced by the upstream object detector. Must return exactly one ClassifierResult per input frame, in the same order.
ClassifierResult ¶
Bases: TypedDict
Return type for ClassifierDetectorSensor.detectClassifications().
ClassifierSensor ¶
Bases: Sensor[ClassifierSensorProperties, TStorage, str], Generic[TStorage]
General-purpose image classifier sensor.
Plugin authors call reportDetections(list) to push classification results.
detected and labels are auto-derived from the detection list.
reportDetections ¶
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:
| Name | Type | Description | Default |
|---|---|---|---|
detected
|
bool
|
Whether any classification result is active. |
required |
detections
|
list[ClassifierDetection] | None
|
Optional explicit classifier detections to publish. |
None
|
clearDetections ¶
Explicitly clear classifier state (detected = False, detections = [], labels = []).
updateValue
async
¶
Read-only sensor: external writes are ignored.
ClipDetectorSensor ¶
Bases: Sensor[dict[str, Any], TStorage, str], Generic[TStorage]
CLIP detector sensor that receives video frames and generates semantic embeddings.
Extend this class and implement detectEmbeddings to produce CLIP
embeddings for downstream semantic search.
modelSpec
abstractmethod
property
¶
Declares the expected input dimensions and trigger labels.
detectEmbeddings
abstractmethod
async
¶
Generate CLIP embeddings in batch. Each frame is a pre-cropped, pre-scaled trigger region
produced by the upstream object detector. Must return exactly one ClipResult per input
frame, in the same order. Use frame['label'] to tag the emitted embedding.
updateValue
async
¶
Frame-only sensor: no externally writable properties.
ClipEmbedding ¶
Bases: TypedDict
A CLIP embedding result for a detected region.
ClipResult ¶
Bases: TypedDict
Return type for ClipDetectorSensor.detectEmbeddings().
ContactSensor ¶
BoundingBox ¶
Bases: TypedDict
Bounding box of a detection.
All coordinates are normalized to 0-1 (fraction of frame dimensions), so they are independent of resolution.
Detection ¶
Bases: TypedDict
A single detection result emitted by any detection sensor.
VideoFrameData ¶
Bases: TypedDict
Video frame data delivered to detector sensors by the backend pipeline.
The backend handles capture, decoding, and scaling — detectors only need to process the pixel payload.
DoorbellTrigger ¶
Bases: Sensor[DoorbellTriggerProperties, TStorage, str], Generic[TStorage]
Doorbell trigger sensor.
Plugin authors call trigger() to fire a doorbell event. The ring property
is set to True and automatically reset to False after a short delay
(RING_AUTO_RESET_MS). Calling trigger() again while still ringing
resets the timer (extends the ring phase).
trigger ¶
updateValue
async
¶
Cross-process consumer entry point. Writing ring=true (any
truthy value) dispatches to trigger() so a UI test button or
external automation can fire the doorbell using the same flow as a
real hardware ring (auto-reset included). Writing ring=false is
ignored — the auto-reset timer owns the off transition.
FaceDetection ¶
FaceDetectorSensor ¶
Bases: FaceSensor[TStorage], Generic[TStorage]
Face detector that receives video frames from the backend pipeline.
Extend this class and implement detectFaces for face detection and
recognition.
modelSpec
abstractmethod
property
¶
Declares the expected input dimensions and trigger labels. The backend scales frames to match.
detectFaces
abstractmethod
async
¶
Detect faces in batch. Each frame is a pre-cropped, pre-scaled person region produced by the upstream object detector. Must return exactly one FaceResult per input frame, in the same order.
FaceResult ¶
Bases: TypedDict
Return type for FaceDetectorSensor.detectFaces().
FaceSensor ¶
Bases: Sensor[FaceSensorProperties, TStorage, str], Generic[TStorage]
Face sensor that reports detected faces and optional identity matches.
Plugin authors call reportDetections(list) to push detected faces.
detected is auto-derived from the detection list.
reportDetections ¶
Report detected faces.
reportDetections(True)— face detected without specifics (e.g. a bare face-event from a discovery provider). The SDK synthesizes a single full-frame face detection without identity.reportDetections(True, [...])— explicit face detections with identity, embedding, and/or thumbnail.reportDetections(False)— clear.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detected
|
bool
|
Whether any face is currently detected. |
required |
detections
|
list[FaceDetection] | None
|
Optional explicit face detections to publish. |
None
|
clearDetections ¶
Explicitly clear face detection state (detected = False, detections = []).
updateValue
async
¶
Read-only sensor: external writes are ignored.
GarageControl ¶
Bases: Sensor[GarageControlProperties, TStorage, str], Generic[TStorage]
Garage door control.
Override setTargetState() to drive hardware and call
await super().setTargetState(value) once the hardware confirms — the base
implementation updates both targetState and currentState.
For long-running transitions (Opening/Closing intermediate states) override
setTargetState and write currentState separately as the door moves.
setTargetState
async
¶
Set the target state. Override to drive hardware and call
await super().setTargetState(value) after success — the base implementation
syncs both targetState and currentState to the new value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
GarageState
|
Desired target state from the |
required |
setCurrentState ¶
Publish the actual door state. Use this to drive long-running
transitions (e.g. Open → Closing → Closed) independently of the
user-requested target state. Read-only from cross-process consumers
(updateValue ignores it).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
GarageState
|
Current physical door state from the |
required |
setObstructionDetected ¶
Publish the obstruction-detected state. Read-only from the consumer
side (updateValue ignores it) — plugin code calls this when its
hardware reports an obstruction sensor change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
bool
|
True when an obstruction is currently detected. |
required |
updateValue
async
¶
Routes generic property writes to semantic methods.
GarageState ¶
Bases: IntEnum
Garage door states (HomeKit-compatible values).
HumidityInfo ¶
Bases: Sensor[HumidityInfoProperties, TStorage, str], Generic[TStorage]
Humidity info sensor. Reports current relative humidity in %.
LeakSensor ¶
LicensePlateDetection ¶
LicensePlateDetectorSensor ¶
Bases: LicensePlateSensor[TStorage], Generic[TStorage]
License plate detector that receives video frames from the backend pipeline.
Extend this class and implement detectLicensePlates for plate detection
and OCR.
modelSpec
abstractmethod
property
¶
Declares the expected input dimensions and trigger labels. The backend scales frames to match.
detectLicensePlates
abstractmethod
async
¶
Detect license plates in batch. Each frame is a pre-cropped, pre-scaled vehicle region produced by the upstream object detector. Must return exactly one LicensePlateResult per input frame, in the same order.
LicensePlateResult ¶
Bases: TypedDict
Return type for LicensePlateDetectorSensor.detectLicensePlates().
LicensePlateSensor ¶
Bases: Sensor[LicensePlateSensorProperties, TStorage, str], Generic[TStorage]
License plate sensor that reports detected plates with OCR text.
Plugin authors call reportDetections(list) to push detected plates.
detected is auto-derived from the detection list.
reportDetections ¶
Report detected license plates.
reportDetections(True)— plate detected without specifics. The SDK synthesizes a single full-frame detection with empty plateText.reportDetections(True, [...])— explicit plate detections with OCR text.reportDetections(False)— clear.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detected
|
bool
|
Whether any license plate is currently detected. |
required |
detections
|
list[LicensePlateDetection] | None
|
Optional explicit plate detections to publish. |
None
|
clearDetections ¶
Explicitly clear license plate state (detected = False, detections = []).
updateValue
async
¶
Read-only sensor: external writes are ignored. State is reported via reportDetections.
LightCapability ¶
Bases: str, Enum
Optional capabilities for light controls.
Brightness
class-attribute
instance-attribute
¶
Light supports brightness adjustment (0–100).
LightControl ¶
Bases: Sensor[LightControlProperties, TStorage, LightCapability], Generic[TStorage]
Light control sensor. Override setOn()/setOff() to drive your
hardware, then await super().setOn() / await super().setOff() to
sync the SDK state.
Plugins that have no hardware-action use case can leave the methods unoverridden — the base implementation just updates the state.
For hardware-pushed updates (someone manually flipped the switch), call
super().setOn() / super().setOff() from your event handler — that
bypasses any plugin override and only syncs state.
setOn
async
¶
setOff
async
¶
setBrightness
async
¶
Set brightness. Override to drive hardware and call
await super().setBrightness(value) after the hardware call
succeeds. The default implementation clamps the value to [0, 100].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int
|
Brightness level in the range 0–100. |
required |
updateValue
async
¶
Routes generic property writes to semantic methods.
LockControl ¶
Bases: Sensor[LockControlProperties, TStorage, str], Generic[TStorage]
Lock control.
Override setTargetState() to drive hardware and call
await super().setTargetState(value) once the hardware confirms — the base
implementation updates both targetState and currentState to the new value.
For asymmetric flows (long-running unlock with intermediate state) override
setTargetState and write currentState separately when transitions complete.
setTargetState
async
¶
Set the target state. Override to drive hardware and call
await super().setTargetState(value) after success — the base implementation
syncs both targetState and currentState to the new value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
LockState
|
Desired lock state from the |
required |
setCurrentState ¶
Publish the actual lock state. Use this to drive transitions where
the physical state diverges from the user-requested target — e.g.
motorized smart locks that take time to rotate (publish Unknown
while moving), or hardware reporting an out-of-band state change.
Read-only from cross-process consumers (updateValue ignores it).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
LockState
|
Current physical lock state from the |
required |
updateValue
async
¶
Routes generic property writes to semantic methods.
LockState ¶
Bases: IntEnum
Lock states (HomeKit-compatible values).
MotionDetectorSensor ¶
Bases: MotionSensor[TStorage], Generic[TStorage]
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.
detectMotion
abstractmethod
async
¶
Analyze a single video frame for motion. Called by the backend at the configured interval.
MotionResult ¶
Bases: TypedDict
Return type for MotionDetectorSensor.detectMotion().
MotionSensor ¶
Bases: Sensor[MotionSensorProperties, TStorage, str], Generic[TStorage]
Motion sensor that reports motion state and detection results.
Plugin authors call reportDetections(list) to push detection results.
detected is auto-derived from the detection list. blocked is read-only
and is set by the backend (dwell logic) — reportDetections() becomes a
no-op while the sensor is blocked.
blocked
property
¶
Whether the sensor is currently blocked. Read-only — set by the backend dwell logic, not by plugin code.
reportDetections ¶
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:
| Name | Type | Description | Default |
|---|---|---|---|
detected
|
bool
|
Whether motion is currently detected. |
required |
detections
|
list[Detection] | None
|
Optional explicit detections produced for this frame. |
None
|
clearDetections ¶
Explicitly clear motion state (detected = False, detections = []).
updateValue
async
¶
Read-only sensor: external writes are ignored. State is reported via reportDetections.
ObjectDetectorSensor ¶
Bases: ObjectSensor[TStorage], Generic[TStorage]
Object detector that receives video frames from the backend pipeline.
Extend this class and implement detectObjects and modelSpec. The
backend scales frames to match modelSpec.input dimensions before each
call.
ObjectResult ¶
Bases: TypedDict
Return type for ObjectDetectorSensor.detectObjects().
ObjectSensor ¶
Bases: Sensor[ObjectSensorProperties, TStorage, str], Generic[TStorage]
Object detection sensor that reports detected objects (person, vehicle, animal, etc.).
Plugin authors call reportDetections(list) to push detection results.
detected and labels are auto-derived from the detection list.
reportDetections ¶
Report detected objects. Auto-derives detected and labels
from the list.
reportDetections(True)— something detected without specific data. The SDK synthesizes a single full-frame'motion'detection as a generic fallback.reportDetections(True, [...])— explicit detections (typical case).reportDetections(False)— clear.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detected
|
bool
|
Whether any object is currently detected. |
required |
detections
|
list[TrackedDetection] | None
|
Optional explicit object detections (with optional tracking metadata). |
None
|
clearDetections ¶
Explicitly clear detection state (detected = False, detections = [], labels = []).
updateValue
async
¶
Read-only sensor: external writes are ignored. State is reported via reportDetections.
TrackedDetection ¶
OccupancySensor ¶
PTZCapability ¶
Bases: str, Enum
Optional capabilities for PTZ controls.
PTZControl ¶
Bases: Sensor[PTZControlProperties, TStorage, PTZCapability], Generic[TStorage]
Pan-tilt-zoom camera control.
Override setPosition() / setVelocity() / setTargetPreset() to drive
hardware, then call the corresponding super().X() method after success to
sync the SDK state. For hardware-pushed state updates (e.g. PTZ position
change events), call the super methods from your event handler — that
bypasses any plugin override and only syncs state.
Set capabilities to advertise supported axes and features. Use
setPresets() to publish the discovered preset list and setMoving() to
publish movement state.
setPosition
async
¶
Move to an absolute pan/tilt/zoom position. Override to drive hardware
and call await super().setPosition(value) after success to sync the SDK state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
PTZPosition
|
Absolute pan/tilt/zoom target position. |
required |
setVelocity
async
¶
Continuous-move command. Override to drive hardware and call
await super().setVelocity(value) after success to sync the SDK state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
PTZDirection | None
|
Per-axis speeds in |
required |
setTargetPreset
async
¶
setPresets ¶
setMoving ¶
goHome
async
¶
updateValue
async
¶
Routes generic property writes to semantic methods.
moving and presets are observed/discovered state and not externally
writable; only Position, Velocity, and TargetPreset may be set.
PTZDirection ¶
Bases: TypedDict
PTZ movement speed for continuous move commands.
Speeds are in normalized range [-1, 1] where:
-1= maximum speed in negative direction0= stop movement1= maximum speed in positive direction
Conventions: positive panSpeed = right, positive tiltSpeed = up,
positive zoomSpeed = zoom in. Plugins should clamp values to [-1, 1]
and map them to hardware-specific speeds.
PTZPosition ¶
Bases: TypedDict
Absolute PTZ position.
SecuritySystem ¶
Bases: Sensor[SecuritySystemProperties, TStorage, str], Generic[TStorage]
Security system control.
Override setTargetState() to drive hardware and call
await super().setTargetState(value) once the hardware confirms — the base
implementation updates both targetState and currentState.
setTargetState
async
¶
Set the target state. Override to drive hardware and call
await super().setTargetState(value) after success — the base implementation
syncs both targetState and currentState to the new value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
SecuritySystemState
|
Desired armed/disarmed state from |
required |
setCurrentState ¶
Publish the actual security system state. Use this to drive
transitions that diverge from the user-requested target — most notably
the AlarmTriggered state when an intruder is detected, or
arming-delay intermediate states. Read-only from cross-process
consumers (updateValue ignores it).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
SecuritySystemState
|
Current security system state from |
required |
updateValue
async
¶
Routes generic property writes to semantic methods.
SecuritySystemState ¶
Bases: IntEnum
Security system arm/disarm states (HomeKit-compatible values).
SirenCapability ¶
Bases: str, Enum
Optional capabilities for siren controls.
Volume
class-attribute
instance-attribute
¶
Siren supports volume adjustment (0–100).
SirenControl ¶
Bases: Sensor[SirenControlProperties, TStorage, SirenCapability], Generic[TStorage]
Siren control sensor. Override setActive()/setInactive() to drive
your hardware, then await super().setActive() / await super().setInactive()
to sync the SDK state. For hardware-pushed updates, call the super methods
from your event handler — that bypasses any plugin override and only syncs
state.
SmokeSensor ¶
AudioInputSpec ¶
Bases: TypedDict
Expected audio input format for an audio detector model.
AudioModelSpec ¶
Bases: TypedDict
Model spec for audio detectors.
ModelSpec ¶
Bases: TypedDict
Model spec for detectors with fixed output labels (face, classifier, license plate).
Declares the input shape the backend should produce and the trigger labels that should activate this detector.
ObjectModelSpec ¶
Bases: TypedDict
Model spec for object detectors.
Only declares input dimensions — the output label set is dynamic and comes from the model itself.
VideoInputSpec ¶
Bases: TypedDict
Expected video input dimensions and pixel format for a detector model.
SwitchControl ¶
Bases: Sensor[SwitchControlProperties, TStorage, str], Generic[TStorage]
Generic on/off switch control. Override setOn() / setOff() to drive
hardware and call await super().setOn() / await super().setOff() after
success to sync the SDK state. For hardware-pushed updates, call the super
methods from your event handler — that bypasses any plugin override and only
syncs state.