Skip to content

Sensors

Detection sensors (motion, object, face, license-plate, audio, classifier, clip) and smart-home sensors (contact, doorbell, lock, garage, light, switch, PTZ, security system, environmental). Plus the sensor-level model specs and shared detection types (Detection, BoundingBox, TrackedDetection).

Note

The reference below is auto-generated from Go doc comments via gomarkdoc. Re-run scripts/gen-api-docs.sh to refresh it.

type AudioDetector

AudioDetector is implemented by plugins that classify audio events. The runtime resamples and buffers audio to match ModelSpec before each call.

type AudioDetector interface {
    // ModelSpec declares the expected audio input format.
    ModelSpec() AudioModelSpec
    // DetectAudio analyzes a single audio frame and returns the audio result.
    DetectAudio(audio AudioFrameData) (*AudioResult, error)
}

type AudioDetectorSensor

AudioDetectorSensor is an audio sensor that consumes audio frames from the backend pipeline. Pair with an AudioDetector implementation.

type AudioDetectorSensor struct {
    AudioSensor
}

func NewAudioDetectorSensor

func NewAudioDetectorSensor(name string, opts ...SensorOption) *AudioDetectorSensor

NewAudioDetectorSensor creates an audio detector sensor with the given name and options.

type AudioFormat

AudioFormat identifies the sample format of an audio buffer.

type AudioFormat string

Supported audio sample formats.

const (
    AudioFormatPCM16   AudioFormat = "pcm16"   // 16-bit signed integer PCM
    AudioFormatFloat32 AudioFormat = "float32" // 32-bit float
)

type AudioFrameData

AudioFrameData is audio frame data delivered to audio detector sensors by the backend pipeline.

type AudioFrameData struct {
    CameraID   string      `msgpack:"cameraId" json:"cameraId"`     // Camera the frame originated from
    Data       []byte      `msgpack:"data" json:"data"`             // Raw audio sample buffer
    SampleRate int         `msgpack:"sampleRate" json:"sampleRate"` // Sample rate of the buffer in Hz
    Channels   int         `msgpack:"channels" json:"channels"`     // Channel count of the buffer (typically 1 = mono)
    Format     AudioFormat `msgpack:"format" json:"format"`         // Sample format: pcm16 = 16-bit signed integer PCM, float32 = 32-bit float
    Decibels   float64     `msgpack:"decibels" json:"decibels"`     // Pre-computed decibel level for this frame, if available
    Timestamp  int64       `msgpack:"timestamp" json:"timestamp"`   // Capture timestamp in milliseconds since epoch
}

type AudioLabel

AudioLabel is one of the built-in audio labels, or any custom string emitted by an audio detector.

type AudioLabel = string

type AudioModelSpec

AudioModelSpec describes an audio detection model.

type AudioModelSpec struct {
    ModelRuntime `msgpack:",inline"`
    Input        AudioInputSpec `msgpack:"input" json:"input"` // Required input audio format
}

type AudioResult

AudioResult is the return value of AudioDetector.DetectAudio.

type AudioResult struct {
    Detected   bool        `msgpack:"detected" json:"detected"`     // Whether an audio event is detected in this frame
    Detections []Detection `msgpack:"detections" json:"detections"` // Detections emitted for this frame
    Decibels   float64     `msgpack:"decibels" json:"decibels"`     // Optional decibel level computed for this frame
}

type AudioSensor

AudioSensor reports audio events and decibel levels.

Plugin authors call ReportDetections to push detected audio events (the detected flag is auto-derived from the list) and SetDecibels to publish the audio level.

type AudioSensor struct {
    BaseSensor
}

func NewAudioSensor

func NewAudioSensor(name string, opts ...SensorOption) *AudioSensor

NewAudioSensor creates an audio sensor with the given name and options.

func (*AudioSensor) ClearDetections

func (s *AudioSensor) ClearDetections()

ClearDetections explicitly clears audio detection state (detected = false, detections = []).

func (*AudioSensor) GetCategory

func (s *AudioSensor) GetCategory() SensorCategory

func (*AudioSensor) GetDecibels

func (s *AudioSensor) GetDecibels() float64

func (*AudioSensor) GetDetections

func (s *AudioSensor) GetDetections() []Detection

func (*AudioSensor) GetType

func (s *AudioSensor) GetType() SensorType

func (*AudioSensor) IsDetected

func (s *AudioSensor) IsDetected() bool

func (*AudioSensor) ReportDetections

func (s *AudioSensor) ReportDetections(detected bool, detections []Detection)

ReportDetections reports detected audio events.

  • ReportDetections(true, nil): audio detected without specifics. The SDK synthesizes a single full-frame "audio" detection.
  • ReportDetections(true, [...]): audio detected with explicit detections.
  • ReportDetections(false, nil): clear.

Example:

sensor.ReportDetections(true, []Detection{
    {Label: "glass_break", Confidence: 0.91, Box: &BoundingBox{X: 0, Y: 0, Width: 1, Height: 1}},
})
sensor.ReportDetections(false, nil)

func (*AudioSensor) SetDecibels

func (s *AudioSensor) SetDecibels(value float64)

SetDecibels updates the current audio level (in decibels).

Example:

sensor.SetDecibels(72)

func (*AudioSensor) ToJSON

func (s *AudioSensor) ToJSON() sensorJSON

func (*AudioSensor) UpdateValue

func (s *AudioSensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type BaseSensor

BaseSensor is the base struct for all sensors. Embed this in concrete sensor types.

Sensors are standalone entities: the plugin supplies the durable identity (WithNativeID), 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.

type BaseSensor struct {
    // contains filtered or unexported fields
}

func NewBaseSensor

func NewBaseSensor(name string, opts ...SensorOption) BaseSensor

NewBaseSensor creates the embedded base for a concrete sensor type. The id it assigns is provisional until the host registers the sensor, and Storage stays nil until then.

Example:

type MySensor struct{ sdk.BaseSensor }

s := &MySensor{BaseSensor: sdk.NewBaseSensor("Front Door", sdk.WithNativeID("dev-1"))}

func (*BaseSensor) AssignmentLocked

func (s *BaseSensor) AssignmentLocked() bool

func (*BaseSensor) Connected

func (s *BaseSensor) Connected() bool

func (*BaseSensor) GetAssignedCameraIDs

func (s *BaseSensor) GetAssignedCameraIDs() []string

func (*BaseSensor) GetCapabilities

func (s *BaseSensor) GetCapabilities() []string

func (*BaseSensor) GetDisplayName

func (s *BaseSensor) GetDisplayName() string

func (*BaseSensor) GetID

func (s *BaseSensor) GetID() string

func (*BaseSensor) GetName

func (s *BaseSensor) GetName() string

func (*BaseSensor) GetNativeID

func (s *BaseSensor) GetNativeID() string

func (*BaseSensor) GetPluginID

func (s *BaseSensor) GetPluginID() string

func (*BaseSensor) GetValue

func (s *BaseSensor) GetValue(property string) any

func (*BaseSensor) GetValues

func (s *BaseSensor) GetValues() map[string]any

func (*BaseSensor) HasCapability

func (s *BaseSensor) HasCapability(cap string) bool

HasCapability reports whether the sensor advertises the given capability.

Example:

dimmable := sensor.HasCapability(sdk.LightCapabilityBrightness)

func (*BaseSensor) IsAssigned

func (s *BaseSensor) IsAssigned() bool

func (*BaseSensor) OnAssignmentChanged

func (s *BaseSensor) OnAssignmentChanged(callback func([]string)) *Disposable

OnAssignmentChanged fires with the current camera id list whenever the user changes this sensor's camera assignments.

func (*BaseSensor) OnCapabilitiesChanged

func (s *BaseSensor) OnCapabilitiesChanged(callback func([]string)) *Disposable

OnCapabilitiesChanged returns a Disposable that fires when capabilities change.

func (*BaseSensor) OnConnectedChanged

func (s *BaseSensor) OnConnectedChanged(callback func(bool)) *Disposable

OnConnectedChanged fires when the sensor's registration state changes.

func (*BaseSensor) OnPropertyChanged

func (s *BaseSensor) OnPropertyChanged(callback func(SensorPropertyChange)) *Disposable

OnPropertyChanged subscribes to property changes. Returns a Disposable to unsubscribe.

func (*BaseSensor) SetCapabilities

func (s *BaseSensor) SetCapabilities(caps []string)

SetCapabilities replaces the advertised feature flags and notifies the backend plus local listeners.

Example:

sensor.SetCapabilities([]string{sdk.LightCapabilityBrightness})

func (*BaseSensor) SetDisplayName

func (s *BaseSensor) SetDisplayName(name string)

SetDisplayName sets the display name (the only mutable identifier on a sensor). name is the human-readable label shown in the UI.

Example:

sensor.SetDisplayName("Front Door Motion")

func (*BaseSensor) Storage

func (s *BaseSensor) Storage() *DeviceStorage

type BatteryInfo

BatteryInfo reports battery level, charging state, and low-battery alerts.

Plugin authors call SetLevel, SetCharging, and SetLow to push updates from the device.

type BatteryInfo struct{ BaseSensor }

func NewBatteryInfo

func NewBatteryInfo(name string, opts ...SensorOption) *BatteryInfo

NewBatteryInfo creates a battery info sensor with the given name and options.

func (*BatteryInfo) GetCategory

func (s *BatteryInfo) GetCategory() SensorCategory

func (*BatteryInfo) GetCharging

func (s *BatteryInfo) GetCharging() ChargingState

func (*BatteryInfo) GetLevel

func (s *BatteryInfo) GetLevel() int

func (*BatteryInfo) GetType

func (s *BatteryInfo) GetType() SensorType

func (*BatteryInfo) IsLow

func (s *BatteryInfo) IsLow() bool

func (*BatteryInfo) SetCharging

func (s *BatteryInfo) SetCharging(value ChargingState)

SetCharging sets the charging state.

Example:

battery.SetCharging(ChargingStateCharging)

func (*BatteryInfo) SetLevel

func (s *BatteryInfo) SetLevel(value int)

SetLevel reports a new battery level percentage, clamped to [0,100].

Example:

battery.SetLevel(87)

func (*BatteryInfo) SetLow

func (s *BatteryInfo) SetLow(value bool)

SetLow sets the low-battery alert flag.

Example:

battery.SetLow(true)

func (*BatteryInfo) ToJSON

func (s *BatteryInfo) ToJSON() sensorJSON

func (*BatteryInfo) UpdateValue

func (s *BatteryInfo) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type BoundingBox

BoundingBox is the bounding box of a detection. All coordinates are normalized to 0-1 (fraction of frame dimensions), so they are independent of resolution.

type BoundingBox struct {
    X      float64 `msgpack:"x" json:"x"`           // X coordinate of the top-left corner (0-1)
    Y      float64 `msgpack:"y" json:"y"`           // Y coordinate of the top-left corner (0-1)
    Width  float64 `msgpack:"width" json:"width"`   // Width as a fraction of frame width (0-1)
    Height float64 `msgpack:"height" json:"height"` // Height as a fraction of frame height (0-1)
}

type ChargingState

ChargingState defines battery charging states.

type ChargingState string

const (
    ChargingStateNotCharging   ChargingState = "NOT_CHARGING"   // Battery is not charging
    ChargingStateNotChargeable ChargingState = "NOT_CHARGEABLE" // Device has no rechargeable battery
    ChargingStateCharging      ChargingState = "CHARGING"       // Battery is currently charging
    ChargingStateFull          ChargingState = "FULL"           // Battery is fully charged
)

type ClassifierDetection

ClassifierDetection is a classifier detection result with an open attribute for classifier categories. The Attribute field of the embedded Detection holds the classifier category (e.g. "bird", "delivery").

type ClassifierDetection struct {
    Detection
    SubAttribute string `msgpack:"subAttribute" json:"subAttribute"` // Classifier sub-category (e.g. "woodpecker", "amazon")
}

type ClassifierDetector

ClassifierDetector is implemented by plugins that run image classification models against pre-cropped trigger regions.

type ClassifierDetector interface {
    // ModelSpec declares the expected input dimensions and trigger labels. The
    // runtime scales frames to match.
    ModelSpec() ModelSpec
    // DetectClassifications classifies a batch of frames, each 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.
    DetectClassifications(frames []VideoFrameData) ([]ClassifierResult, error)
}

type ClassifierDetectorSensor

ClassifierDetectorSensor is a classifier sensor that consumes video frames from the backend pipeline. Pair with a ClassifierDetector implementation.

type ClassifierDetectorSensor struct {
    ClassifierSensor
}

func NewClassifierDetectorSensor

func NewClassifierDetectorSensor(name string, opts ...SensorOption) *ClassifierDetectorSensor

NewClassifierDetectorSensor creates a classifier detector sensor with the given name and options.

type ClassifierResult

ClassifierResult is the return value of ClassifierDetector.DetectClassifications.

type ClassifierResult struct {
    Detected   bool                  `msgpack:"detected" json:"detected"`     // Whether any classification result is emitted for this frame
    Detections []ClassifierDetection `msgpack:"detections" json:"detections"` // Detections emitted for this frame
}

type ClassifierSensor

ClassifierSensor reports classification results from image analysis.

Plugin authors call ReportDetections to push classification results. The detected flag and labels are auto-derived from the detection list.

type ClassifierSensor struct{ BaseSensor }

func NewClassifierSensor

func NewClassifierSensor(name string, opts ...SensorOption) *ClassifierSensor

NewClassifierSensor creates a classifier sensor with the given name and options.

func (*ClassifierSensor) ClearDetections

func (s *ClassifierSensor) ClearDetections()

ClearDetections explicitly clears classifier state (detected = false, detections = [], labels = []).

func (*ClassifierSensor) GetCategory

func (s *ClassifierSensor) GetCategory() SensorCategory

func (*ClassifierSensor) GetDetections

func (s *ClassifierSensor) GetDetections() []ClassifierDetection

func (*ClassifierSensor) GetLabels

func (s *ClassifierSensor) GetLabels() []string

func (*ClassifierSensor) GetType

func (s *ClassifierSensor) GetType() SensorType

func (*ClassifierSensor) IsDetected

func (s *ClassifierSensor) IsDetected() bool

func (*ClassifierSensor) ReportDetections

func (s *ClassifierSensor) ReportDetections(detected bool, detections []ClassifierDetection)

ReportDetections reports classification results. The detected flag and labels are auto-derived from the detection list.

  • ReportDetections(true, nil): generic classification trigger. The SDK synthesizes a single full-frame detection with empty attribute and sub-attribute.
  • ReportDetections(true, [...]): explicit classifier detections.
  • ReportDetections(false, nil): clear.

Example:

sensor.ReportDetections(true, []ClassifierDetection{
    {Detection: Detection{Label: "animal", Confidence: 0.88, Box: &BoundingBox{X: 0.1, Y: 0.2, Width: 0.3, Height: 0.4}, Attribute: "bird"}, SubAttribute: "woodpecker"},
})
sensor.ReportDetections(false, nil)

func (*ClassifierSensor) ToJSON

func (s *ClassifierSensor) ToJSON() sensorJSON

func (*ClassifierSensor) UpdateValue

func (s *ClassifierSensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type ClipDetector

ClipDetector is implemented by plugins that generate CLIP embeddings for downstream semantic search.

type ClipDetector interface {
    // ModelSpec declares the expected input dimensions and trigger labels.
    ModelSpec() ModelSpec
    // DetectEmbeddings produces CLIP embeddings for a batch of frames, each
    // 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 ClipResult per input frame, in the
    // same order; use VideoFrameData.Label to tag the emitted embedding.
    DetectEmbeddings(frames []VideoFrameData) ([]ClipResult, error)
}

type ClipDetectorSensor

ClipDetectorSensor is a frame-only sensor that generates CLIP embeddings from video frames. Pair with a ClipDetector implementation.

type ClipDetectorSensor struct{ BaseSensor }

func NewClipDetectorSensor

func NewClipDetectorSensor(name string, opts ...SensorOption) *ClipDetectorSensor

NewClipDetectorSensor creates a CLIP detector sensor with the given name and options.

func (*ClipDetectorSensor) GetCategory

func (s *ClipDetectorSensor) GetCategory() SensorCategory

func (*ClipDetectorSensor) GetType

func (s *ClipDetectorSensor) GetType() SensorType

func (*ClipDetectorSensor) ToJSON

func (s *ClipDetectorSensor) ToJSON() sensorJSON

func (*ClipDetectorSensor) UpdateValue

func (s *ClipDetectorSensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type ClipEmbedding

ClipEmbedding is a CLIP embedding result for a detected region.

type ClipEmbedding struct {
    Label     string      `msgpack:"label" json:"label"`         // Detection label this embedding was computed for (e.g. "person", "vehicle")
    Box       BoundingBox `msgpack:"box" json:"box"`             // Bounding box of the detected region in normalized coordinates
    Embedding []float64   `msgpack:"embedding" json:"embedding"` // CLIP embedding vector
}

type ClipResult

ClipResult is the return value of ClipDetector.DetectEmbeddings.

type ClipResult struct {
    Embeddings     []ClipEmbedding `msgpack:"embeddings" json:"embeddings"`         // Embeddings emitted for this frame
    EmbeddingModel string          `msgpack:"embeddingModel" json:"embeddingModel"` // Identifier of the embedding model used to produce the vectors
}

type ContactSensor

ContactSensor reports door/window open-close state.

type ContactSensor struct{ BaseSensor }

func NewContactSensor

func NewContactSensor(name string, opts ...SensorOption) *ContactSensor

NewContactSensor creates a contact sensor with the given name and options.

func (*ContactSensor) GetCategory

func (s *ContactSensor) GetCategory() SensorCategory

func (*ContactSensor) GetType

func (s *ContactSensor) GetType() SensorType

func (*ContactSensor) IsDetected

func (s *ContactSensor) IsDetected() bool

func (*ContactSensor) SetDetected

func (s *ContactSensor) SetDetected(detected bool)

SetDetected reports contact state (true = open, false = closed).

Example:

contact.SetDetected(true)

func (*ContactSensor) ToJSON

func (s *ContactSensor) ToJSON() sensorJSON

func (*ContactSensor) UpdateValue

func (s *ContactSensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type Detection

Detection is a single detection result emitted by any detection sensor.

type Detection struct {
    Label      string       `msgpack:"label" json:"label"`                             // Detection label (e.g. "person", "vehicle")
    Confidence float64      `msgpack:"confidence" json:"confidence"`                   // Confidence score in the range 0-1
    Box        *BoundingBox `msgpack:"box,omitempty" json:"box,omitempty"`             // Bounding box in normalized coordinates
    Attribute  string       `msgpack:"attribute,omitempty" json:"attribute,omitempty"` // Optional sub-detection attribute (face, license_plate, or classifier-specific)
}

type DetectionAttribute

DetectionAttribute identifies the kind of a sub-detection (face, license plate, ...).

type DetectionAttribute = string

type DetectionLabel

DetectionLabel is a label identifying a type of detection.

type DetectionLabel = string

type DoorbellTrigger

DoorbellTrigger fires doorbell ring events.

Plugin authors call Trigger to fire an event. The ring property is set to true and automatically reset to false after ringAutoResetMs.

type DoorbellTrigger struct {
    BaseSensor
    // contains filtered or unexported fields
}

func NewDoorbellTrigger

func NewDoorbellTrigger(name string, opts ...SensorOption) *DoorbellTrigger

NewDoorbellTrigger creates a doorbell trigger with the given name and options.

func (*DoorbellTrigger) GetCategory

func (s *DoorbellTrigger) GetCategory() SensorCategory

func (*DoorbellTrigger) GetType

func (s *DoorbellTrigger) GetType() SensorType

func (*DoorbellTrigger) IsRinging

func (s *DoorbellTrigger) IsRinging() bool

func (*DoorbellTrigger) ToJSON

func (s *DoorbellTrigger) ToJSON() sensorJSON

func (*DoorbellTrigger) Trigger

func (s *DoorbellTrigger) Trigger()

Trigger fires a doorbell ring event. Sets ring to true and auto-resets after ringAutoResetMs. Re-triggering while ringing resets the timer (extends the ring phase).

Example:

doorbell.Trigger()

func (*DoorbellTrigger) UpdateValue

func (s *DoorbellTrigger) UpdateValue(property string, value any) error

UpdateValue routes generic property writes to the semantic setters. Writing ring=false is ignored, the auto-reset timer owns the off transition.

type FaceDetection

FaceDetection is a face detection result, extending Detection with face-specific fields. The Attribute field of the embedded Detection is fixed to "face".

type FaceDetection struct {
    Detection
    Identity  string    `msgpack:"identity,omitempty" json:"identity,omitempty"`   // Recognized identity name, if matched against known faces
    Embedding []float64 `msgpack:"embedding,omitempty" json:"embedding,omitempty"` // Face embedding vector for recognition/comparison
    Thumbnail []byte    `msgpack:"thumbnail,omitempty" json:"thumbnail,omitempty"` // JPEG thumbnail crop of the detected face
}

type FaceDetector

FaceDetector is implemented by plugins that perform face detection and recognition.

type FaceDetector interface {
    // ModelSpec declares the expected input dimensions and trigger labels. The
    // runtime scales frames to match.
    ModelSpec() ModelSpec
    // DetectFaces analyzes a batch of frames, each scaled to ModelSpec().Input:
    // normally a person region cropped by the upstream object detector, but the
    // whole scene when no decoded frame is available. Must return exactly one
    // FaceResult per input frame, in the same order.
    DetectFaces(frames []VideoFrameData) ([]FaceResult, error)
}

type FaceDetectorSensor

FaceDetectorSensor is a face sensor that consumes video frames from the backend pipeline. Pair with a FaceDetector implementation.

type FaceDetectorSensor struct {
    FaceSensor
}

func NewFaceDetectorSensor

func NewFaceDetectorSensor(name string, opts ...SensorOption) *FaceDetectorSensor

NewFaceDetectorSensor creates a face detector sensor with the given name and options.

type FaceResult

FaceResult is the return value of FaceDetector.DetectFaces.

type FaceResult struct {
    Detected   bool            `msgpack:"detected" json:"detected"`     // Whether any face is detected in this frame
    Detections []FaceDetection `msgpack:"detections" json:"detections"` // Detections emitted for this frame
}

type FaceSensor

FaceSensor reports detected faces and optional identity matches.

Plugin authors call ReportDetections to push detected faces. The detected flag is auto-derived from the detection list.

type FaceSensor struct{ BaseSensor }

func NewFaceSensor

func NewFaceSensor(name string, opts ...SensorOption) *FaceSensor

NewFaceSensor creates a face sensor with the given name and options.

func (*FaceSensor) ClearDetections

func (s *FaceSensor) ClearDetections()

ClearDetections explicitly clears face detection state (detected = false, detections = []).

func (*FaceSensor) GetCategory

func (s *FaceSensor) GetCategory() SensorCategory

func (*FaceSensor) GetDetections

func (s *FaceSensor) GetDetections() []FaceDetection

func (*FaceSensor) GetIdentities

func (s *FaceSensor) GetIdentities() []string

GetIdentities returns the names of the faces recognized during the active detection phase.

func (*FaceSensor) GetType

func (s *FaceSensor) GetType() SensorType

func (*FaceSensor) IsDetected

func (s *FaceSensor) IsDetected() bool

func (*FaceSensor) ReportDetections

func (s *FaceSensor) ReportDetections(detected bool, detections []FaceDetection)

ReportDetections reports detected faces.

  • ReportDetections(true, nil): face detected without specifics. The SDK synthesizes a single full-frame face detection without identity.
  • ReportDetections(true, [...]): explicit face detections with identity, embedding, and/or thumbnail.
  • ReportDetections(false, nil): clear.

Example:

sensor.ReportDetections(true, []FaceDetection{
    {Detection: Detection{Label: "person", Confidence: 0.94, Box: &BoundingBox{X: 0.4, Y: 0.2, Width: 0.15, Height: 0.25}, Attribute: "face"}, Identity: "Alice"},
})
sensor.ReportDetections(false, nil)

func (*FaceSensor) ToJSON

func (s *FaceSensor) ToJSON() sensorJSON

func (*FaceSensor) UpdateValue

func (s *FaceSensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type GarageControl

GarageControl is a garage door control sensor. Override SetTargetState (by embedding GarageControl in your own type and shadowing the method) to drive hardware and call the embedded GarageControl's SetTargetState 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.

type GarageControl struct{ BaseSensor }

func NewGarageControl

func NewGarageControl(name string, opts ...SensorOption) *GarageControl

NewGarageControl creates a garage door control with the given name and options.

func (*GarageControl) GetCategory

func (s *GarageControl) GetCategory() SensorCategory

func (*GarageControl) GetCurrentState

func (s *GarageControl) GetCurrentState() GarageState

func (*GarageControl) GetTargetState

func (s *GarageControl) GetTargetState() GarageState

func (*GarageControl) GetType

func (s *GarageControl) GetType() SensorType

func (*GarageControl) IsObstructionDetected

func (s *GarageControl) IsObstructionDetected() bool

func (*GarageControl) SetCurrentState

func (s *GarageControl) SetCurrentState(value GarageState)

SetCurrentState publishes the actual door state. Use this to drive long-running transitions (Open, then Closing, then Closed) independently of the user-requested target state. Read-only from cross-process consumers, UpdateValue ignores it.

Example:

garage.SetCurrentState(GarageStateClosing)

func (*GarageControl) SetObstructionDetected

func (s *GarageControl) SetObstructionDetected(detected bool)

SetObstructionDetected publishes the obstruction-detected state. Read-only from cross-process consumers, UpdateValue ignores it.

Example:

garage.SetObstructionDetected(true)

func (*GarageControl) SetTargetState

func (s *GarageControl) SetTargetState(value GarageState)

SetTargetState sets the target state. Writes both targetState and currentState.

Example:

garage.SetTargetState(GarageStateOpen)

func (*GarageControl) ToJSON

func (s *GarageControl) ToJSON() sensorJSON

func (*GarageControl) UpdateValue

func (s *GarageControl) UpdateValue(property string, value any) error

UpdateValue routes generic property writes to the semantic setters. Only targetState is externally writable.

type GarageState

GarageState defines garage door states.

type GarageState int

const (
    GarageStateOpen    GarageState = 0 // Door is fully open
    GarageStateClosed  GarageState = 1 // Door is fully closed
    GarageStateOpening GarageState = 2 // Door is moving towards open
    GarageStateClosing GarageState = 3 // Door is moving towards closed
    GarageStateStopped GarageState = 4 // Door stopped part-way
)

type HumidityInfo

HumidityInfo reports current relative humidity (0-100%).

type HumidityInfo struct{ BaseSensor }

func NewHumidityInfo

func NewHumidityInfo(name string, opts ...SensorOption) *HumidityInfo

func (*HumidityInfo) GetCategory

func (s *HumidityInfo) GetCategory() SensorCategory

func (*HumidityInfo) GetCurrent

func (s *HumidityInfo) GetCurrent() float64

func (*HumidityInfo) GetType

func (s *HumidityInfo) GetType() SensorType

func (*HumidityInfo) SetCurrent

func (s *HumidityInfo) SetCurrent(value float64)

SetCurrent sets the current relative humidity (clamped to [0,100]).

Example:

humidity.SetCurrent(63)

func (*HumidityInfo) ToJSON

func (s *HumidityInfo) ToJSON() sensorJSON

func (*HumidityInfo) UpdateValue

func (s *HumidityInfo) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type LeakSensor

LeakSensor reports water leak detection state.

type LeakSensor struct{ BaseSensor }

func NewLeakSensor

func NewLeakSensor(name string, opts ...SensorOption) *LeakSensor

func (*LeakSensor) GetCategory

func (s *LeakSensor) GetCategory() SensorCategory

func (*LeakSensor) GetType

func (s *LeakSensor) GetType() SensorType

func (*LeakSensor) IsDetected

func (s *LeakSensor) IsDetected() bool

func (*LeakSensor) SetDetected

func (s *LeakSensor) SetDetected(detected bool)

SetDetected reports leak detection state (true when a water leak is currently detected).

Example:

leak.SetDetected(true)

func (*LeakSensor) ToJSON

func (s *LeakSensor) ToJSON() sensorJSON

func (*LeakSensor) UpdateValue

func (s *LeakSensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type LicensePlateDetection

LicensePlateDetection is a license plate detection result, extending Detection with OCR fields. The Attribute field of the embedded Detection is fixed to "license_plate".

type LicensePlateDetection struct {
    Detection
    PlateText     string  `msgpack:"plateText" json:"plateText"`                             // Recognized plate text (e.g. "ABC 1234")
    OcrConfidence float64 `msgpack:"ocrConfidence,omitempty" json:"ocrConfidence,omitempty"` // Average text recognition confidence (0-1), separate from the box confidence
}

type LicensePlateDetector

LicensePlateDetector is implemented by plugins that perform license plate detection and OCR.

type LicensePlateDetector interface {
    // ModelSpec declares the expected input dimensions and trigger labels. The
    // runtime scales frames to match.
    ModelSpec() ModelSpec
    // DetectLicensePlates analyzes a batch of frames pre-scaled to the ModelSpec
    // input: normally a vehicle region cropped by the upstream object detector,
    // but the whole scene when no decoded frame is available. Must return exactly
    // one result per input frame, in the same order.
    DetectLicensePlates(frames []VideoFrameData) ([]LicensePlateResult, error)
}

type LicensePlateDetectorSensor

LicensePlateDetectorSensor is a license plate sensor that consumes video frames from the backend pipeline. Pair with a LicensePlateDetector implementation.

type LicensePlateDetectorSensor struct {
    LicensePlateSensor
}

func NewLicensePlateDetectorSensor

func NewLicensePlateDetectorSensor(name string, opts ...SensorOption) *LicensePlateDetectorSensor

type LicensePlateResult

LicensePlateResult is the return value of LicensePlateDetector.DetectLicensePlates.

type LicensePlateResult struct {
    Detected   bool                    `msgpack:"detected" json:"detected"`     // Whether any license plate is detected in this frame
    Detections []LicensePlateDetection `msgpack:"detections" json:"detections"` // Detections emitted for this frame
}

type LicensePlateSensor

LicensePlateSensor reports detected license plates and OCR results.

Plugin authors call ReportDetections to push detected plates. The detected flag is auto-derived from the detection list.

type LicensePlateSensor struct{ BaseSensor }

func NewLicensePlateSensor

func NewLicensePlateSensor(name string, opts ...SensorOption) *LicensePlateSensor

func (*LicensePlateSensor) ClearDetections

func (s *LicensePlateSensor) ClearDetections()

ClearDetections explicitly clears license plate state (detected = false, detections = []).

func (*LicensePlateSensor) GetCategory

func (s *LicensePlateSensor) GetCategory() SensorCategory

func (*LicensePlateSensor) GetDetections

func (s *LicensePlateSensor) GetDetections() []LicensePlateDetection

func (*LicensePlateSensor) GetPlates

func (s *LicensePlateSensor) GetPlates() []string

GetPlates returns the plate texts recognized during the active detection phase.

func (*LicensePlateSensor) GetType

func (s *LicensePlateSensor) GetType() SensorType

func (*LicensePlateSensor) IsDetected

func (s *LicensePlateSensor) IsDetected() bool

func (*LicensePlateSensor) ReportDetections

func (s *LicensePlateSensor) ReportDetections(detected bool, detections []LicensePlateDetection)

ReportDetections reports detected license plates.

  • ReportDetections(true, nil): 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, nil): clear.

Example:

sensor.ReportDetections(true, []LicensePlateDetection{
    {Detection: Detection{Label: "vehicle", Confidence: 0.93, Box: &BoundingBox{X: 0.2, Y: 0.5, Width: 0.2, Height: 0.08}, Attribute: "license_plate"}, PlateText: "ABC 1234"},
})
sensor.ReportDetections(false, nil)

func (*LicensePlateSensor) ToJSON

func (s *LicensePlateSensor) ToJSON() sensorJSON

func (*LicensePlateSensor) UpdateValue

func (s *LicensePlateSensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type LightControl

LightControl is a light on/off and brightness control sensor. Override SetOn / SetOff (by embedding LightControl in your own type and shadowing the methods) to drive your hardware, then call the embedded LightControl's methods to sync the SDK state.

Plugins with 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 the embedded LightControl's SetOn / SetOff directly from your event handler. That bypasses any plugin override and only syncs state.

type LightControl struct{ BaseSensor }

func NewLightControl

func NewLightControl(name string, opts ...SensorOption) *LightControl

func (*LightControl) GetBrightness

func (s *LightControl) GetBrightness() int

func (*LightControl) GetCategory

func (s *LightControl) GetCategory() SensorCategory

func (*LightControl) GetType

func (s *LightControl) GetType() SensorType

func (*LightControl) IsOn

func (s *LightControl) IsOn() bool

func (*LightControl) SetBrightness

func (s *LightControl) SetBrightness(value int)

SetBrightness sets the brightness level (clamped to [0, 100]). Override (via embedding) to drive hardware and call the embedded LightControl's SetBrightness to sync the SDK state.

Example:

light.SetBrightness(75)

func (*LightControl) SetOff

func (s *LightControl) SetOff()

SetOff turns the light off. Override (via embedding) to drive hardware and call the embedded LightControl's SetOff to sync the SDK state.

Example:

light.SetOff()

func (*LightControl) SetOn

func (s *LightControl) SetOn()

SetOn turns the light on. Override (via embedding) to drive hardware and call the embedded LightControl's SetOn to sync the SDK state.

Example:

light.SetOn()

func (*LightControl) ToJSON

func (s *LightControl) ToJSON() sensorJSON

func (*LightControl) UpdateValue

func (s *LightControl) UpdateValue(property string, value any) error

UpdateValue routes generic property writes to the semantic setters. Only on and brightness are externally writable.

type LockControl

LockControl is a lock/unlock control sensor. Override SetTargetState (by embedding LockControl in your own type and shadowing the method) to drive hardware and call the embedded LockControl's SetTargetState 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.

type LockControl struct{ BaseSensor }

func NewLockControl

func NewLockControl(name string, opts ...SensorOption) *LockControl

func (*LockControl) GetCategory

func (s *LockControl) GetCategory() SensorCategory

func (*LockControl) GetCurrentState

func (s *LockControl) GetCurrentState() LockState

func (*LockControl) GetTargetState

func (s *LockControl) GetTargetState() LockState

func (*LockControl) GetType

func (s *LockControl) GetType() SensorType

func (*LockControl) SetCurrentState

func (s *LockControl) SetCurrentState(value LockState)

SetCurrentState publishes the actual lock state. Use it when the physical state diverges from the requested target: motorized locks that take time to rotate (publish LockStateUnknown while moving), or hardware reporting an out-of-band state change. Read-only from cross-process consumers (UpdateValue ignores it).

Example:

lock.SetCurrentState(LockStateUnknown)

func (*LockControl) SetTargetState

func (s *LockControl) SetTargetState(value LockState)

SetTargetState sets the target lock state. Writes both targetState and currentState.

Example:

lock.SetTargetState(LockStateSecured)

func (*LockControl) ToJSON

func (s *LockControl) ToJSON() sensorJSON

func (*LockControl) UpdateValue

func (s *LockControl) UpdateValue(property string, value any) error

UpdateValue routes generic property writes to the semantic setters. Only targetState is externally writable, currentState is observed-only.

type LockState

LockState defines lock states.

type LockState int

const (
    LockStateSecured   LockState = 0 // Locked
    LockStateUnsecured LockState = 1 // Unlocked
    LockStateUnknown   LockState = 2 // State cannot be determined, e.g. while a motorized lock is moving
)

type ModelSpec

ModelSpec describes a detection model with fixed output labels (face, classifier, license plate). It declares the input shape the backend should produce and the trigger labels that should activate this detector.

type ModelSpec struct {
    ModelRuntime   `msgpack:",inline"`
    Input          VideoInputSpec `msgpack:"input" json:"input"`                                       // Required input frame dimensions and pixel format
    TriggerLabels  []string       `msgpack:"triggerLabels" json:"triggerLabels"`                       // Labels emitted by an upstream object detector that activate this detector
    EmbeddingModel string         `msgpack:"embeddingModel,omitempty" json:"embeddingModel,omitempty"` // Embedding model identifier, required for face recognition and CLIP: embeddings are stored and matched under this id
}

type MotionDetector

MotionDetector is implemented by plugins that analyze video frames for motion. The runtime calls DetectMotion at the configured frame interval, zone-filters the returned detections and applies them to the associated MotionSensor. Detected is re-derived from the surviving detections, so a result with no detections reports no motion.

type MotionDetector interface {
    // DetectMotion analyzes a single video frame and returns the motion result.
    DetectMotion(frame VideoFrameData) (*MotionResult, error)
}

type MotionDetectorSensor

MotionDetectorSensor is a motion sensor that consumes video frames from the backend pipeline. Pair with a MotionDetector implementation; the backend invokes the detector at the configured frame interval and forwards results to this sensor.

type MotionDetectorSensor struct {
    MotionSensor
}

func NewMotionDetectorSensor

func NewMotionDetectorSensor(name string, opts ...SensorOption) *MotionDetectorSensor

type MotionResult

MotionResult is the return value of MotionDetector.DetectMotion.

type MotionResult struct {
    Detected   bool        `msgpack:"detected" json:"detected"`     // Whether motion is detected in this frame. Ignored by the backend, which re-derives it from the detections
    Detections []Detection `msgpack:"detections" json:"detections"` // Detections emitted for this frame
}

type MotionSensor

MotionSensor reports motion state and detection results.

Plugin authors call ReportDetections to push detection results. The detected flag is auto-derived from the detection list. The blocked flag is read-only and set by the backend dwell logic, ReportDetections is a no-op while it is set.

type MotionSensor struct {
    BaseSensor
}

func NewMotionSensor

func NewMotionSensor(name string, opts ...SensorOption) *MotionSensor

func (*MotionSensor) ClearDetections

func (s *MotionSensor) ClearDetections()

ClearDetections explicitly clears motion state (detected = false, detections = []).

func (*MotionSensor) GetCategory

func (s *MotionSensor) GetCategory() SensorCategory

func (*MotionSensor) GetDetections

func (s *MotionSensor) GetDetections() []Detection

func (*MotionSensor) GetType

func (s *MotionSensor) GetType() SensorType

func (*MotionSensor) IsBlocked

func (s *MotionSensor) IsBlocked() bool

func (*MotionSensor) IsDetected

func (s *MotionSensor) IsDetected() bool

func (*MotionSensor) ReportDetections

func (s *MotionSensor) ReportDetections(detected bool, detections []Detection)

ReportDetections reports a motion detection result.

  • ReportDetections(true, nil): motion detected without bounding box. The SDK synthesizes a single full-frame "motion" detection.
  • ReportDetections(true, [...]): motion detected with explicit detections.
  • ReportDetections(false, nil): no motion (clears detections).

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

Example:

sensor.ReportDetections(true, []Detection{
    {Label: "motion", Confidence: 0.85, Box: &BoundingBox{X: 0.1, Y: 0.2, Width: 0.3, Height: 0.4}},
})
sensor.ReportDetections(false, nil)

func (*MotionSensor) ToJSON

func (s *MotionSensor) ToJSON() sensorJSON

func (*MotionSensor) UpdateValue

func (s *MotionSensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type ObjectDetector

ObjectDetector is implemented by plugins that detect objects in video frames. The runtime scales frames to match ModelSpec before each call.

type ObjectDetector interface {
    // ModelSpec declares the expected input dimensions.
    ModelSpec() ObjectModelSpec
    // DetectObjects analyzes a single video frame and returns the object result.
    DetectObjects(frame VideoFrameData) (*ObjectResult, error)
}

type ObjectDetectorSensor

ObjectDetectorSensor is an object sensor that consumes video frames from the backend pipeline. Pair with an ObjectDetector implementation.

type ObjectDetectorSensor struct {
    ObjectSensor
}

func NewObjectDetectorSensor

func NewObjectDetectorSensor(name string, opts ...SensorOption) *ObjectDetectorSensor

type ObjectModelSpec

ObjectModelSpec describes an object detection model. Only declares input dimensions, the output label set is dynamic and comes from the model itself.

type ObjectModelSpec struct {
    ModelRuntime `msgpack:",inline"`
    Input        VideoInputSpec `msgpack:"input" json:"input"` // Required input frame dimensions and pixel format
}

type ObjectResult

ObjectResult is the return value of ObjectDetector.DetectObjects.

type ObjectResult struct {
    Detected   bool               `msgpack:"detected" json:"detected"`     // Whether any object is detected in this frame
    Detections []TrackedDetection `msgpack:"detections" json:"detections"` // Detections emitted for this frame
}

type ObjectSensor

ObjectSensor reports detected objects (person, vehicle, animal, etc.).

Plugin authors call ReportDetections to push detection results. The detected flag and the labels are auto-derived from the detection list.

type ObjectSensor struct {
    BaseSensor
}

func NewObjectSensor

func NewObjectSensor(name string, opts ...SensorOption) *ObjectSensor

func (*ObjectSensor) ClearDetections

func (s *ObjectSensor) ClearDetections()

ClearDetections explicitly clears detection state (detected = false, detections = [], labels = []).

func (*ObjectSensor) GetCategory

func (s *ObjectSensor) GetCategory() SensorCategory

func (*ObjectSensor) GetDetections

func (s *ObjectSensor) GetDetections() []TrackedDetection

func (*ObjectSensor) GetLabels

func (s *ObjectSensor) GetLabels() []string

func (*ObjectSensor) GetType

func (s *ObjectSensor) GetType() SensorType

func (*ObjectSensor) IsDetected

func (s *ObjectSensor) IsDetected() bool

func (*ObjectSensor) ReportDetections

func (s *ObjectSensor) ReportDetections(detected bool, detections []TrackedDetection)

ReportDetections reports detected objects. The detected flag and the labels are auto-derived from the detection list.

  • ReportDetections(true, nil): generic trigger, synthesizes a single full-frame "motion" detection as a fallback.
  • ReportDetections(true, [...]): explicit detections.
  • ReportDetections(false, nil): clear.

Example:

sensor.ReportDetections(true, []TrackedDetection{
    {Detection: Detection{Label: "person", Confidence: 0.92, Box: &BoundingBox{X: 0.1, Y: 0.2, Width: 0.3, Height: 0.4}}},
})
sensor.ReportDetections(false, nil)

func (*ObjectSensor) ToJSON

func (s *ObjectSensor) ToJSON() sensorJSON

func (*ObjectSensor) UpdateValue

func (s *ObjectSensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type OccupancySensor

OccupancySensor reports occupancy/presence state.

type OccupancySensor struct{ BaseSensor }

func NewOccupancySensor

func NewOccupancySensor(name string, opts ...SensorOption) *OccupancySensor

func (*OccupancySensor) GetCategory

func (s *OccupancySensor) GetCategory() SensorCategory

func (*OccupancySensor) GetType

func (s *OccupancySensor) GetType() SensorType

func (*OccupancySensor) IsDetected

func (s *OccupancySensor) IsDetected() bool

func (*OccupancySensor) SetDetected

func (s *OccupancySensor) SetDetected(detected bool)

SetDetected reports occupancy state (true when the area is currently occupied).

Example:

occupancy.SetDetected(true)

func (*OccupancySensor) ToJSON

func (s *OccupancySensor) ToJSON() sensorJSON

func (*OccupancySensor) UpdateValue

func (s *OccupancySensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type PTZControl

PTZControl is a pan-tilt-zoom camera control sensor. Override SetPosition / SetVelocity / SetTargetPreset (by embedding PTZControl in your own type and shadowing the methods) to drive hardware, then call the corresponding embedded method after success to sync the SDK state. For hardware-pushed state updates (e.g. PTZ position change events), call the embedded methods directly 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.

type PTZControl struct{ BaseSensor }

func NewPTZControl

func NewPTZControl(name string, opts ...SensorOption) *PTZControl

func (*PTZControl) GetCategory

func (s *PTZControl) GetCategory() SensorCategory

func (*PTZControl) GetPosition

func (s *PTZControl) GetPosition() PTZPosition

func (*PTZControl) GetPresets

func (s *PTZControl) GetPresets() []string

func (*PTZControl) GetTargetPreset

func (s *PTZControl) GetTargetPreset() (string, bool)

func (*PTZControl) GetType

func (s *PTZControl) GetType() SensorType

func (*PTZControl) GetVelocity

func (s *PTZControl) GetVelocity() (PTZDirection, bool)

func (*PTZControl) GoHome

func (s *PTZControl) GoHome()

GoHome moves the PTZ to the home position (0, 0, 0). To drive a hardware home command, shadow UpdateValue and handle "home" there: UpdateValue calls the embedded GoHome, so shadowing GoHome alone is never reached.

Example:

ptz.GoHome()

func (*PTZControl) IsMoving

func (s *PTZControl) IsMoving() bool

func (*PTZControl) SetMoving

func (s *PTZControl) SetMoving(value bool)

SetMoving publishes the movement state.

Example:

ptz.SetMoving(true)

func (*PTZControl) SetPosition

func (s *PTZControl) SetPosition(value PTZPosition)

SetPosition sets the absolute PTZ position.

Example:

ptz.SetPosition(PTZPosition{Pan: 0.25, Tilt: -0.1, Zoom: 0.5})

func (*PTZControl) SetPresets

func (s *PTZControl) SetPresets(value []string)

SetPresets publishes the discovered preset list. The preset list stays empty until this runs.

Example:

ptz.SetPresets([]string{"Home", "Driveway", "Backyard"})

func (*PTZControl) SetRelativeMove

func (s *PTZControl) SetRelativeMove(value PTZRelativeMove)

SetRelativeMove issues a relative displacement move. Shadow this method to drive hardware (e.g. ONVIF RelativeMove in a translation space) and call the embedded method after success to sync the SDK state. Advertise PTZCapabilityRelativeMove when the camera supports it.

Example:

// move the view a third of a frame to the right, a tenth down
ptz.SetRelativeMove(PTZRelativeMove{PanDelta: 0.33, TiltDelta: -0.1, ZoomDelta: 0})

func (*PTZControl) SetTargetPreset

func (s *PTZControl) SetTargetPreset(value string)

SetTargetPreset sets the target preset ID. The property is unset until this runs.

Example:

ptz.SetTargetPreset("Driveway")

func (*PTZControl) SetVelocity

func (s *PTZControl) SetVelocity(value PTZDirection)

SetVelocity sets the continuous-move velocity. The velocity property is unset until the first continuous move is issued.

Example:

ptz.SetVelocity(PTZDirection{PanSpeed: 0.5, TiltSpeed: 0, ZoomSpeed: 0})
ptz.SetVelocity(PTZDirection{}) // stop

func (*PTZControl) ToJSON

func (s *PTZControl) ToJSON() sensorJSON

func (*PTZControl) UpdateValue

func (s *PTZControl) UpdateValue(property string, value any) error

UpdateValue routes generic property writes to the semantic setters.

type SecuritySystem

SecuritySystem is a security system arm/disarm control sensor.

type SecuritySystem struct{ BaseSensor }

func NewSecuritySystem

func NewSecuritySystem(name string, opts ...SensorOption) *SecuritySystem

func (*SecuritySystem) GetCategory

func (s *SecuritySystem) GetCategory() SensorCategory

func (*SecuritySystem) GetCurrentState

func (s *SecuritySystem) GetCurrentState() SecuritySystemState

func (*SecuritySystem) GetTargetState

func (s *SecuritySystem) GetTargetState() SecuritySystemState

func (*SecuritySystem) GetType

func (s *SecuritySystem) GetType() SensorType

func (*SecuritySystem) SetCurrentState

func (s *SecuritySystem) SetCurrentState(value SecuritySystemState)

SetCurrentState publishes the actual security system state. Use this for transitions that diverge from the user-requested target: AlarmTriggered when an intruder is detected, or arming-delay intermediate states. Read-only from cross-process consumers (UpdateValue ignores it).

Example:

alarm.SetCurrentState(SecuritySystemStateAlarmTriggered)

func (*SecuritySystem) SetTargetState

func (s *SecuritySystem) SetTargetState(value SecuritySystemState)

SetTargetState sets the target state. Writes both targetState and currentState. The target state is never SecuritySystemStateAlarmTriggered, publish that through SetCurrentState.

Example:

alarm.SetTargetState(SecuritySystemStateAwayArm)

func (*SecuritySystem) ToJSON

func (s *SecuritySystem) ToJSON() sensorJSON

func (*SecuritySystem) UpdateValue

func (s *SecuritySystem) UpdateValue(property string, value any) error

UpdateValue routes generic property writes to the semantic setters.

type SecuritySystemState

SecuritySystemState defines security system states.

type SecuritySystemState int

const (
    SecuritySystemStateStayArm        SecuritySystemState = 0 // Armed, occupants home
    SecuritySystemStateAwayArm        SecuritySystemState = 1 // Armed, occupants away
    SecuritySystemStateNightArm       SecuritySystemState = 2 // Armed for night mode
    SecuritySystemStateDisarmed       SecuritySystemState = 3 // System disarmed
    SecuritySystemStateAlarmTriggered SecuritySystemState = 4 // Alarm is triggered
)

type Sensor

Sensor is the interface all sensors must implement.

State-modifying methods (SetOn, ReportDetections, etc.) live on the concrete sensor types, not on Sensor. Code that holds a Sensor reference can read state and observe changes, plus invoke UpdateValue for cross-process generic property writes.

type Sensor interface {
    GetID() string
    GetType() SensorType
    GetName() string
    GetDisplayName() string
    GetNativeID() string
    GetPluginID() string
    GetAssignedCameraIDs() []string
    Connected() bool
    GetCapabilities() []string
    AssignmentLocked() bool
    // HasCapability reports whether the sensor advertises a capability.
    HasCapability(cap string) bool
    // GetValue returns the current value of a sensor property.
    GetValue(property string) any
    // GetValues returns a snapshot copy of all property values.
    GetValues() map[string]any
    // UpdateValue is the generic property write coming from a consumer. Concrete
    // sensor types dispatch known properties to semantic methods (SetOn,
    // SetTargetState) so plugin-side hardware overrides run. Read-only sensors
    // implement it as a no-op. Plugin authors call the semantic methods instead.
    UpdateValue(property string, value any) error
    // OnPropertyChanged fires on every property change.
    OnPropertyChanged(callback func(SensorPropertyChange)) *Disposable
    // OnCapabilitiesChanged fires with the full capability list whenever it changes.
    OnCapabilitiesChanged(callback func([]string)) *Disposable
    // OnAssignmentChanged fires with the current camera id list whenever the
    // user changes this sensor's camera assignments.
    OnAssignmentChanged(callback func([]string)) *Disposable
    // OnConnectedChanged fires when the owning plugin's connectivity changes.
    OnConnectedChanged(callback func(bool)) *Disposable
}

type SensorCategory

SensorCategory categorizes a sensor's role in the system. It determines how the backend treats the sensor, read-only or controllable.

type SensorCategory string

const (
    SensorCategorySensor  SensorCategory = "sensor"  // Read-only detection sensor (motion, object, audio, etc.)
    SensorCategoryControl SensorCategory = "control" // Controllable sensor with set methods (light, siren, PTZ, etc.)
    SensorCategoryTrigger SensorCategory = "trigger" // Event trigger (doorbell ring)
    SensorCategoryInfo    SensorCategory = "info"    // Informational read-only state (battery level)
)

type SensorTriggerSettings

SensorTriggerSettings is the sensor trigger settings (contact, doorbell, switch, light, etc.).

type SensorTriggerSettings struct {
    // Timeout is the sensor trigger timeout in seconds.
    Timeout int `msgpack:"timeout" json:"timeout"`
    // Triggers are sensor entity ids that also trigger the detection cascade (in addition to motion/audio).
    Triggers []string `msgpack:"triggers" json:"triggers"`
}

type SensorType

SensorType identifies the kind of sensor. "Sensor" is camera.ui's umbrella term for the smallest smart-home unit. It covers measuring devices and controllable ones alike.

type SensorType string

const (
    SensorTypeMotion         SensorType = "motion"         // Video-based motion detection
    SensorTypeObject         SensorType = "object"         // Object detection (person, vehicle, animal, etc.)
    SensorTypeAudio          SensorType = "audio"          // Audio event detection (glass break, scream, etc.)
    SensorTypeFace           SensorType = "face"           // Face detection and recognition
    SensorTypeLicensePlate   SensorType = "licensePlate"   // License plate detection and OCR
    SensorTypeClassifier     SensorType = "classifier"     // General-purpose image classifier
    SensorTypeClip           SensorType = "clip"           // CLIP embedding generation for semantic search
    SensorTypeObjectAssist   SensorType = "objectAssist"   // Locates objects in a frame so secondary detectors get real crops from camera-side detections
    SensorTypeContact        SensorType = "contact"        // Contact/open-close sensor (door, window)
    SensorTypeLight          SensorType = "light"          // Light on/off and brightness control
    SensorTypeSiren          SensorType = "siren"          // Siren on/off and volume control
    SensorTypeSwitch         SensorType = "switch"         // Generic on/off switch
    SensorTypeLock           SensorType = "lock"           // Lock/unlock control
    SensorTypePTZ            SensorType = "ptz"            // Pan-tilt-zoom camera control
    SensorTypeSecuritySystem SensorType = "securitySystem" // Security system arm/disarm control
    SensorTypeDoorbell       SensorType = "doorbell"       // Doorbell ring trigger
    SensorTypeTemperature    SensorType = "temperature"    // Temperature sensor (°C)
    SensorTypeHumidity       SensorType = "humidity"       // Humidity sensor (0-100%)
    SensorTypeOccupancy      SensorType = "occupancy"      // Occupancy/presence sensor
    SensorTypeSmoke          SensorType = "smoke"          // Smoke detector
    SensorTypeLeak           SensorType = "leak"           // Water leak detector
    SensorTypeGas            SensorType = "gas"            // Gas detector
    SensorTypeCarbonMonoxide SensorType = "carbonMonoxide" // Carbon monoxide detector
    SensorTypeHeat           SensorType = "heat"           // Heat alarm
    SensorTypeCold           SensorType = "cold"           // Cold alarm
    SensorTypeVibration      SensorType = "vibration"      // Vibration sensor
    SensorTypeTamper         SensorType = "tamper"         // Tamper sensor
    SensorTypeProblem        SensorType = "problem"        // Generic problem/fault sensor
    SensorTypePower          SensorType = "power"          // Power detection sensor
    SensorTypeIlluminance    SensorType = "illuminance"    // Illuminance sensor (lx)
    SensorTypeCarbonDioxide  SensorType = "carbonDioxide"  // Carbon dioxide sensor (ppm)
    SensorTypeGarage         SensorType = "garage"         // Garage door opener
    SensorTypeBattery        SensorType = "battery"        // Battery level and charging state
)

type SirenControl

SirenControl is a siren on/off and volume control sensor. Override SetActive / SetInactive (by embedding SirenControl in your own type and shadowing the methods) to drive your hardware, then call the embedded SirenControl's methods to sync the SDK state. For hardware-pushed updates, call the embedded methods directly from your event handler. That bypasses any plugin override and only syncs state.

type SirenControl struct{ BaseSensor }

func NewSirenControl

func NewSirenControl(name string, opts ...SensorOption) *SirenControl

func (*SirenControl) GetCategory

func (s *SirenControl) GetCategory() SensorCategory

func (*SirenControl) GetType

func (s *SirenControl) GetType() SensorType

func (*SirenControl) GetVolume

func (s *SirenControl) GetVolume() int

func (*SirenControl) IsActive

func (s *SirenControl) IsActive() bool

func (*SirenControl) SetActive

func (s *SirenControl) SetActive()

SetActive activates the siren.

Example:

siren.SetActive()

func (*SirenControl) SetInactive

func (s *SirenControl) SetInactive()

SetInactive deactivates the siren.

Example:

siren.SetInactive()

func (*SirenControl) SetVolume

func (s *SirenControl) SetVolume(value int)

SetVolume sets the siren volume (clamped to [0,100]).

Example:

siren.SetVolume(80)

func (*SirenControl) ToJSON

func (s *SirenControl) ToJSON() sensorJSON

func (*SirenControl) UpdateValue

func (s *SirenControl) UpdateValue(property string, value any) error

UpdateValue routes generic property writes to the semantic setters.

type SmokeSensor

SmokeSensor reports smoke detection state.

type SmokeSensor struct{ BaseSensor }

func NewSmokeSensor

func NewSmokeSensor(name string, opts ...SensorOption) *SmokeSensor

func (*SmokeSensor) GetCategory

func (s *SmokeSensor) GetCategory() SensorCategory

func (*SmokeSensor) GetType

func (s *SmokeSensor) GetType() SensorType

func (*SmokeSensor) IsDetected

func (s *SmokeSensor) IsDetected() bool

func (*SmokeSensor) SetDetected

func (s *SmokeSensor) SetDetected(detected bool)

SetDetected reports the smoke detection state.

Example:

smoke.SetDetected(true)

func (*SmokeSensor) ToJSON

func (s *SmokeSensor) ToJSON() sensorJSON

func (*SmokeSensor) UpdateValue

func (s *SmokeSensor) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type SwitchControl

SwitchControl is a generic on/off switch control sensor. Override SetOn / SetOff (by embedding SwitchControl in your own type and shadowing the methods) to drive hardware, then call the embedded SwitchControl's methods to sync the SDK state. For hardware-pushed updates, call the embedded methods directly from your event handler. That bypasses any plugin override and only syncs state.

type SwitchControl struct{ BaseSensor }

func NewSwitchControl

func NewSwitchControl(name string, opts ...SensorOption) *SwitchControl

func (*SwitchControl) GetCategory

func (s *SwitchControl) GetCategory() SensorCategory

func (*SwitchControl) GetType

func (s *SwitchControl) GetType() SensorType

func (*SwitchControl) IsOn

func (s *SwitchControl) IsOn() bool

func (*SwitchControl) SetOff

func (s *SwitchControl) SetOff()

SetOff turns the switch off.

Example:

sw.SetOff()

func (*SwitchControl) SetOn

func (s *SwitchControl) SetOn()

SetOn turns the switch on.

Example:

sw.SetOn()

func (*SwitchControl) ToJSON

func (s *SwitchControl) ToJSON() sensorJSON

func (*SwitchControl) UpdateValue

func (s *SwitchControl) UpdateValue(property string, value any) error

UpdateValue routes generic property writes to the semantic setters.

type TemperatureInfo

TemperatureInfo reports the current temperature in degrees Celsius.

type TemperatureInfo struct{ BaseSensor }

func NewTemperatureInfo

func NewTemperatureInfo(name string, opts ...SensorOption) *TemperatureInfo

func (*TemperatureInfo) GetCategory

func (s *TemperatureInfo) GetCategory() SensorCategory

func (*TemperatureInfo) GetCurrent

func (s *TemperatureInfo) GetCurrent() float64

func (*TemperatureInfo) GetType

func (s *TemperatureInfo) GetType() SensorType

func (*TemperatureInfo) SetCurrent

func (s *TemperatureInfo) SetCurrent(value float64)

SetCurrent reports a new temperature reading (clamped to [-270,100]).

Example:

temperature.SetCurrent(21.5)

func (*TemperatureInfo) ToJSON

func (s *TemperatureInfo) ToJSON() sensorJSON

func (*TemperatureInfo) UpdateValue

func (s *TemperatureInfo) UpdateValue(property string, value any) error

UpdateValue on a read-only sensor: external writes are ignored.

type TrackVelocity

TrackVelocity is the signed centroid velocity in normalized units per frame. Positive X = moving right, positive Y = moving down. Prefer it over deriving velocity from frame-to-frame position deltas.

type TrackVelocity struct {
    X   float64 `msgpack:"x" json:"x"`
    Y   float64 `msgpack:"y" json:"y"`
}

type TrackedDetection

TrackedDetection extends Detection with tracking metadata (stable IDs, velocity). Tracking fields are omitempty: plugins return plain Detection and the server-side tracker fills these in.

type TrackedDetection struct {
    Detection
    TrackId         *int           `msgpack:"trackId,omitempty" json:"trackId,omitempty"`                 // Stable sequential ID for this object across frames
    TrackAge        *int           `msgpack:"trackAge,omitempty" json:"trackAge,omitempty"`               // Number of frames this object has been continuously tracked
    TrackSpeed      *float64       `msgpack:"trackSpeed,omitempty" json:"trackSpeed,omitempty"`           // Velocity magnitude in normalized units per frame; 0 = stationary
    TrackVelocity   *TrackVelocity `msgpack:"trackVelocity,omitempty" json:"trackVelocity,omitempty"`     // Signed centroid velocity in normalized units per frame
    TrackLost       *bool          `msgpack:"trackLost,omitempty" json:"trackLost,omitempty"`             // True if the object was not matched in the current frame
    StationarySince *float64       `msgpack:"stationarySince,omitempty" json:"stationarySince,omitempty"` // Epoch ms since the object has been still; only present while it is settled
}