Sensors¶
Detection sensors (motion, object, face, license-plate, audio, classifier, clip), smart-home sensors and accessories (contact, lock, light, cover, thermostat, media player, environmental readings and the rest) and PTZ. 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.
func UpdateModelSpec¶
func UpdateModelSpec(sensor Sensor)
UpdateModelSpec re-announces a detector's model spec, e.g. once its models finished loading: what a detector reports at registration is only what it knew then, models loading in the background are missing from it. sensor must be the concrete sensor value.
type AccessAttempt¶
AccessAttempt holds the details of an access attempt, as the device reports them.
type AccessAttempt struct {
// Method is how the attempt was made.
Method AccessMethod
// User is who made it, when the device knows.
User string
}
type AccessMethod¶
AccessMethod is how an access attempt was made.
type AccessMethod string
const (
AccessMethodFingerprint AccessMethod = "fingerprint" // Fingerprint
AccessMethodNfc AccessMethod = "nfc" // NFC card or tag
AccessMethodPin AccessMethod = "pin" // PIN code
AccessMethodFace AccessMethod = "face" // Face recognition at the device
AccessMethodApp AccessMethod = "app" // App on a phone
)
type AccessProperty¶
AccessProperty is a property name of an access reader.
type AccessProperty = string
Property names of an access reader.
const (
AccessPropertyResult AccessProperty = "result" // Result of the attempt in progress, empty between attempts
AccessPropertyMethod AccessProperty = "method" // How the last attempt was made
AccessPropertyUser AccessProperty = "user" // Who made the last attempt, empty when unknown
)
type AccessResult¶
AccessResult is the result of an access attempt.
type AccessResult string
const (
AccessResultGranted AccessResult = "granted" // Access was granted
AccessResultDenied AccessResult = "denied" // Access was denied
)
type AccessTrigger¶
AccessTrigger is an access reader, such as a fingerprint or NFC reader on a doorbell or a keypad.
Call Report for each attempt: result is set and goes back to empty after accessAutoResetMs, method and user stay until the next attempt.
type AccessTrigger struct {
BaseSensor
// contains filtered or unexported fields
}
func NewAccessTrigger¶
func NewAccessTrigger(name string, opts ...SensorOption) *AccessTrigger
NewAccessTrigger creates an access reader with the given name and options.
func (*AccessTrigger) GetCategory¶
func (s *AccessTrigger) GetCategory() SensorCategory
func (*AccessTrigger) GetMethod¶
func (s *AccessTrigger) GetMethod() AccessMethod
GetMethod returns how the last attempt was made.
func (*AccessTrigger) GetResult¶
func (s *AccessTrigger) GetResult() AccessResult
GetResult returns the result of the attempt in progress, empty between attempts.
func (*AccessTrigger) GetType¶
func (s *AccessTrigger) GetType() SensorType
func (*AccessTrigger) GetUser¶
func (s *AccessTrigger) GetUser() string
GetUser returns who made the last attempt, empty when unknown.
func (*AccessTrigger) Report¶
func (s *AccessTrigger) Report(result AccessResult, attempt AccessAttempt)
Report reports an access attempt. An attempt while the last result is still set counts as a new one.
Example:
reader.Report(sdk.AccessResultGranted, sdk.AccessAttempt{Method: sdk.AccessMethodFingerprint, User: "Anna"})
func (*AccessTrigger) ToJSON¶
func (s *AccessTrigger) ToJSON() sensorJSON
type AirPurifierControl¶
AirPurifierControl is an air purifier. Override SetOn, SetOff, SetSpeed, SetAuto, SetPreset and SetChildLock (by embedding AirPurifierControl in your own type and shadowing the methods) to drive hardware, then call the embedded AirPurifierControl's methods to sync the SDK state. Report what the purifier does and how its filter is with SetState, SetFilterLife and SetFilterChange.
Each optional part comes with its AirPurifierCapability constant. The presets it offers come as choices: SetPropertySpec(AirPurifierPropertyPreset, &PropertySpecOverride{Choices: ...}).
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type AirPurifierControl struct{ BaseSensor }
func NewAirPurifierControl¶
func NewAirPurifierControl(name string, opts ...SensorOption) *AirPurifierControl
NewAirPurifierControl creates an air purifier with the given name and options.
func (*AirPurifierControl) GetCategory¶
func (s *AirPurifierControl) GetCategory() SensorCategory
func (*AirPurifierControl) GetFilterLife¶
func (s *AirPurifierControl) GetFilterLife() (int, bool)
GetFilterLife returns the filter life left in percent, false before the first report.
func (*AirPurifierControl) GetPreset¶
func (s *AirPurifierControl) GetPreset() string
GetPreset returns the active preset, one of the choices the plugin sets.
func (*AirPurifierControl) GetSpeed¶
func (s *AirPurifierControl) GetSpeed() int
GetSpeed returns the speed in percent.
func (*AirPurifierControl) GetState¶
func (s *AirPurifierControl) GetState() AirPurifierState
GetState returns what the purifier does right now, an AirPurifierState, empty before the first report.
func (*AirPurifierControl) GetType¶
func (s *AirPurifierControl) GetType() SensorType
func (*AirPurifierControl) IsAuto¶
func (s *AirPurifierControl) IsAuto() bool
IsAuto reports true while the purifier runs in its automatic mode.
func (*AirPurifierControl) IsChildLocked¶
func (s *AirPurifierControl) IsChildLocked() bool
IsChildLocked reports true while the buttons on the purifier are locked.
func (*AirPurifierControl) IsOn¶
func (s *AirPurifierControl) IsOn() bool
IsOn reports true while the purifier is on, a command when written.
func (*AirPurifierControl) NeedsFilterChange¶
func (s *AirPurifierControl) NeedsFilterChange() bool
NeedsFilterChange reports true when the filter needs a change.
func (*AirPurifierControl) SetAuto¶
func (s *AirPurifierControl) SetAuto(auto bool) error
SetAuto switches the automatic mode on, or back to a set speed with false.
Example:
purifier.SetAuto(true)
func (*AirPurifierControl) SetChildLock¶
func (s *AirPurifierControl) SetChildLock(locked bool) error
SetChildLock locks the buttons on the purifier, or unlocks them with false.
Example:
purifier.SetChildLock(true)
func (*AirPurifierControl) SetFilterChange¶
func (s *AirPurifierControl) SetFilterChange(change bool)
SetFilterChange reports whether the filter needs a change.
Example:
purifier.SetFilterChange(true)
func (*AirPurifierControl) SetFilterLife¶
func (s *AirPurifierControl) SetFilterLife(percent float64)
SetFilterLife reports how much filter life is left, 0 to 100 percent.
Example:
purifier.SetFilterLife(35)
func (*AirPurifierControl) SetOff¶
func (s *AirPurifierControl) SetOff() error
SetOff turns the purifier off.
Example:
purifier.SetOff()
func (*AirPurifierControl) SetOn¶
func (s *AirPurifierControl) SetOn() error
SetOn turns the purifier on.
Example:
purifier.SetOn()
func (*AirPurifierControl) SetPreset¶
func (s *AirPurifierControl) SetPreset(value string) error
SetPreset sets the preset, one of the preset choices.
Example:
purifier.SetPreset("sleep")
func (*AirPurifierControl) SetSpeed¶
func (s *AirPurifierControl) SetSpeed(speed int) error
SetSpeed sets the speed, 0 to 100 percent.
Example:
purifier.SetSpeed(60)
func (*AirPurifierControl) SetState¶
func (s *AirPurifierControl) SetState(value AirPurifierState)
SetState reports what the purifier does right now: inactive, idle or purifying.
Example:
purifier.SetState(AirPurifierStateIdle)
func (*AirPurifierControl) ToJSON¶
func (s *AirPurifierControl) ToJSON() sensorJSON
type AirPurifierProperty¶
AirPurifierProperty is a property name of an air purifier.
type AirPurifierProperty = string
Property names of an air purifier.
const (
AirPurifierPropertyOn AirPurifierProperty = "on" // True while the purifier is on, a command when written
AirPurifierPropertyState AirPurifierProperty = "state" // What the purifier does right now, an AirPurifierState
AirPurifierPropertySpeed AirPurifierProperty = "speed" // Speed in percent
AirPurifierPropertyAuto AirPurifierProperty = "auto" // True while the purifier runs in its automatic mode
AirPurifierPropertyPreset AirPurifierProperty = "preset" // Active preset, one of the choices the plugin sets
AirPurifierPropertyChildLock AirPurifierProperty = "childLock" // True while the buttons on the purifier are locked
AirPurifierPropertyFilterLife AirPurifierProperty = "filterLife" // Filter life left in percent
AirPurifierPropertyFilterChange AirPurifierProperty = "filterChange" // True when the filter needs a change
)
type AirPurifierState¶
AirPurifierState is what an air purifier does right now.
type AirPurifierState = string
const (
AirPurifierStateInactive AirPurifierState = "inactive" // Purifier is off
AirPurifierStateIdle AirPurifierState = "idle" // Purifier is on but not purifying right now
AirPurifierStatePurifying AirPurifierState = "purifying" // Purifier cleans the air
)
type AirQualityInfo¶
AirQualityInfo reports an overall air quality level and the readings the device has.
Set the capabilities to the readings the device offers. Without a level of its own from the plugin, the level follows the air quality index, else PM2.5.
type AirQualityInfo struct {
BaseSensor
// contains filtered or unexported fields
}
func NewAirQualityInfo¶
func NewAirQualityInfo(name string, opts ...SensorOption) *AirQualityInfo
NewAirQualityInfo creates an air quality sensor with the given name and options.
func (*AirQualityInfo) GetCategory¶
func (s *AirQualityInfo) GetCategory() SensorCategory
func (*AirQualityInfo) GetLevel¶
func (s *AirQualityInfo) GetLevel() AirQualityLevel
GetLevel returns the overall air quality, empty while unknown.
func (*AirQualityInfo) GetReading¶
func (s *AirQualityInfo) GetReading(property AirQualityProperty) float64
GetReading returns a reading, 0 when the device has none.
func (*AirQualityInfo) GetType¶
func (s *AirQualityInfo) GetType() SensorType
func (*AirQualityInfo) SetLevel¶
func (s *AirQualityInfo) SetLevel(value AirQualityLevel)
SetLevel reports the overall air quality as the device rates it. From then on the level no longer follows the readings.
Example:
airQuality.SetLevel(sdk.AirQualityLevelGood)
func (*AirQualityInfo) SetReading¶
func (s *AirQualityInfo) SetReading(property AirQualityProperty, value float64)
SetReading reports a reading. A value that is not a finite number is ignored, a negative one counts as 0.
Example:
airQuality.SetReading(sdk.AirQualityPropertyPm25, 12.4)
func (*AirQualityInfo) ToJSON¶
func (s *AirQualityInfo) ToJSON() sensorJSON
type AirQualityLevel¶
AirQualityLevel is the overall air quality, from best to worst.
type AirQualityLevel string
const (
AirQualityLevelExcellent AirQualityLevel = "excellent" // Clean air
AirQualityLevelGood AirQualityLevel = "good" // Good air
AirQualityLevelFair AirQualityLevel = "fair" // Acceptable air
AirQualityLevelInferior AirQualityLevel = "inferior" // Poor air for sensitive people
AirQualityLevelPoor AirQualityLevel = "poor" // Poor air
)
type AirQualityProperty¶
AirQualityProperty is a property name of an air quality sensor.
type AirQualityProperty = string
Property names of an air quality sensor.
const (
AirQualityPropertyLevel AirQualityProperty = "level" // Overall air quality, empty while unknown
AirQualityPropertyAqi AirQualityProperty = "aqi" // Air quality index
AirQualityPropertyPm25 AirQualityProperty = "pm25" // Fine particles up to 2.5 μm, in μg/m³
AirQualityPropertyPm10 AirQualityProperty = "pm10" // Particles up to 10 μm, in μg/m³
AirQualityPropertyVoc AirQualityProperty = "voc" // Volatile organic compounds, in μg/m³
AirQualityPropertyNo2 AirQualityProperty = "no2" // Nitrogen dioxide, in μg/m³
)
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 AudioInputSpec¶
AudioInputSpec describes the expected audio input format for an audio detector model.
type AudioInputSpec struct {
SampleRate int `msgpack:"sampleRate" json:"sampleRate"` // Sample rate in Hz the model expects
Channels int `msgpack:"channels" json:"channels"` // Channel count the model expects (typically 1 = mono)
Format AudioFormat `msgpack:"format" json:"format"` // Sample format (pcm16 = 16-bit signed PCM, float32 = 32-bit float)
SamplesPerFrame int `msgpack:"samplesPerFrame,omitempty" json:"samplesPerFrame,omitempty"` // Number of samples per audio frame; the backend buffers audio to deliver exactly this many samples per call
}
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 AudioProperty¶
AudioProperty is a property name of an audio sensor.
type AudioProperty = string
Property names of an audio sensor.
const (
AudioPropertyDetected AudioProperty = "detected" // Whether an audio event is currently detected
AudioPropertyDetections AudioProperty = "detections" // List of detected audio events (e.g. glass break, scream). The plugin that owns the sensor does not get the backend's updates of it
AudioPropertyDecibels AudioProperty = "decibels" // Current audio level in decibels. The plugin that owns the sensor does not get the backend's updates of it
AudioPropertyLastTriggered AudioProperty = "lastTriggered" // Timestamp in milliseconds of the last detection trigger, set by the backend
)
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
GetDecibels returns the current audio level in decibels. The plugin that owns the sensor does not get the backend's updates of it.
func (*AudioSensor) GetDetections¶
func (s *AudioSensor) GetDetections() []Detection
GetDetections returns the detected audio events (e.g. glass break, scream). The plugin that owns the sensor does not get the backend's updates of it.
func (*AudioSensor) GetType¶
func (s *AudioSensor) GetType() SensorType
func (*AudioSensor) IsDetected¶
func (s *AudioSensor) IsDetected() bool
IsDetected reports whether an audio event is currently detected.
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
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
AssignmentLocked reports whether the sensor is bound to the camera it was added to, so the user cannot assign it elsewhere.
func (*BaseSensor) Connected¶
func (s *BaseSensor) Connected() bool
Connected reports whether the sensor is registered and its plugin is connected.
func (*BaseSensor) GetAddress¶
func (s *BaseSensor) GetAddress() string
GetAddress returns the current address at the source, e.g. a Home Assistant entity id. Display only.
func (*BaseSensor) GetAssignedCameraIDs¶
func (s *BaseSensor) GetAssignedCameraIDs() []string
GetAssignedCameraIDs returns the ids of the cameras the user assigned the sensor to.
func (*BaseSensor) GetCapabilities¶
func (s *BaseSensor) GetCapabilities() []string
GetCapabilities returns the capabilities the sensor advertises.
func (*BaseSensor) GetDeviceInfo¶
func (s *BaseSensor) GetDeviceInfo() *SensorDevice
GetDeviceInfo returns the device the sensor belongs to, nil without one and for a camera's own sensor.
func (*BaseSensor) GetDisplayName¶
func (s *BaseSensor) GetDisplayName() string
GetDisplayName returns the full name shown to the user: inside a device the device name plus the short name, otherwise the plugin's name until the user renames the sensor.
func (*BaseSensor) GetID¶
func (s *BaseSensor) GetID() string
GetID returns the entity id of the sensor, provisional on a new sensor until registration.
func (*BaseSensor) GetName¶
func (s *BaseSensor) GetName() string
GetName returns the name the plugin gave the sensor.
func (*BaseSensor) GetNativeID¶
func (s *BaseSensor) GetNativeID() string
GetNativeID returns the durable identity the plugin supplied, e.g. an upstream device id.
func (*BaseSensor) GetOrigin¶
func (s *BaseSensor) GetOrigin() string
GetOrigin returns the source system the sensor was imported from, e.g. "homeassistant".
func (*BaseSensor) GetPluginID¶
func (s *BaseSensor) GetPluginID() string
GetPluginID returns the id of the plugin that owns the sensor, set at registration.
func (*BaseSensor) GetPropertySpecs¶
func (s *BaseSensor) GetPropertySpecs() map[string]SensorPropertySpec
GetPropertySpecs returns the specs of the properties the plugin narrowed or described, resolved against the type's. A property without an entry follows its type's spec.
func (*BaseSensor) GetShortName¶
func (s *BaseSensor) GetShortName() string
GetShortName returns the name inside its device, the same as GetDisplayName for a sensor without a device.
func (*BaseSensor) GetSourceState¶
func (s *BaseSensor) GetSourceState() SensorSourceState
GetSourceState returns the state of the source behind the sensor, as reported with SetSourceState.
func (*BaseSensor) GetValue¶
func (s *BaseSensor) GetValue(property string) any
GetValue returns the current value of a sensor property.
func (*BaseSensor) GetValues¶
func (s *BaseSensor) GetValues() map[string]any
GetValues returns a snapshot copy of all property values.
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
IsAssigned reports whether the sensor is assigned to at least one camera.
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) OnDeviceInfoChanged¶
func (s *BaseSensor) OnDeviceInfoChanged(callback func(*SensorDevice)) *Disposable
OnDeviceInfoChanged fires with the device whenever the sensor joins or leaves one, or its device, names or main-sensor role change.
func (*BaseSensor) OnPropertyChanged¶
func (s *BaseSensor) OnPropertyChanged(callback func(SensorPropertyChange)) *Disposable
OnPropertyChanged subscribes to property changes. Returns a Disposable to unsubscribe.
func (*BaseSensor) OnPropertySpecsChanged¶
func (s *BaseSensor) OnPropertySpecsChanged(callback func(map[string]SensorPropertySpec)) *Disposable
OnPropertySpecsChanged fires with the property specs whenever the plugin changes them.
func (*BaseSensor) OnSourceStateChanged¶
func (s *BaseSensor) OnSourceStateChanged(callback func(SensorSourceState)) *Disposable
OnSourceStateChanged fires when the source state changes.
func (*BaseSensor) Primary¶
func (s *BaseSensor) Primary() bool
Primary reports whether the sensor is the main sensor of its device, called like the device when it stands alone.
func (*BaseSensor) SetAddress¶
func (s *BaseSensor) SetAddress(address string)
SetAddress reports the sensor's current address at the source, e.g. after a Home Assistant entity was renamed. The identity (nativeId) stays.
Example:
sensor.SetAddress(entry.EntityID)
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) SetDeviceInfo¶
func (s *BaseSensor) SetDeviceInfo(device *DeviceInfo, primary bool)
SetDeviceInfo puts the sensor into a device, or takes it out with nil. Sensors of this plugin that report the same DeviceInfo.ID form one device. Pass the device with WithDevice when it is known at construction, call this for what changes later: a new firmware, a rename at the source. Only a change reaches the host. Ignored for a sensor added with CameraDevice.AddSensor, its camera is its device. primary marks the device's main sensor.
Example:
sensor.SetDeviceInfo(&sdk.DeviceInfo{ID: hub.Serial, Name: hub.Name, Manufacturer: "Acme", Firmware: hub.Version}, true)
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) SetPropertySpec¶
func (s *BaseSensor) SetPropertySpec(property string, spec *PropertySpecOverride)
SetPropertySpec narrows or describes one property for this device: a range and step, the enum values it supports, the choices it offers with their names, a text limit. The host rejects a command outside it before it reaches the plugin. Pass it with WithPropertySpec when it is known at construction, call this for what changes later. Only a change reaches the host. A nil spec follows the type's spec again.
Example:
alarm.SetPropertySpec(sdk.SecuritySystemPropertyTargetState, &sdk.PropertySpecOverride{
Values: []any{sdk.SecuritySystemStateAwayArm, sdk.SecuritySystemStateStayArm, sdk.SecuritySystemStateDisarmed},
})
func (*BaseSensor) SetSourceState¶
func (s *BaseSensor) SetSourceState(state SensorSourceState)
SetSourceState reports what the source behind this sensor looks like right now, for example unavailable while the device can't be reached. The host shows the state with its reason on the sensors page and never deletes on it. While it is unavailable or removed the sensor takes no writes.
Example:
sensor.SetSourceState(sdk.SensorSourceStateRemoved)
func (*BaseSensor) Storage¶
func (s *BaseSensor) Storage() *DeviceStorage
Storage returns the per-sensor storage, nil before registration.
func (*BaseSensor) UpdateValue¶
func (s *BaseSensor) UpdateValue(property string, value any) error
UpdateValue writes a property the way a consumer does: through the semantic setter, after the writes queued before it. It returns the setter's error, or an error when the device gave no answer within 10 seconds.
Example:
err := light.UpdateValue(sdk.LightPropertyBrightness, 80)
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
GetCharging returns the current charging state.
func (*BatteryInfo) GetLevel¶
func (s *BatteryInfo) GetLevel() int
GetLevel returns the battery level percentage (0-100).
func (*BatteryInfo) GetType¶
func (s *BatteryInfo) GetType() SensorType
func (*BatteryInfo) IsLow¶
func (s *BatteryInfo) IsLow() bool
IsLow reports whether the battery is critically low.
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
type BatteryProperty¶
BatteryProperty is a property name of a battery info sensor.
type BatteryProperty = string
Property names of a battery info sensor.
const (
BatteryPropertyLevel BatteryProperty = "level" // Battery level percentage (0-100)
BatteryPropertyCharging BatteryProperty = "charging" // Current charging state
BatteryPropertyLow BatteryProperty = "low" // Whether the battery is critically low
)
type BinarySensor¶
BinarySensor is the base of the sensors that report one condition as on or off, such as smoke, a leak or an open contact. The concrete sensor types embed it.
type BinarySensor struct {
BaseSensor
// contains filtered or unexported fields
}
func (*BinarySensor) GetCategory¶
func (s *BinarySensor) GetCategory() SensorCategory
func (*BinarySensor) GetType¶
func (s *BinarySensor) GetType() SensorType
func (*BinarySensor) IsDetected¶
func (s *BinarySensor) IsDetected() bool
IsDetected reports whether the sensor currently detects its condition.
func (*BinarySensor) SetDetected¶
func (s *BinarySensor) SetDetected(detected bool)
SetDetected reports whether the condition is currently detected.
Example:
sensor.SetDetected(true)
func (*BinarySensor) ToJSON¶
func (s *BinarySensor) ToJSON() sensorJSON
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 ButtonConfig¶
ButtonConfig describes a button at construction.
type ButtonConfig struct {
// Index is the position of the button on its device, from 1, e.g. for HomeKit's button order.
Index int
// Presses lists the kinds of press the button reports besides a single press.
Presses []ButtonPress
}
type ButtonPress¶
ButtonPress is how a button was pressed.
type ButtonPress string
const (
ButtonPressSingle ButtonPress = "single" // One short press
ButtonPressDouble ButtonPress = "double" // Two short presses in a row
ButtonPressLong ButtonPress = "long" // A press held down
)
type ButtonProperty¶
ButtonProperty is a property name of a button.
type ButtonProperty = string
const (
ButtonPropertyPress ButtonProperty = "press" // Kind of the press in progress, empty between presses
ButtonPropertyIndex ButtonProperty = "index" // Position of the button on its device, from 1. 0 leaves the order to the creation order
)
type ButtonTrigger¶
ButtonTrigger is a physical button, such as one on a remote or a wall switch.
Call Press when the device reports a press: press is set to its kind and goes back to empty after pressAutoResetMs. A single press is always offered, double and long presses only when listed in ButtonConfig.Presses.
type ButtonTrigger struct {
BaseSensor
// contains filtered or unexported fields
}
func NewButtonTrigger¶
func NewButtonTrigger(name string, config ButtonConfig, opts ...SensorOption) *ButtonTrigger
NewButtonTrigger creates a button with the given name, config and options.
func (*ButtonTrigger) GetCategory¶
func (s *ButtonTrigger) GetCategory() SensorCategory
func (*ButtonTrigger) GetIndex¶
func (s *ButtonTrigger) GetIndex() int
GetIndex returns the position of the button on its device, from 1. 0 leaves the order to the creation order.
func (*ButtonTrigger) GetPress¶
func (s *ButtonTrigger) GetPress() ButtonPress
GetPress returns the kind of the press in progress, empty between presses.
func (*ButtonTrigger) GetType¶
func (s *ButtonTrigger) GetType() SensorType
func (*ButtonTrigger) Press¶
func (s *ButtonTrigger) Press(kind ButtonPress) error
Press reports a press. A press while the last one is still set counts as a new one. It fails when the button does not offer this kind of press.
Example:
err := button.Press(sdk.ButtonPressDouble)
func (*ButtonTrigger) ToJSON¶
func (s *ButtonTrigger) ToJSON() sensorJSON
type CarbonDioxideInfo¶
CarbonDioxideInfo reports the current CO2 concentration in ppm.
type CarbonDioxideInfo struct{ MeasurementInfo }
func NewCarbonDioxideInfo¶
func NewCarbonDioxideInfo(name string, opts ...SensorOption) *CarbonDioxideInfo
NewCarbonDioxideInfo creates a carbon dioxide info sensor with the given name and options.
type CarbonDioxideProperty¶
CarbonDioxideProperty is a property name of a carbon dioxide sensor.
type CarbonDioxideProperty = string
Property names of a carbon dioxide sensor.
const (
CarbonDioxidePropertyCurrent CarbonDioxideProperty = "current" // Current CO2 concentration in parts per million
)
type CarbonMonoxideProperty¶
CarbonMonoxideProperty is a property name of a carbon monoxide sensor.
type CarbonMonoxideProperty = string
Property names of a carbon monoxide sensor.
const (
CarbonMonoxidePropertyDetected CarbonMonoxideProperty = "detected" // Whether carbon monoxide is detected
)
type CarbonMonoxideSensor¶
CarbonMonoxideSensor reports carbon monoxide detection state.
type CarbonMonoxideSensor struct{ BinarySensor }
func NewCarbonMonoxideSensor¶
func NewCarbonMonoxideSensor(name string, opts ...SensorOption) *CarbonMonoxideSensor
NewCarbonMonoxideSensor creates a carbon monoxide sensor with the given name and options.
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 ChimeControl¶
ChimeControl is a chime, such as a door chime or a speaker that plays ringtones. Offer the device's tones with SetPropertySpec(ChimePropertyTone) and its Choices. Override Play (by embedding ChimeControl in your own type and shadowing the method) to drive your hardware, then call the embedded method to sync the SDK state, and call Stop when the device reports the end. Without that the chime counts as done after chimeAutoResetMs.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type ChimeControl struct {
BaseSensor
// contains filtered or unexported fields
}
func NewChimeControl¶
func NewChimeControl(name string, opts ...SensorOption) *ChimeControl
NewChimeControl creates a chime with the given name and options.
func (*ChimeControl) GetCategory¶
func (s *ChimeControl) GetCategory() SensorCategory
func (*ChimeControl) GetRepeat¶
func (s *ChimeControl) GetRepeat() int
GetRepeat returns how often the tone plays (1-10).
func (*ChimeControl) GetTone¶
func (s *ChimeControl) GetTone() string
GetTone returns the tone the chime plays, one of the tones the device offers.
func (*ChimeControl) GetType¶
func (s *ChimeControl) GetType() SensorType
func (*ChimeControl) GetVolume¶
func (s *ChimeControl) GetVolume() int
GetVolume returns the volume level (0-100).
func (*ChimeControl) IsActive¶
func (s *ChimeControl) IsActive() bool
IsActive reports whether the chime is playing.
func (*ChimeControl) Play¶
func (s *ChimeControl) Play() error
Play plays the tone.
Example:
chime.Play()
func (*ChimeControl) SetRepeat¶
func (s *ChimeControl) SetRepeat(value int) error
SetRepeat sets how often the tone plays (clamped to [1,10]).
Example:
chime.SetRepeat(2)
func (*ChimeControl) SetTone¶
func (s *ChimeControl) SetTone(value string) error
SetTone chooses the tone, one of the tones offered as choices.
Example:
chime.SetTone("ding-dong")
func (*ChimeControl) SetVolume¶
func (s *ChimeControl) SetVolume(value int) error
SetVolume sets the chime volume (clamped to [0,100]).
Example:
chime.SetVolume(60)
func (*ChimeControl) Stop¶
func (s *ChimeControl) Stop() error
Stop stops playing, call it too when the device reports the end.
Example:
chime.Stop()
func (*ChimeControl) ToJSON¶
func (s *ChimeControl) ToJSON() sensorJSON
type ChimeProperty¶
ChimeProperty is a property name of a chime.
type ChimeProperty = string
const (
ChimePropertyActive ChimeProperty = "active" // Whether the chime is playing
ChimePropertyTone ChimeProperty = "tone" // Tone the chime plays, one of the tones the device offers
ChimePropertyVolume ChimeProperty = "volume" // Volume level (0-100)
ChimePropertyRepeat ChimeProperty = "repeat" // How often the tone plays (1-10)
)
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 ClassifierProperty¶
ClassifierProperty is a property name of a classifier sensor.
type ClassifierProperty = string
Property names of a classifier sensor.
const (
ClassifierPropertyDetected ClassifierProperty = "detected" // Whether any classification result is active
ClassifierPropertyDetections ClassifierProperty = "detections" // List of classification results with labels and confidence. The plugin that owns the sensor does not get the backend's updates of it
ClassifierPropertyLabels ClassifierProperty = "labels" // Labels recognized during the active detection phase (auto-derived when reporting detections)
)
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
GetDetections returns the classification results with labels and confidence. The plugin that owns the sensor does not get the backend's updates of it.
func (*ClassifierSensor) GetLabels¶
func (s *ClassifierSensor) GetLabels() []string
GetLabels returns the labels recognized during the active detection phase (auto-derived when reporting detections).
func (*ClassifierSensor) GetType¶
func (s *ClassifierSensor) GetType() SensorType
func (*ClassifierSensor) IsDetected¶
func (s *ClassifierSensor) IsDetected() bool
IsDetected reports whether any classification result is active.
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
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
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 ColdProperty¶
ColdProperty is a property name of a cold sensor.
type ColdProperty = string
Property names of a cold sensor.
const (
ColdPropertyDetected ColdProperty = "detected" // Whether abnormal cold is detected
)
type ColdSensor¶
ColdSensor reports abnormal cold detection state.
type ColdSensor struct{ BinarySensor }
func NewColdSensor¶
func NewColdSensor(name string, opts ...SensorOption) *ColdSensor
NewColdSensor creates a cold sensor with the given name and options.
type CommandControl¶
CommandControl is the base of the controls that take one-off commands, such as a vacuum or a media player. A command reads in command for a moment (commandAutoResetMs) and then empty again, so the history records each one and the next arrives the same way. The concrete control types embed it.
type CommandControl struct {
BaseSensor
// contains filtered or unexported fields
}
func (*CommandControl) GetCategory¶
func (s *CommandControl) GetCategory() SensorCategory
func (*CommandControl) GetType¶
func (s *CommandControl) GetType() SensorType
func (*CommandControl) ToJSON¶
func (s *CommandControl) ToJSON() sensorJSON
type ContactKind¶
ContactKind says what a contact guards, it decides how smart homes show it.
type ContactKind = string
const (
ContactKindDoor ContactKind = "door" // A door
ContactKindGarageDoor ContactKind = "garage_door" // A garage door
ContactKindWindow ContactKind = "window" // A window
)
type ContactProperty¶
ContactProperty is a property name of a contact sensor.
type ContactProperty = string
Property names of a contact sensor.
const (
ContactPropertyDetected ContactProperty = "detected" // Whether the contact is open (true = open, false = closed)
ContactPropertyKind ContactProperty = "kind" // What the contact guards, a ContactKind
)
type ContactSensor¶
ContactSensor reports door/window open-close state.
type ContactSensor struct{ BinarySensor }
func NewContactSensor¶
func NewContactSensor(name string, opts ...SensorOption) *ContactSensor
NewContactSensor creates a contact sensor with the given name and options.
func (*ContactSensor) GetKind¶
func (s *ContactSensor) GetKind() ContactKind
GetKind returns what the contact guards, a ContactKind.
func (*ContactSensor) SetKind¶
func (s *ContactSensor) SetKind(kind ContactKind)
SetKind says what the contact guards. Smart homes show it by its kind, a window or a door for example, and Home Assistant takes it as the device class.
Example:
contact.SetKind(ContactKindWindow)
type CoverControl¶
CoverControl is a blind, shutter, awning, curtain or other cover. Override SetTargetState, SetTargetPosition and SetTargetTilt (by embedding CoverControl in your own type and shadowing the methods) to drive hardware, then call the embedded CoverControl's methods to sync the SDK state. Report what the hardware does with SetCurrentState, SetCurrentPosition and SetCurrentTilt.
A cover that moves to positions adds CoverCapabilityPosition, one with slats CoverCapabilityTilt, one that stops on command CoverCapabilityStop and shadows Stop. SetKind says what the cover is.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type CoverControl struct{ BaseSensor }
func NewCoverControl¶
func NewCoverControl(name string, opts ...SensorOption) *CoverControl
NewCoverControl creates a cover with the given name and options.
func (*CoverControl) GetCategory¶
func (s *CoverControl) GetCategory() SensorCategory
func (*CoverControl) GetCurrentPosition¶
func (s *CoverControl) GetCurrentPosition() int
GetCurrentPosition returns the current position, 0 (closed) to 100 (open).
func (*CoverControl) GetCurrentState¶
func (s *CoverControl) GetCurrentState() CoverState
GetCurrentState returns the current state, a CoverState.
func (*CoverControl) GetCurrentTilt¶
func (s *CoverControl) GetCurrentTilt() int
GetCurrentTilt returns the current tilt of the slats, 0 (closed) to 100 (open).
func (*CoverControl) GetKind¶
func (s *CoverControl) GetKind() CoverKind
GetKind returns what the cover is, a CoverKind, empty when the plugin did not say.
func (*CoverControl) GetTargetPosition¶
func (s *CoverControl) GetTargetPosition() int
GetTargetPosition returns the target position, 0 (closed) to 100 (open).
func (*CoverControl) GetTargetState¶
func (s *CoverControl) GetTargetState() CoverState
GetTargetState returns the target state, Open or Closed.
func (*CoverControl) GetTargetTilt¶
func (s *CoverControl) GetTargetTilt() int
GetTargetTilt returns the target tilt of the slats, 0 (closed) to 100 (open).
func (*CoverControl) GetType¶
func (s *CoverControl) GetType() SensorType
func (*CoverControl) IsObstructionDetected¶
func (s *CoverControl) IsObstructionDetected() bool
IsObstructionDetected reports whether something blocks the cover.
func (*CoverControl) SetCurrentPosition¶
func (s *CoverControl) SetCurrentPosition(position int)
SetCurrentPosition reports the position of the cover, 0 (closed) to 100 (open).
Example:
cover.SetCurrentPosition(30)
func (*CoverControl) SetCurrentState¶
func (s *CoverControl) SetCurrentState(value CoverState)
SetCurrentState reports the state of the cover.
Example:
cover.SetCurrentState(CoverStateOpening)
func (*CoverControl) SetCurrentTilt¶
func (s *CoverControl) SetCurrentTilt(tilt int)
SetCurrentTilt reports the tilt of the slats, 0 (closed) to 100 (open).
Example:
cover.SetCurrentTilt(40)
func (*CoverControl) SetKind¶
func (s *CoverControl) SetKind(kind CoverKind)
SetKind says what the cover is. Smart homes show it by its kind, a window or a door for example, and Home Assistant takes it as the device class.
Example:
cover.SetKind(CoverKindShutter)
func (*CoverControl) SetObstructionDetected¶
func (s *CoverControl) SetObstructionDetected(detected bool)
SetObstructionDetected reports whether something blocks the cover.
Example:
cover.SetObstructionDetected(true)
func (*CoverControl) SetTargetPosition¶
func (s *CoverControl) SetTargetPosition(position int) error
SetTargetPosition moves the cover to a position, 0 (closed) to 100 (open). Writes both targetPosition and currentPosition.
Example:
cover.SetTargetPosition(50)
func (*CoverControl) SetTargetState¶
func (s *CoverControl) SetTargetState(value CoverState) error
SetTargetState opens or closes the cover. Writes both targetState and currentState.
Example:
cover.SetTargetState(CoverStateOpen)
func (*CoverControl) SetTargetTilt¶
func (s *CoverControl) SetTargetTilt(tilt int) error
SetTargetTilt tilts the slats, 0 (closed) to 100 (open). Writes both targetTilt and currentTilt.
Example:
cover.SetTargetTilt(100)
func (*CoverControl) Stop¶
func (s *CoverControl) Stop() error
Stop stops the cover and reports it as stopped. The stop property is a command and stays false.
Example:
cover.Stop()
func (*CoverControl) ToJSON¶
func (s *CoverControl) ToJSON() sensorJSON
type CoverKind¶
CoverKind says what a cover is, it decides how smart homes show it.
type CoverKind = string
const (
CoverKindAwning CoverKind = "awning" // An awning
CoverKindBlind CoverKind = "blind" // A blind of slats, such as a Venetian blind
CoverKindCurtain CoverKind = "curtain" // A curtain or drape
CoverKindDamper CoverKind = "damper" // A damper that controls the airflow in a duct
CoverKindDoor CoverKind = "door" // A door or gate
CoverKindShade CoverKind = "shade" // A shade of one piece of fabric, such as a roller shade
CoverKindShutter CoverKind = "shutter" // A shutter, such as a roller shutter
CoverKindWindow CoverKind = "window" // A window that opens and closes
)
type CoverProperty¶
CoverProperty is a property name of a cover.
type CoverProperty = string
const (
CoverPropertyCurrentState CoverProperty = "currentState" // Current state, a CoverState
CoverPropertyTargetState CoverProperty = "targetState" // Target state, Open or Closed
CoverPropertyCurrentPosition CoverProperty = "currentPosition" // Current position, 0 (closed) to 100 (open)
CoverPropertyTargetPosition CoverProperty = "targetPosition" // Target position, 0 (closed) to 100 (open)
CoverPropertyCurrentTilt CoverProperty = "currentTilt" // Current tilt of the slats, 0 (closed) to 100 (open)
CoverPropertyTargetTilt CoverProperty = "targetTilt" // Target tilt of the slats, 0 (closed) to 100 (open)
CoverPropertyStop CoverProperty = "stop" // Command that stops the cover, it reads false again once handled
CoverPropertyObstructionDetected CoverProperty = "obstructionDetected" // Whether something blocks the cover
CoverPropertyKind CoverProperty = "kind" // What the cover is, a CoverKind
)
type CoverState¶
CoverState is the state of a cover. A target takes Open and Closed.
type CoverState int
const (
CoverStateOpen CoverState = 0 // Cover is open, fully or part-way
CoverStateClosed CoverState = 1 // Cover is fully closed
CoverStateOpening CoverState = 2 // Cover is moving towards open
CoverStateClosing CoverState = 3 // Cover is moving towards closed
CoverStateStopped CoverState = 4 // Cover stopped part-way
)
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 DeviceInfo¶
DeviceInfo is the physical device a sensor belongs to, as the plugin reports it. Sensors of one plugin that report the same ID form one device: one row on the sensors page, one HomeKit accessory, one Home Assistant device. A sensor without a device is its own device, and a sensor added with CameraDevice.AddSensor belongs to its camera.
type DeviceInfo struct {
// ID is the source's stable id for the device, never an address: a vendor
// device id, a Home Assistant device id, a serial number.
ID string `msgpack:"id" json:"id"`
// Name is the name of the device at the source.
Name string `msgpack:"name" json:"name"`
// Manufacturer is the manufacturer label (optional).
Manufacturer string `msgpack:"manufacturer,omitempty" json:"manufacturer,omitempty"`
// Model is the model label (optional).
Model string `msgpack:"model,omitempty" json:"model,omitempty"`
// Firmware is the firmware version (optional).
Firmware string `msgpack:"firmware,omitempty" json:"firmware,omitempty"`
// SerialNumber is the serial number (optional).
SerialNumber string `msgpack:"serialNumber,omitempty" json:"serialNumber,omitempty"`
}
type DisplayControl¶
DisplayControl is a text display on a device, such as the screen of a doorbell. Set the longest text with SetPropertySpec(DisplayPropertyMessage) and its MaxLength, the presets with SetPropertySpec(DisplayPropertyPreset) and its Choices. Override SetMessage and SetPreset (by embedding DisplayControl in your own type and shadowing the methods) to drive your hardware, then call the embedded methods to sync the SDK state.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type DisplayControl struct{ BaseSensor }
func NewDisplayControl¶
func NewDisplayControl(name string, opts ...SensorOption) *DisplayControl
NewDisplayControl creates a display with the given name and options.
func (*DisplayControl) GetCategory¶
func (s *DisplayControl) GetCategory() SensorCategory
func (*DisplayControl) GetDuration¶
func (s *DisplayControl) GetDuration() int
GetDuration returns the seconds a new message stays on the display, 0 until it is cleared.
func (*DisplayControl) GetMessage¶
func (s *DisplayControl) GetMessage() string
GetMessage returns the text on the display, empty when none is shown.
func (*DisplayControl) GetPreset¶
func (s *DisplayControl) GetPreset() string
GetPreset returns the preset message on the display, empty when none is shown.
func (*DisplayControl) GetType¶
func (s *DisplayControl) GetType() SensorType
func (*DisplayControl) SetDuration¶
func (s *DisplayControl) SetDuration(value int) error
SetDuration sets how long a new message stays on the display, 0 keeps it until it is cleared.
Example:
display.SetDuration(60)
func (*DisplayControl) SetMessage¶
func (s *DisplayControl) SetMessage(value string) error
SetMessage shows a text, an empty one clears the display.
Example:
display.SetMessage("Back in 5 minutes")
func (*DisplayControl) SetPreset¶
func (s *DisplayControl) SetPreset(value string) error
SetPreset shows a preset message, an empty one clears the display.
Example:
display.SetPreset("LEAVE_PACKAGE_AT_DOOR")
func (*DisplayControl) ToJSON¶
func (s *DisplayControl) ToJSON() sensorJSON
type DisplayProperty¶
DisplayProperty is a property name of a display.
type DisplayProperty = string
const (
DisplayPropertyMessage DisplayProperty = "message" // Text on the display, empty when none is shown
DisplayPropertyPreset DisplayProperty = "preset" // Preset message on the display, empty when none is shown
DisplayPropertyDuration DisplayProperty = "duration" // Seconds a new message stays on the display, 0 until it is cleared
)
type DoorbellProperty¶
DoorbellProperty is a property name of a doorbell trigger.
type DoorbellProperty = string
Property names of a doorbell trigger.
const (
DoorbellPropertyRing DoorbellProperty = "ring" // Whether the doorbell is currently ringing
)
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.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
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
IsRinging reports whether the doorbell is currently ringing.
func (*DoorbellTrigger) ToJSON¶
func (s *DoorbellTrigger) ToJSON() sensorJSON
func (*DoorbellTrigger) Trigger¶
func (s *DoorbellTrigger) Trigger() error
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()
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
}
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 FaceEmbedder¶
FaceEmbedder is implemented by plugins that turn a face crop into a vector for recognition against enrolled faces.
type FaceEmbedder interface {
// ModelSpec declares the expected input dimensions and trigger labels.
ModelSpec() ModelSpec
// EmbedFaces embeds a batch of face crops, each padded around the
// detected box and scaled to ModelSpec().Input. Must return exactly one
// FaceEmbeddingResult per input frame, in the same order; return an empty
// Embedding for a crop the model could not use.
EmbedFaces(frames []VideoFrameData) ([]FaceEmbeddingResult, error)
}
type FaceEmbedderSensor¶
FaceEmbedderSensor is a frame-only sensor that turns face crops into vectors. Pair with a FaceEmbedder implementation.
The crop comes from the face detector's box, cut from the source frame, so the sensor runs after face detection rather than on the raw scene. Vectors from different models are not comparable, which is why every result carries its embedding model.
type FaceEmbedderSensor struct{ BaseSensor }
func NewFaceEmbedderSensor¶
func NewFaceEmbedderSensor(name string, opts ...SensorOption) *FaceEmbedderSensor
NewFaceEmbedderSensor creates a face embedder sensor with the given name and options.
func (*FaceEmbedderSensor) GetCategory¶
func (s *FaceEmbedderSensor) GetCategory() SensorCategory
func (*FaceEmbedderSensor) GetType¶
func (s *FaceEmbedderSensor) GetType() SensorType
func (*FaceEmbedderSensor) ToJSON¶
func (s *FaceEmbedderSensor) ToJSON() sensorJSON
type FaceEmbeddingResult¶
FaceEmbeddingResult is the return value of FaceEmbedder.EmbedFaces.
type FaceEmbeddingResult struct {
Embedding []float64 `msgpack:"embedding" json:"embedding"` // Embedding vector for the face in this crop, empty when no face could be embedded
EmbeddingModel string `msgpack:"embeddingModel" json:"embeddingModel"` // Identifier of the embedding model that produced the vector
Landmarks []Point `msgpack:"landmarks,omitempty" json:"landmarks,omitempty"` // The five points the face was aligned on, in 0 - 1 of the input image: right eye, left eye, nose, right and left mouth corner
Quality float64 `msgpack:"quality,omitempty" json:"quality,omitempty"` // How clearly the picture shows a face (0 - 1), also sent with an empty embedding when the face was too unclear; not sent when the landmarks were passed in
}
type FaceProperty¶
FaceProperty is a property name of a face sensor.
type FaceProperty = string
Property names of a face sensor.
const (
FacePropertyDetected FaceProperty = "detected" // Whether any face is currently detected
FacePropertyDetections FaceProperty = "detections" // List of detected faces, with an identity where one was matched. The plugin that owns the sensor does not get the backend's updates of it
FacePropertyIdentities FaceProperty = "identities" // Names of the faces recognized during the active detection phase
)
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
GetDetections returns the detected faces, with an identity where one was matched. The plugin that owns the sensor does not get the backend's updates of it.
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
IsDetected reports whether any face is currently detected.
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 an identity where the plugin recognizes the face itself.
- 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
type FanControl¶
FanControl is a ceiling, desk or other fan. Override SetOn, SetOff, SetSpeed and the other commands (by embedding FanControl in your own type and shadowing the methods) to drive hardware, then call the embedded FanControl's methods to sync the SDK state.
A fan with speeds adds FanCapabilitySpeed, one that turns both ways FanCapabilityDirection, one that swings FanCapabilityOscillation. Presets are the device's own, add FanCapabilityPreset and set them as Choices. A fan with a few fixed speeds sets the speed's Step, three speeds are a step of 33.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type FanControl struct{ BaseSensor }
func NewFanControl¶
func NewFanControl(name string, opts ...SensorOption) *FanControl
NewFanControl creates a fan with the given name and options.
func (*FanControl) GetCategory¶
func (s *FanControl) GetCategory() SensorCategory
func (*FanControl) GetDirection¶
func (s *FanControl) GetDirection() FanDirection
GetDirection returns the direction, a FanDirection.
func (*FanControl) GetPreset¶
func (s *FanControl) GetPreset() string
GetPreset returns the active preset, one of the choices the device offers.
func (*FanControl) GetSpeed¶
func (s *FanControl) GetSpeed() int
GetSpeed returns the speed, 0 to 100 percent.
func (*FanControl) GetType¶
func (s *FanControl) GetType() SensorType
func (*FanControl) IsOn¶
func (s *FanControl) IsOn() bool
IsOn reports whether the fan runs.
func (*FanControl) IsOscillating¶
func (s *FanControl) IsOscillating() bool
IsOscillating reports whether the fan swings from side to side.
func (*FanControl) SetDirection¶
func (s *FanControl) SetDirection(direction FanDirection) error
SetDirection sets the direction, forward or reverse.
Example:
fan.SetDirection(FanDirectionReverse)
func (*FanControl) SetOff¶
func (s *FanControl) SetOff() error
SetOff turns the fan off.
Example:
fan.SetOff()
func (*FanControl) SetOn¶
func (s *FanControl) SetOn() error
SetOn turns the fan on.
Example:
fan.SetOn()
func (*FanControl) SetOscillating¶
func (s *FanControl) SetOscillating(value bool) error
SetOscillating lets the fan swing, or stops it with false.
Example:
fan.SetOscillating(true)
func (*FanControl) SetPreset¶
func (s *FanControl) SetPreset(value string) error
SetPreset sets the preset, one of the preset choices.
Example:
fan.SetPreset("sleep")
func (*FanControl) SetSpeed¶
func (s *FanControl) SetSpeed(speed int) error
SetSpeed sets the speed, 0 to 100 percent.
Example:
fan.SetSpeed(66)
func (*FanControl) ToJSON¶
func (s *FanControl) ToJSON() sensorJSON
type FanDirection¶
FanDirection is the direction a fan turns.
type FanDirection = string
const (
FanDirectionForward FanDirection = "forward" // Fan turns in its normal direction
FanDirectionReverse FanDirection = "reverse" // Fan turns the other way
)
type FanProperty¶
FanProperty is a property name of a fan.
type FanProperty = string
const (
FanPropertyOn FanProperty = "on" // Whether the fan runs
FanPropertySpeed FanProperty = "speed" // Speed, 0 to 100 percent
FanPropertyDirection FanProperty = "direction" // Direction, a FanDirection
FanPropertyOscillating FanProperty = "oscillating" // Whether the fan swings from side to side
FanPropertyPreset FanProperty = "preset" // Active preset, one of the choices the device offers
)
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.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
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
GetCurrentState returns the actual current state of the garage door.
func (*GarageControl) GetTargetState¶
func (s *GarageControl) GetTargetState() GarageState
GetTargetState returns the desired target state (set by user, transitions to the current state).
func (*GarageControl) GetType¶
func (s *GarageControl) GetType() SensorType
func (*GarageControl) IsObstructionDetected¶
func (s *GarageControl) IsObstructionDetected() bool
IsObstructionDetected reports whether an obstruction is detected.
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) error
SetTargetState sets the target state. Writes both targetState and currentState.
Example:
garage.SetTargetState(GarageStateOpen)
func (*GarageControl) ToJSON¶
func (s *GarageControl) ToJSON() sensorJSON
type GarageProperty¶
GarageProperty is a property name of a garage control.
type GarageProperty = string
Property names of a garage control.
const (
GaragePropertyCurrentState GarageProperty = "currentState" // The actual current state of the garage door
GaragePropertyTargetState GarageProperty = "targetState" // The desired target state (set by user, transitions to currentState)
GaragePropertyObstructionDetected GarageProperty = "obstructionDetected" // Whether an obstruction is detected
)
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 GasProperty¶
GasProperty is a property name of a gas sensor.
type GasProperty = string
Property names of a gas sensor.
const (
GasPropertyDetected GasProperty = "detected" // Whether gas is detected
)
type GasSensor¶
GasSensor reports gas detection state.
type GasSensor struct{ BinarySensor }
func NewGasSensor¶
func NewGasSensor(name string, opts ...SensorOption) *GasSensor
NewGasSensor creates a gas sensor with the given name and options.
type GlassBreakProperty¶
GlassBreakProperty is a property name of a glass break sensor.
type GlassBreakProperty = string
Property names of a glass break sensor.
const (
GlassBreakPropertyDetected GlassBreakProperty = "detected" // Whether breaking glass is detected
)
type GlassBreakSensor¶
GlassBreakSensor reports glass break detection state.
type GlassBreakSensor struct{ BinarySensor }
func NewGlassBreakSensor¶
func NewGlassBreakSensor(name string, opts ...SensorOption) *GlassBreakSensor
NewGlassBreakSensor creates a glass break sensor with the given name and options.
type HeatProperty¶
HeatProperty is a property name of a heat sensor.
type HeatProperty = string
Property names of a heat sensor.
const (
HeatPropertyDetected HeatProperty = "detected" // Whether abnormal heat is detected
)
type HeatSensor¶
HeatSensor reports abnormal heat detection state.
type HeatSensor struct{ BinarySensor }
func NewHeatSensor¶
func NewHeatSensor(name string, opts ...SensorOption) *HeatSensor
NewHeatSensor creates a heat sensor with the given name and options.
type HumidifierAction¶
HumidifierAction is what a humidifier does right now.
type HumidifierAction = string
const (
HumidifierActionOff HumidifierAction = "off" // Humidifier is off
HumidifierActionIdle HumidifierAction = "idle" // Humidifier is on but not working right now
HumidifierActionHumidifying HumidifierAction = "humidifying" // Humidifier adds moisture
HumidifierActionDrying HumidifierAction = "drying" // Humidifier removes moisture
)
type HumidifierControl¶
HumidifierControl is a humidifier or dehumidifier that works toward a target humidity. Override SetOn, SetOff, SetTargetHumidity and SetMode (by embedding HumidifierControl in your own type and shadowing the methods) to drive hardware, then call the embedded HumidifierControl's methods to sync the SDK state. Report what the device measures and does with SetCurrentHumidity and SetAction.
SetKind says whether it humidifies or dehumidifies. The modes it offers come as choices: SetPropertySpec(HumidifierPropertyMode, &PropertySpecOverride{Choices: ...}).
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type HumidifierControl struct{ BaseSensor }
func NewHumidifierControl¶
func NewHumidifierControl(name string, opts ...SensorOption) *HumidifierControl
NewHumidifierControl creates a humidifier with the given name and options.
func (*HumidifierControl) GetAction¶
func (s *HumidifierControl) GetAction() HumidifierAction
GetAction returns what the humidifier does right now, a HumidifierAction, empty before the first report.
func (*HumidifierControl) GetCategory¶
func (s *HumidifierControl) GetCategory() SensorCategory
func (*HumidifierControl) GetCurrentHumidity¶
func (s *HumidifierControl) GetCurrentHumidity() (float64, bool)
GetCurrentHumidity returns the measured humidity in percent, false before the first reading.
func (*HumidifierControl) GetKind¶
func (s *HumidifierControl) GetKind() HumidifierKind
GetKind returns whether it humidifies or dehumidifies, a HumidifierKind, empty when the plugin did not say.
func (*HumidifierControl) GetMode¶
func (s *HumidifierControl) GetMode() string
GetMode returns the active mode, one of the choices the plugin sets.
func (*HumidifierControl) GetTargetHumidity¶
func (s *HumidifierControl) GetTargetHumidity() int
GetTargetHumidity returns the target humidity in percent.
func (*HumidifierControl) GetType¶
func (s *HumidifierControl) GetType() SensorType
func (*HumidifierControl) IsOn¶
func (s *HumidifierControl) IsOn() bool
IsOn reports true while the humidifier is on, a command when written.
func (*HumidifierControl) SetAction¶
func (s *HumidifierControl) SetAction(value HumidifierAction)
SetAction reports what the humidifier does right now: off, idle, humidifying or drying.
Example:
humidifier.SetAction(HumidifierActionHumidifying)
func (*HumidifierControl) SetCurrentHumidity¶
func (s *HumidifierControl) SetCurrentHumidity(value float64)
SetCurrentHumidity reports the humidity the device measures, 0 to 100 percent.
Example:
humidifier.SetCurrentHumidity(38)
func (*HumidifierControl) SetKind¶
func (s *HumidifierControl) SetKind(kind HumidifierKind)
SetKind says whether the device humidifies or dehumidifies. Smart homes show it by its kind, and Home Assistant takes it as the device class.
Example:
humidifier.SetKind(HumidifierKindDehumidifier)
func (*HumidifierControl) SetMode¶
func (s *HumidifierControl) SetMode(value string) error
SetMode sets the mode, one of the mode choices.
Example:
humidifier.SetMode("sleep")
func (*HumidifierControl) SetOff¶
func (s *HumidifierControl) SetOff() error
SetOff turns the humidifier off.
Example:
humidifier.SetOff()
func (*HumidifierControl) SetOn¶
func (s *HumidifierControl) SetOn() error
SetOn turns the humidifier on.
Example:
humidifier.SetOn()
func (*HumidifierControl) SetTargetHumidity¶
func (s *HumidifierControl) SetTargetHumidity(value int) error
SetTargetHumidity sets the target humidity, 0 to 100 percent.
Example:
humidifier.SetTargetHumidity(45)
func (*HumidifierControl) ToJSON¶
func (s *HumidifierControl) ToJSON() sensorJSON
type HumidifierKind¶
HumidifierKind says whether the device adds or removes moisture, it decides how smart homes show it.
type HumidifierKind = string
const (
HumidifierKindHumidifier HumidifierKind = "humidifier" // Adds moisture to the air
HumidifierKindDehumidifier HumidifierKind = "dehumidifier" // Removes moisture from the air
)
type HumidifierProperty¶
HumidifierProperty is a property name of a humidifier.
type HumidifierProperty = string
Property names of a humidifier.
const (
HumidifierPropertyOn HumidifierProperty = "on" // True while the humidifier is on, a command when written
HumidifierPropertyTargetHumidity HumidifierProperty = "targetHumidity" // Target humidity in percent
HumidifierPropertyCurrentHumidity HumidifierProperty = "currentHumidity" // Measured humidity in percent
HumidifierPropertyAction HumidifierProperty = "action" // What the humidifier does right now, a HumidifierAction
HumidifierPropertyMode HumidifierProperty = "mode" // Active mode, one of the choices the plugin sets
HumidifierPropertyKind HumidifierProperty = "kind" // Whether it humidifies or dehumidifies, a HumidifierKind
)
type HumidityInfo¶
HumidityInfo reports current relative humidity (0-100%).
type HumidityInfo struct{ MeasurementInfo }
func NewHumidityInfo¶
func NewHumidityInfo(name string, opts ...SensorOption) *HumidityInfo
NewHumidityInfo creates a humidity info sensor with the given name and options.
type HumidityProperty¶
HumidityProperty is a property name of a humidity sensor.
type HumidityProperty = string
Property names of a humidity sensor.
const (
HumidityPropertyCurrent HumidityProperty = "current" // Current relative humidity (0-100%)
)
type IlluminanceInfo¶
IlluminanceInfo reports the current light level in lux.
type IlluminanceInfo struct{ MeasurementInfo }
func NewIlluminanceInfo¶
func NewIlluminanceInfo(name string, opts ...SensorOption) *IlluminanceInfo
NewIlluminanceInfo creates an illuminance info sensor with the given name and options.
type IlluminanceProperty¶
IlluminanceProperty is a property name of an illuminance sensor.
type IlluminanceProperty = string
Property names of an illuminance sensor.
const (
IlluminancePropertyCurrent IlluminanceProperty = "current" // Current illuminance in lux
)
type LawnMowerActivity¶
LawnMowerActivity is what a lawn mower does right now.
type LawnMowerActivity = string
const (
LawnMowerActivityMowing LawnMowerActivity = "mowing" // Mower is mowing
LawnMowerActivityDocked LawnMowerActivity = "docked" // Mower is in its dock
LawnMowerActivityPaused LawnMowerActivity = "paused" // Mower paused where it is
LawnMowerActivityReturning LawnMowerActivity = "returning" // Mower drives back to its dock
LawnMowerActivityError LawnMowerActivity = "error" // Mower reports an error
)
type LawnMowerCommand¶
LawnMowerCommand is a command a lawn mower takes.
type LawnMowerCommand = string
const (
LawnMowerCommandStart LawnMowerCommand = "start" // Start or resume mowing
LawnMowerCommandPause LawnMowerCommand = "pause" // Pause mowing where the mower is
LawnMowerCommandDock LawnMowerCommand = "dock" // Stop mowing and send the mower back to its dock
)
type LawnMowerControl¶
LawnMowerControl is a robot lawn mower. Override Start, Pause and Dock (by embedding LawnMowerControl in your own type and shadowing the methods) to drive hardware, then call the embedded LawnMowerControl's methods after success. Report what the mower does with SetActivity.
Narrow the commands to those the mower takes with SetPropertySpec(LawnMowerPropertyCommand, &PropertySpecOverride{Values: ...}).
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type LawnMowerControl struct{ RobotControl }
func NewLawnMowerControl¶
func NewLawnMowerControl(name string, opts ...SensorOption) *LawnMowerControl
NewLawnMowerControl creates a lawn mower with the given name and options.
func (*LawnMowerControl) Dock¶
func (s *LawnMowerControl) Dock() error
Dock stops mowing and sends the mower back to its dock.
Example:
mower.Dock()
func (*LawnMowerControl) Pause¶
func (s *LawnMowerControl) Pause() error
Pause pauses mowing where the mower is.
Example:
mower.Pause()
func (*LawnMowerControl) Start¶
func (s *LawnMowerControl) Start() error
Start starts or resumes mowing.
Example:
mower.Start()
type LawnMowerProperty¶
LawnMowerProperty is a property name of a lawn mower.
type LawnMowerProperty = string
Property names of a lawn mower.
const (
LawnMowerPropertyActivity LawnMowerProperty = "activity" // What the mower does right now, a LawnMowerActivity
LawnMowerPropertyCommand LawnMowerProperty = "command" // One-off LawnMowerCommand when written, empty again right after
)
type LeakProperty¶
LeakProperty is a property name of a leak sensor.
type LeakProperty = string
Property names of a leak sensor.
const (
LeakPropertyDetected LeakProperty = "detected" // Whether a leak is detected
)
type LeakSensor¶
LeakSensor reports water leak detection state.
type LeakSensor struct{ BinarySensor }
func NewLeakSensor¶
func NewLeakSensor(name string, opts ...SensorOption) *LeakSensor
NewLeakSensor creates a leak sensor with the given name and options.
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
NewLicensePlateDetectorSensor creates a license plate detector sensor with the given name and options.
type LicensePlateProperty¶
LicensePlateProperty is a property name of a license plate sensor.
type LicensePlateProperty = string
Property names of a license plate sensor.
const (
LicensePlatePropertyDetected LicensePlateProperty = "detected" // Whether any license plate is currently detected
LicensePlatePropertyDetections LicensePlateProperty = "detections" // List of detected plates with OCR text. The plugin that owns the sensor does not get the backend's updates of it
LicensePlatePropertyPlates LicensePlateProperty = "plates" // Plate texts recognized during the active detection phase
)
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
NewLicensePlateSensor creates a license plate sensor with the given name and options.
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
GetDetections returns the detected plates with OCR text. The plugin that owns the sensor does not get the backend's updates of it.
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
IsDetected reports whether any license plate is currently detected.
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
type LightColor¶
LightColor is the color of a light.
type LightColor struct {
// Hue in degrees (0-360).
Hue float64 `msgpack:"hue" json:"hue"`
// Saturation in percent (0-100).
Saturation float64 `msgpack:"saturation" json:"saturation"`
}
type LightColorMode¶
LightColorMode says which of its two color settings a light shows.
type LightColorMode = string
const (
LightColorModeTemperature LightColorMode = "temperature" // The white color temperature
LightColorModeColor LightColorMode = "color" // The color from hue and saturation
)
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.
A light with LightCapabilityColorTemperature or LightCapabilityColor overrides SetColorTemperature and SetColor the same way. A command switches the color mode to the setting it changed. When the device reports its state, sync both settings and call SetColorMode with the one it shows.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type LightControl struct{ BaseSensor }
func NewLightControl¶
func NewLightControl(name string, opts ...SensorOption) *LightControl
NewLightControl creates a light control with the given name and options.
func (*LightControl) GetBrightness¶
func (s *LightControl) GetBrightness() int
GetBrightness returns the brightness level (0-100).
func (*LightControl) GetCategory¶
func (s *LightControl) GetCategory() SensorCategory
func (*LightControl) GetColor¶
func (s *LightControl) GetColor() LightColor
GetColor returns the color as hue and saturation, see LightColor.
func (*LightControl) GetColorMode¶
func (s *LightControl) GetColorMode() LightColorMode
GetColorMode returns whether the light shows its color temperature or its color, see LightColorMode.
func (*LightControl) GetColorTemperature¶
func (s *LightControl) GetColorTemperature() int
GetColorTemperature returns the white color temperature in Kelvin.
func (*LightControl) GetType¶
func (s *LightControl) GetType() SensorType
func (*LightControl) IsOn¶
func (s *LightControl) IsOn() bool
IsOn reports whether the light is on.
func (*LightControl) SetBrightness¶
func (s *LightControl) SetBrightness(value int) error
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) SetColor¶
func (s *LightControl) SetColor(hue, saturation float64) error
SetColor sets the color (hue clamped to [0, 360], saturation to [0, 100]). Override (via embedding) to drive hardware and call the embedded LightControl's SetColor to sync the SDK state.
Example:
light.SetColor(240, 100)
func (*LightControl) SetColorMode¶
func (s *LightControl) SetColorMode(mode LightColorMode)
SetColorMode reports which of its two color settings the light shows.
Example:
light.SetColorMode(sdk.LightColorModeColor)
func (*LightControl) SetColorTemperature¶
func (s *LightControl) SetColorTemperature(kelvin int) error
SetColorTemperature sets the white color temperature in Kelvin (clamped to [1000, 10000]). Override (via embedding) to drive hardware and call the embedded LightControl's SetColorTemperature to sync the SDK state.
Example:
light.SetColorTemperature(2700)
func (*LightControl) SetOff¶
func (s *LightControl) SetOff() error
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() error
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
type LightProperty¶
LightProperty is a property name of a light control.
type LightProperty = string
Property names of a light control.
const (
LightPropertyOn LightProperty = "on" // Whether the light is on
LightPropertyBrightness LightProperty = "brightness" // Brightness level (0-100)
LightPropertyColorTemperature LightProperty = "colorTemperature" // White color temperature in Kelvin
LightPropertyColor LightProperty = "color" // Color as hue and saturation, see LightColor
LightPropertyColorMode LightProperty = "colorMode" // Whether the light shows its color temperature or its color, see LightColorMode
)
type LoadedModel¶
LoadedModel is one model a sensor has loaded, reported for the metrics view and for debugging.
type LoadedModel struct {
Name string `msgpack:"name" json:"name"` // Resolved model name, after any "default" placeholder
Role string `msgpack:"role,omitempty" json:"role,omitempty"` // What it does in a sensor that loads several: detect, embed, ocr, text
Device string `msgpack:"device,omitempty" json:"device,omitempty"` // Where inference runs, resolved to the real device
Precision string `msgpack:"precision,omitempty" json:"precision,omitempty"` // Weight precision: fp32, fp16, int8
LoadMs int `msgpack:"loadMs,omitempty" json:"loadMs,omitempty"` // How long loading took, in milliseconds
}
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.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type LockControl struct{ BaseSensor }
func NewLockControl¶
func NewLockControl(name string, opts ...SensorOption) *LockControl
NewLockControl creates a lock control with the given name and options.
func (*LockControl) GetCategory¶
func (s *LockControl) GetCategory() SensorCategory
func (*LockControl) GetCurrentState¶
func (s *LockControl) GetCurrentState() LockState
GetCurrentState returns the actual current state of the lock.
func (*LockControl) GetTargetState¶
func (s *LockControl) GetTargetState() LockState
GetTargetState returns the desired target state (set by user, transitions to the current state).
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) error
SetTargetState sets the target lock state. Writes both targetState and currentState.
Example:
lock.SetTargetState(LockStateSecured)
func (*LockControl) ToJSON¶
func (s *LockControl) ToJSON() sensorJSON
type LockProperty¶
LockProperty is a property name of a lock control.
type LockProperty = string
Property names of a lock control.
const (
LockPropertyCurrentState LockProperty = "currentState" // The actual current state of the lock
LockPropertyTargetState LockProperty = "targetState" // The desired target state (set by user, transitions to currentState)
)
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
LockStateJammed LockState = 3 // Something blocks the bolt, the lock is neither locked nor unlocked
)
type MeasurementInfo¶
MeasurementInfo is the base of the sensors that report one reading, such as a temperature or a CO2 level. The concrete sensor types embed it and set the reading they start with and the range the quantity can have.
type MeasurementInfo struct {
BaseSensor
// contains filtered or unexported fields
}
func (*MeasurementInfo) GetCategory¶
func (s *MeasurementInfo) GetCategory() SensorCategory
func (*MeasurementInfo) GetCurrent¶
func (s *MeasurementInfo) GetCurrent() float64
GetCurrent returns the current reading, in the unit of the sensor type.
func (*MeasurementInfo) GetType¶
func (s *MeasurementInfo) GetType() SensorType
func (*MeasurementInfo) SetCurrent¶
func (s *MeasurementInfo) SetCurrent(value float64)
SetCurrent reports a new reading. A value outside the range of the quantity is clamped to it, NaN and infinite values are ignored.
Example:
temperature.SetCurrent(21.5)
func (*MeasurementInfo) ToJSON¶
func (s *MeasurementInfo) ToJSON() sensorJSON
type MediaPlayerCommand¶
MediaPlayerCommand is a command a media player takes.
type MediaPlayerCommand = string
Commands a media player takes.
const (
MediaPlayerCommandPlay MediaPlayerCommand = "play" // Start or resume playback
MediaPlayerCommandPause MediaPlayerCommand = "pause" // Pause playback
MediaPlayerCommandStop MediaPlayerCommand = "stop" // Stop playback
MediaPlayerCommandNext MediaPlayerCommand = "next" // Skip to the next track or channel
MediaPlayerCommandPrevious MediaPlayerCommand = "previous" // Go back to the previous track or channel
)
type MediaPlayerControl¶
MediaPlayerControl is a TV, speaker, receiver or projector. Override SetOn, SetOff, Play, Pause, Stop, Next, Previous, SetVolume, SetMuted and SetSource (by embedding MediaPlayerControl in your own type and shadowing the methods) to drive hardware, then call the embedded MediaPlayerControl's methods after success. Report what the player does with SetState and what plays with SetNowPlaying.
SetKind says what kind of device it is. Narrow the commands to those the player takes with SetPropertySpec(MediaPlayerPropertyCommand, &PropertySpecOverride{Values: ...}). The inputs come as choices with the source capability: SetPropertySpec(MediaPlayerPropertySource, &PropertySpecOverride{Choices: ...}).
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type MediaPlayerControl struct{ CommandControl }
func NewMediaPlayerControl¶
func NewMediaPlayerControl(name string, opts ...SensorOption) *MediaPlayerControl
NewMediaPlayerControl creates a media player with the given name and options.
func (*MediaPlayerControl) GetArtist¶
func (s *MediaPlayerControl) GetArtist() string
GetArtist returns the artist of what plays.
func (*MediaPlayerControl) GetKind¶
func (s *MediaPlayerControl) GetKind() MediaPlayerKind
GetKind returns what kind of device it is, a MediaPlayerKind, empty when the plugin did not say.
func (*MediaPlayerControl) GetSource¶
func (s *MediaPlayerControl) GetSource() string
GetSource returns the selected input or app, one of the choices the plugin sets.
func (*MediaPlayerControl) GetState¶
func (s *MediaPlayerControl) GetState() MediaPlayerState
GetState returns what the player does right now, a MediaPlayerState, empty before the first report.
func (*MediaPlayerControl) GetTitle¶
func (s *MediaPlayerControl) GetTitle() string
GetTitle returns the title of what plays.
func (*MediaPlayerControl) GetVolume¶
func (s *MediaPlayerControl) GetVolume() (int, bool)
GetVolume returns the volume, 0 to 100, false before the first report.
func (*MediaPlayerControl) IsMuted¶
func (s *MediaPlayerControl) IsMuted() bool
IsMuted reports whether the sound is muted.
func (*MediaPlayerControl) IsOn¶
func (s *MediaPlayerControl) IsOn() bool
IsOn reports whether the player is on, writable with the power capability.
func (*MediaPlayerControl) Next¶
func (s *MediaPlayerControl) Next() error
Next skips to the next track or channel.
Example:
player.Next()
func (*MediaPlayerControl) Pause¶
func (s *MediaPlayerControl) Pause() error
Pause pauses playback.
Example:
player.Pause()
func (*MediaPlayerControl) Play¶
func (s *MediaPlayerControl) Play() error
Play starts or resumes playback.
Example:
player.Play()
func (*MediaPlayerControl) Previous¶
func (s *MediaPlayerControl) Previous() error
Previous goes back to the previous track or channel.
Example:
player.Previous()
func (*MediaPlayerControl) SetKind¶
func (s *MediaPlayerControl) SetKind(kind MediaPlayerKind)
SetKind says what kind of device the player is. Smart homes show it by its kind, and Home Assistant takes it as the device class.
Example:
player.SetKind(MediaPlayerKindSpeaker)
func (*MediaPlayerControl) SetMuted¶
func (s *MediaPlayerControl) SetMuted(muted bool) error
SetMuted mutes the sound, or unmutes it with false.
Example:
player.SetMuted(true)
func (*MediaPlayerControl) SetNowPlaying¶
func (s *MediaPlayerControl) SetNowPlaying(title, artist string)
SetNowPlaying reports the title and artist of what plays, needs the nowPlaying capability. Pass empty strings when nothing plays.
Example:
player.SetNowPlaying("So What", "Miles Davis")
func (*MediaPlayerControl) SetOff¶
func (s *MediaPlayerControl) SetOff() error
SetOff turns the player off.
Example:
player.SetOff()
func (*MediaPlayerControl) SetOn¶
func (s *MediaPlayerControl) SetOn() error
SetOn turns the player on.
Example:
player.SetOn()
func (*MediaPlayerControl) SetSource¶
func (s *MediaPlayerControl) SetSource(value string) error
SetSource switches to another input or app, one of the source choices.
Example:
player.SetSource("hdmi1")
func (*MediaPlayerControl) SetState¶
func (s *MediaPlayerControl) SetState(value MediaPlayerState)
SetState reports what the player does right now: off, on, idle, playing, paused or buffering. IsOn follows: everything but off counts as on.
Example:
player.SetState(MediaPlayerStatePlaying)
func (*MediaPlayerControl) SetVolume¶
func (s *MediaPlayerControl) SetVolume(volume float64) error
SetVolume sets the volume, 0 to 100, clamped and rounded.
Example:
player.SetVolume(30)
func (*MediaPlayerControl) Stop¶
func (s *MediaPlayerControl) Stop() error
Stop stops playback.
Example:
player.Stop()
type MediaPlayerKind¶
MediaPlayerKind is what kind of device a media player is.
type MediaPlayerKind = string
const (
MediaPlayerKindTv MediaPlayerKind = "tv" // A TV
MediaPlayerKindSpeaker MediaPlayerKind = "speaker" // A speaker
MediaPlayerKindReceiver MediaPlayerKind = "receiver" // An AV receiver
MediaPlayerKindProjector MediaPlayerKind = "projector" // A projector
)
type MediaPlayerProperty¶
MediaPlayerProperty is a property name of a media player.
type MediaPlayerProperty = string
Property names of a media player.
const (
MediaPlayerPropertyOn MediaPlayerProperty = "on" // Whether the player is on, writable with the power capability
MediaPlayerPropertyState MediaPlayerProperty = "state" // What the player does right now, a MediaPlayerState
MediaPlayerPropertyKind MediaPlayerProperty = "kind" // What kind of device it is, a MediaPlayerKind
MediaPlayerPropertyCommand MediaPlayerProperty = "command" // One-off MediaPlayerCommand when written, empty again right after
MediaPlayerPropertyVolume MediaPlayerProperty = "volume" // Volume, 0 to 100
MediaPlayerPropertyMuted MediaPlayerProperty = "muted" // Whether the sound is muted
MediaPlayerPropertySource MediaPlayerProperty = "source" // Selected input or app, one of the choices the plugin sets
MediaPlayerPropertyTitle MediaPlayerProperty = "title" // Title of what plays
MediaPlayerPropertyArtist MediaPlayerProperty = "artist" // Artist of what plays
)
type MediaPlayerState¶
MediaPlayerState is what a media player does right now.
type MediaPlayerState = string
const (
MediaPlayerStateOff MediaPlayerState = "off" // Player is off or in standby
MediaPlayerStateOn MediaPlayerState = "on" // On, without telling what it does
MediaPlayerStateIdle MediaPlayerState = "idle" // Player is on and plays nothing
MediaPlayerStatePlaying MediaPlayerState = "playing" // Player is playing
MediaPlayerStatePaused MediaPlayerState = "paused" // Playback is paused
MediaPlayerStateBuffering MediaPlayerState = "buffering" // Player is loading and about to play
)
type ModelRuntime¶
ModelRuntime is what a sensor runs on. Every field is optional: a plugin that reports nothing simply shows nothing.
type ModelRuntime struct {
Runtime string `msgpack:"runtime,omitempty" json:"runtime,omitempty"` // Inference framework and version
Models []LoadedModel `msgpack:"models,omitempty" json:"models,omitempty"` // Loaded models, primary one first
}
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
NewMotionDetectorSensor creates a motion detector sensor with the given name and options.
type MotionProperty¶
MotionProperty is a property name of a motion sensor.
type MotionProperty = string
Property names of a motion sensor.
const (
MotionPropertyDetected MotionProperty = "detected" // Whether motion is currently detected
MotionPropertyDetections MotionProperty = "detections" // List of detection results with bounding boxes. The plugin that owns the sensor does not get the backend's updates of it
MotionPropertyBlocked MotionProperty = "blocked" // When true, detection updates are suppressed (set by the backend dwell logic)
MotionPropertyLastTriggered MotionProperty = "lastTriggered" // Timestamp in milliseconds of the last detection trigger, set by the backend
)
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
NewMotionSensor creates a motion sensor with the given name and options.
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
GetDetections returns the detection results with bounding boxes. The plugin that owns the sensor does not get the backend's updates of it.
func (*MotionSensor) GetType¶
func (s *MotionSensor) GetType() SensorType
func (*MotionSensor) IsBlocked¶
func (s *MotionSensor) IsBlocked() bool
IsBlocked reports whether detection updates are suppressed (set by the backend dwell logic).
func (*MotionSensor) IsDetected¶
func (s *MotionSensor) IsDetected() bool
IsDetected reports whether motion is currently detected.
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
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. Up to three DetectObjects calls can run at once on separate goroutines, so DetectObjects must be safe for concurrent use, or the embedding type declares its own RPCConcurrency returning nil to get one call at a time.
type ObjectDetectorSensor struct {
ObjectSensor
}
func NewObjectDetectorSensor¶
func NewObjectDetectorSensor(name string, opts ...SensorOption) *ObjectDetectorSensor
NewObjectDetectorSensor creates an object detector sensor with the given name and options.
func (*ObjectDetectorSensor) RPCConcurrency¶
func (s *ObjectDetectorSensor) RPCConcurrency() map[string]int
RPCConcurrency returns how many calls per method the backend may run at once, keyed by wire name. A detector overrides it to change the limit.
Example:
func (d *MyDetector) RPCConcurrency() map[string]int { return nil }
type ObjectMask¶
ObjectMask is the outline of one object: a mask laid over its box.
type ObjectMask struct {
Box BoundingBox `msgpack:"box" json:"box"` // Box the mask covers, normalized to the image the object was found in
Width int `msgpack:"width" json:"width"` // Mask width in pixels
Height int `msgpack:"height" json:"height"` // Mask height in pixels
Data []byte `msgpack:"data" json:"data"` // One byte per pixel, row by row from the top left: how likely the pixel belongs to the object (0 - 255). Above 127 counts as the object
}
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 ObjectProperty¶
ObjectProperty is a property name of an object detection sensor.
type ObjectProperty = string
Property names of an object detection sensor.
const (
ObjectPropertyDetected ObjectProperty = "detected" // Whether any object is currently detected
ObjectPropertyDetections ObjectProperty = "detections" // List of detected objects with labels and bounding boxes. The plugin that owns the sensor does not get the backend's updates of it
ObjectPropertyLabels ObjectProperty = "labels" // Unique labels of the current detections (auto-derived when reporting detections)
ObjectPropertyStaticDetections ObjectProperty = "staticDetections" // Settled objects hidden from events, kept visible for overlays. Written by the backend. The plugin that owns the sensor does not get the backend's updates of it
)
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
NewObjectSensor creates an object sensor with the given name and options.
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
GetDetections returns the detected objects with labels and bounding boxes. The plugin that owns the sensor does not get the backend's updates of it.
func (*ObjectSensor) GetLabels¶
func (s *ObjectSensor) GetLabels() []string
GetLabels returns the unique labels of the current detections (auto-derived when reporting detections).
func (*ObjectSensor) GetType¶
func (s *ObjectSensor) GetType() SensorType
func (*ObjectSensor) IsDetected¶
func (s *ObjectSensor) IsDetected() bool
IsDetected reports whether any object is currently detected.
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
type OccupancyProperty¶
OccupancyProperty is a property name of an occupancy sensor.
type OccupancyProperty = string
Property names of an occupancy sensor.
const (
OccupancyPropertyDetected OccupancyProperty = "detected" // Whether occupancy is detected (true = occupied)
)
type OccupancySensor¶
OccupancySensor reports occupancy/presence state.
type OccupancySensor struct{ BinarySensor }
func NewOccupancySensor¶
func NewOccupancySensor(name string, opts ...SensorOption) *OccupancySensor
NewOccupancySensor creates an occupancy sensor with the given name and options.
type OutletControl¶
OutletControl is a power outlet or smart plug. Override SetOn / SetOff (by embedding OutletControl in your own type and shadowing the methods) to drive hardware, then call the embedded OutletControl's methods to sync the SDK state. For hardware-pushed updates, call the embedded methods directly from your event handler.
An outlet that measures its load adds OutletCapabilityInUse and reports it with SetInUse.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type OutletControl struct{ BaseSensor }
func NewOutletControl¶
func NewOutletControl(name string, opts ...SensorOption) *OutletControl
NewOutletControl creates an outlet with the given name and options.
func (*OutletControl) GetCategory¶
func (s *OutletControl) GetCategory() SensorCategory
func (*OutletControl) GetType¶
func (s *OutletControl) GetType() SensorType
func (*OutletControl) IsInUse¶
func (s *OutletControl) IsInUse() bool
IsInUse reports whether the device plugged into the outlet draws power.
func (*OutletControl) IsOn¶
func (s *OutletControl) IsOn() bool
IsOn reports whether the outlet is on.
func (*OutletControl) SetInUse¶
func (s *OutletControl) SetInUse(inUse bool)
SetInUse reports whether the device plugged into the outlet draws power.
Example:
outlet.SetInUse(watts > 1)
func (*OutletControl) SetOff¶
func (s *OutletControl) SetOff() error
SetOff turns the outlet off.
Example:
outlet.SetOff()
func (*OutletControl) SetOn¶
func (s *OutletControl) SetOn() error
SetOn turns the outlet on.
Example:
outlet.SetOn()
func (*OutletControl) ToJSON¶
func (s *OutletControl) ToJSON() sensorJSON
type OutletProperty¶
OutletProperty is a property name of an outlet.
type OutletProperty = string
const (
OutletPropertyOn OutletProperty = "on" // Whether the outlet is on
OutletPropertyInUse OutletProperty = "inUse" // Whether the device plugged into the outlet draws power
)
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.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type PTZControl struct{ BaseSensor }
func NewPTZControl¶
func NewPTZControl(name string, opts ...SensorOption) *PTZControl
NewPTZControl creates a PTZ control with the given name and options.
func (*PTZControl) GetCategory¶
func (s *PTZControl) GetCategory() SensorCategory
func (*PTZControl) GetPosition¶
func (s *PTZControl) GetPosition() PTZPosition
GetPosition returns the current pan/tilt/zoom position.
func (*PTZControl) GetPresets¶
func (s *PTZControl) GetPresets() []string
GetPresets returns the available preset names, empty until SetPresets runs.
func (*PTZControl) GetTargetPreset¶
func (s *PTZControl) GetTargetPreset() (string, bool)
GetTargetPreset returns the target preset to move to. ok is false until a preset was requested.
func (*PTZControl) GetType¶
func (s *PTZControl) GetType() SensorType
func (*PTZControl) GetVelocity¶
func (s *PTZControl) GetVelocity() (PTZDirection, bool)
GetVelocity returns the current movement velocity (continuous move). ok is false until a continuous move was issued.
func (*PTZControl) GoHome¶
func (s *PTZControl) GoHome() error
GoHome moves the PTZ to the home position (0, 0, 0).
Example:
ptz.GoHome()
func (*PTZControl) IsMoving¶
func (s *PTZControl) IsMoving() bool
IsMoving reports whether the camera is currently moving.
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) error
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) error
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) error
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) error
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
type PTZProperty¶
PTZProperty is a property name of a PTZ control.
type PTZProperty = string
Property names of a PTZ control.
const (
PTZPropertyPosition PTZProperty = "position" // Current pan/tilt/zoom position
PTZPropertyMoving PTZProperty = "moving" // Whether the camera is currently moving
PTZPropertyPresets PTZProperty = "presets" // List of available preset names. Empty until `setPresets()` runs
PTZPropertyVelocity PTZProperty = "velocity" // Current movement velocity (continuous move). Undefined until a continuous move was issued
PTZPropertyTargetPreset PTZProperty = "targetPreset" // Target preset to move to. Undefined until a preset was requested
PTZPropertyRelativeMove PTZProperty = "relativeMove" // Relative displacement move command (write-only)
PTZPropertyHome PTZProperty = "home" // Move to the home position (write-only command, carries no state)
)
type PersonEmbedder¶
PersonEmbedder is implemented by plugins that turn the crop of a person into a vector of their appearance.
type PersonEmbedder interface {
// ModelSpec declares the expected input dimensions and trigger labels.
ModelSpec() ModelSpec
// EmbedPersons embeds a batch of person crops, each cut tight around the
// detected box and stretched to ModelSpec().Input. Must return exactly one
// PersonEmbeddingResult per input frame, in the same order; return an
// empty Embedding for a crop the model could not use.
EmbedPersons(frames []VideoFrameData) ([]PersonEmbeddingResult, error)
}
type PersonEmbedderSensor¶
PersonEmbedderSensor is a frame-only sensor that turns person crops into vectors of their appearance, to find the same person again when no face is visible. Pair with a PersonEmbedder implementation.
The crop is the person's box from the object detector, cut tight from the source frame. A vector describes clothing and build, not identity: it finds the same person on the same day, not after a change of clothes. Vectors from different models are not comparable, which is why every result carries its embedding model.
type PersonEmbedderSensor struct{ BaseSensor }
func NewPersonEmbedderSensor¶
func NewPersonEmbedderSensor(name string, opts ...SensorOption) *PersonEmbedderSensor
NewPersonEmbedderSensor creates a person embedder sensor with the given name and options.
func (*PersonEmbedderSensor) GetCategory¶
func (s *PersonEmbedderSensor) GetCategory() SensorCategory
func (*PersonEmbedderSensor) GetType¶
func (s *PersonEmbedderSensor) GetType() SensorType
func (*PersonEmbedderSensor) ToJSON¶
func (s *PersonEmbedderSensor) ToJSON() sensorJSON
type PersonEmbeddingResult¶
PersonEmbeddingResult is the return value of PersonEmbedder.EmbedPersons.
type PersonEmbeddingResult struct {
Embedding []float64 `msgpack:"embedding" json:"embedding"` // Embedding vector for the person in this crop, empty when the crop could not be embedded
EmbeddingModel string `msgpack:"embeddingModel" json:"embeddingModel"` // Identifier of the embedding model that produced the vector
}
type PowerProperty¶
PowerProperty is a property name of a power sensor.
type PowerProperty = string
Property names of a power sensor.
const (
PowerPropertyDetected PowerProperty = "detected" // Whether power is detected
)
type PowerSensor¶
PowerSensor reports power detection state.
type PowerSensor struct{ BinarySensor }
func NewPowerSensor¶
func NewPowerSensor(name string, opts ...SensorOption) *PowerSensor
NewPowerSensor creates a power sensor with the given name and options.
type PresenceProperty¶
PresenceProperty is a property name of a presence sensor.
type PresenceProperty = string
Property names of a presence sensor.
const (
PresencePropertyDetected PresenceProperty = "detected" // Whether the person is at home
PresencePropertyZone PresenceProperty = "zone" // Name of the zone the person is in while away, empty at home or when unknown
)
type PresenceSensor¶
PresenceSensor reports whether one person is at home, such as from a phone's location or a tracker. Unlike an occupancy sensor it follows a person, not a room.
type PresenceSensor struct{ BinarySensor }
func NewPresenceSensor¶
func NewPresenceSensor(name string, opts ...SensorOption) *PresenceSensor
NewPresenceSensor creates a presence sensor with the given name and options.
func (*PresenceSensor) GetZone¶
func (s *PresenceSensor) GetZone() string
GetZone returns the name of the zone the person is in while away, empty at home or when unknown.
func (*PresenceSensor) SetZone¶
func (s *PresenceSensor) SetZone(zone string)
SetZone reports the zone the person is in while away, empty when the zone is unknown.
Example:
presence.SetDetected(false)
presence.SetZone("Work")
type ProblemProperty¶
ProblemProperty is a property name of a problem sensor.
type ProblemProperty = string
Property names of a problem sensor.
const (
ProblemPropertyDetected ProblemProperty = "detected" // Whether a problem is detected
)
type ProblemSensor¶
ProblemSensor reports the problem state.
type ProblemSensor struct{ BinarySensor }
func NewProblemSensor¶
func NewProblemSensor(name string, opts ...SensorOption) *ProblemSensor
NewProblemSensor creates a problem sensor with the given name and options.
type PropertySpecOverride¶
PropertySpecOverride is what a plugin narrows or describes on one property of its sensor, on top of the type's spec: a thermostat's range, a chime's tones, an alarm without night mode. The host rejects a command outside it before it reaches the plugin, readings the plugin reports are not checked.
type PropertySpecOverride struct {
// Min is the lowest accepted value, inside the type's range.
Min *float64 `msgpack:"min,omitempty" json:"min,omitempty"`
// Max is the highest accepted value, inside the type's range.
Max *float64 `msgpack:"max,omitempty" json:"max,omitempty"`
// Step is the accepted increment, commands are rounded to it.
Step *float64 `msgpack:"step,omitempty" json:"step,omitempty"`
// Unit is the display unit, only for a property whose type sets none.
Unit string `msgpack:"unit,omitempty" json:"unit,omitempty"`
// Values lists the values an enum property supports at the device, a subset of the type's.
Values []any `msgpack:"values,omitempty" json:"values,omitempty"`
// Choices lists the values the device offers with their names at the device, for a property without a fixed enum.
Choices []SensorPropertyChoice `msgpack:"choices,omitempty" json:"choices,omitempty"`
// MaxLength is the longest accepted text.
MaxLength *int `msgpack:"maxLength,omitempty" json:"maxLength,omitempty"`
}
type RobotControl¶
RobotControl is the base of the robots that run on their own and take one-off commands, such as a vacuum or a lawn mower. The concrete control types embed it.
type RobotControl struct{ CommandControl }
func (*RobotControl) GetActivity¶
func (s *RobotControl) GetActivity() string
GetActivity returns what the robot does right now, empty before the first report.
func (*RobotControl) SetActivity¶
func (s *RobotControl) SetActivity(value string)
SetActivity reports what the robot does right now, one of the activities of its type.
Example:
robot.SetActivity(VacuumActivityDocked)
type SceneControl¶
SceneControl is a scene or script that runs on command and has no state of its own. Override Activate (by embedding SceneControl in your own type and shadowing the method) to run it on the device, then call the embedded method after success, which sets active for a moment (sceneAutoResetMs).
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type SceneControl struct {
BaseSensor
// contains filtered or unexported fields
}
func NewSceneControl¶
func NewSceneControl(name string, opts ...SensorOption) *SceneControl
NewSceneControl creates a scene with the given name and options.
func (*SceneControl) Activate¶
func (s *SceneControl) Activate() error
Activate runs the scene. The active property reads true for a moment and then false again, so the next command arrives the same way.
Example:
scene.Activate()
func (*SceneControl) GetCategory¶
func (s *SceneControl) GetCategory() SensorCategory
func (*SceneControl) GetType¶
func (s *SceneControl) GetType() SensorType
func (*SceneControl) IsActive¶
func (s *SceneControl) IsActive() bool
IsActive reports true for a moment after the scene ran, a command when written true.
func (*SceneControl) ToJSON¶
func (s *SceneControl) ToJSON() sensorJSON
type SceneProperty¶
SceneProperty is a property name of a scene.
type SceneProperty = string
const (
ScenePropertyActive SceneProperty = "active" // True for a moment after the scene ran, a command when written true
)
type SecuritySystem¶
SecuritySystem is a security system arm/disarm control sensor.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type SecuritySystem struct{ BaseSensor }
func NewSecuritySystem¶
func NewSecuritySystem(name string, opts ...SensorOption) *SecuritySystem
NewSecuritySystem creates a security system with the given name and options.
func (*SecuritySystem) GetCategory¶
func (s *SecuritySystem) GetCategory() SensorCategory
func (*SecuritySystem) GetCurrentState¶
func (s *SecuritySystem) GetCurrentState() SecuritySystemState
GetCurrentState returns the actual current state of the security system.
func (*SecuritySystem) GetTargetState¶
func (s *SecuritySystem) GetTargetState() SecuritySystemState
GetTargetState returns the desired target state (set by user, transitions to the current state), never SecuritySystemStateAlarmTriggered.
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) error
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
type SecuritySystemProperty¶
SecuritySystemProperty is a property name of a security system control.
type SecuritySystemProperty = string
Property names of a security system control.
const (
SecuritySystemPropertyCurrentState SecuritySystemProperty = "currentState" // The actual current state of the security system
SecuritySystemPropertyTargetState SecuritySystemProperty = "targetState" // The desired target state (set by user, transitions to currentState). Never `AlarmTriggered`
)
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 SegmentationFrame¶
SegmentationFrame is a crop handed to Segmenter.SegmentObjects, with the object it was cut for.
type SegmentationFrame struct {
VideoFrameData `msgpack:",inline"`
Box BoundingBox `msgpack:"box" json:"box"` // Box of the object to outline, normalized to this crop
}
type SegmentationResult¶
SegmentationResult is the return value of Segmenter.SegmentObjects.
type SegmentationResult struct {
Mask *ObjectMask `msgpack:"mask,omitempty" json:"mask,omitempty"` // The object's outline, nil when the model found no object at the box
}
type Segmenter¶
Segmenter is implemented by plugins that outline an object inside a crop.
type Segmenter interface {
// ModelSpec declares the expected input dimensions and trigger labels.
ModelSpec() ModelSpec
// SegmentObjects outlines objects in batch. Each frame is a region around
// one object, scaled to ModelSpec().Input, and carries the object's box.
// Must return exactly one SegmentationResult per input frame, in the same
// order; leave Mask nil when the model found no object at the box.
SegmentObjects(frames []SegmentationFrame) ([]SegmentationResult, error)
}
type SegmenterSensor¶
SegmenterSensor is a frame-only sensor that outlines an object inside a crop. Pair with a Segmenter implementation.
Each crop is a region around an object the object detector found, and the object's box inside it says which object is meant. The mask separates the object from its background, but not from a neighbour the detector saw as part of it: two people in one box come back as one outline.
type SegmenterSensor struct{ BaseSensor }
func NewSegmenterSensor¶
func NewSegmenterSensor(name string, opts ...SensorOption) *SegmenterSensor
NewSegmenterSensor creates a segmenter sensor with the given name and options.
func (*SegmenterSensor) GetCategory¶
func (s *SegmenterSensor) GetCategory() SensorCategory
func (*SegmenterSensor) GetType¶
func (s *SegmenterSensor) GetType() SensorType
func (*SegmenterSensor) ToJSON¶
func (s *SegmenterSensor) ToJSON() sensorJSON
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 returns the entity id of the sensor, provisional on a new sensor until registration.
GetID() string
// GetType returns the type of the sensor, fixed per sensor class.
GetType() SensorType
// GetName returns the name the plugin gave the sensor.
GetName() string
// GetDisplayName returns the full name shown to the user: inside a device the device name plus
// the short name, otherwise the plugin's name until the user renames the sensor.
GetDisplayName() string
// GetShortName returns the name inside its device, the same as GetDisplayName for a sensor without a device.
GetShortName() string
// GetDeviceInfo returns the device the sensor belongs to, nil without one and for a camera's own sensor.
GetDeviceInfo() *SensorDevice
// Primary reports whether the sensor is the main sensor of its device, called like the device when it stands alone.
Primary() bool
// GetNativeID returns the durable identity the plugin supplied, e.g. an upstream device id.
GetNativeID() string
// GetPluginID returns the id of the plugin that owns the sensor, set at registration.
GetPluginID() string
// GetAssignedCameraIDs returns the ids of the cameras the user assigned the sensor to.
GetAssignedCameraIDs() []string
// Connected reports whether the sensor is registered and its plugin is connected.
Connected() bool
// GetSourceState returns the state of the source behind the sensor. Seen from another plugin it is
// also unavailable while the camera the sensor belongs to is offline. A sensor that is unavailable
// or removed takes no writes.
GetSourceState() SensorSourceState
// GetCapabilities returns the capabilities the sensor advertises.
GetCapabilities() []string
// AssignmentLocked reports whether the sensor is bound to the camera it was added to, so the user cannot assign it elsewhere.
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. Control
// types dispatch it to their semantic methods (SetOn, SetTargetState), so
// plugin-side hardware overrides run, and return the setter's error. Writes
// run one at a time per sensor in arrival order, a newer value of a property
// replaces one still waiting, a command always runs. Read-only sensors ignore
// writes. 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
// OnSourceStateChanged fires when the source state changes.
OnSourceStateChanged(callback func(SensorSourceState)) *Disposable
// OnDeviceInfoChanged fires with the device whenever the sensor joins or leaves
// one, or its device, names or main-sensor role change.
OnDeviceInfoChanged(callback func(*SensorDevice)) *Disposable
// GetPropertySpecs returns the specs of the properties the plugin narrowed or described,
// resolved against the type's. A property without an entry follows its type's spec.
GetPropertySpecs() map[string]SensorPropertySpec
// OnPropertySpecsChanged fires with the property specs whenever the plugin changes them.
OnPropertySpecsChanged(callback func(map[string]SensorPropertySpec)) *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 SensorDevice¶
SensorDevice is the device a sensor belongs to, as consumers see it.
type SensorDevice struct {
// ID is the id of the device in camera.ui, not the plugin's DeviceInfo.ID.
ID string `msgpack:"id" json:"id"`
// Name is the name shown to the user, the source's name until the user renames the device.
Name string `msgpack:"name" json:"name"`
// Manufacturer is the manufacturer label (optional).
Manufacturer string `msgpack:"manufacturer,omitempty" json:"manufacturer,omitempty"`
// Model is the model label (optional).
Model string `msgpack:"model,omitempty" json:"model,omitempty"`
// Firmware is the firmware version (optional).
Firmware string `msgpack:"firmware,omitempty" json:"firmware,omitempty"`
// SerialNumber is the serial number (optional).
SerialNumber string `msgpack:"serialNumber,omitempty" json:"serialNumber,omitempty"`
}
type SensorOption¶
SensorOption configures a sensor at construction time.
type SensorOption func(*sensorOptions)
func WithAddress¶
func WithAddress(address string) SensorOption
WithAddress sets the sensor's current address at the source, e.g. a Home Assistant entity id. Display only, may change over time; identity is the native id.
func WithCapabilities¶
func WithCapabilities(capabilities ...string) SensorOption
WithCapabilities sets the capabilities the sensor starts with, such as the last known ones of an adopted sensor.
func WithDevice¶
func WithDevice(device *DeviceInfo) SensorOption
WithDevice sets the device the sensor belongs to. Sensors of the plugin that report the same DeviceInfo.ID form one device.
func WithNativeID¶
func WithNativeID(nativeID string) SensorOption
WithNativeID sets the plugin-supplied durable identity (e.g. an upstream device id). The host reconciles the sensor across restarts by (pluginId, nativeId); without it, identity falls back to (type, name) and a rename creates a new sensor.
func WithOrigin¶
func WithOrigin(origin string) SensorOption
WithOrigin marks the source system the sensor was imported from (e.g. "homeassistant"). Export bridges targeting that system skip the sensor.
func WithPrimary¶
func WithPrimary() SensorOption
WithPrimary marks the sensor as the main sensor of its device, called like the device when it stands alone.
func WithPropertySpec¶
func WithPropertySpec(property string, spec *PropertySpecOverride) SensorOption
WithPropertySpec sets what the device accepts for one property, see BaseSensor.SetPropertySpec.
type SensorPropertyChange¶
SensorPropertyChange is emitted when a sensor property value changes.
type SensorPropertyChange struct {
// Property is the property name.
Property string
// Value is the new property value.
Value any
// Timestamp is when the value was set (Unix ms).
Timestamp int64
}
type SensorPropertyChoice¶
SensorPropertyChoice is a value a device offers for a property, such as a chime tone or a TV input.
type SensorPropertyChoice struct {
// Value is the value written to the property.
Value any `msgpack:"value" json:"value"`
// Label is the name of the value at the device, shown as it comes.
Label string `msgpack:"label" json:"label"`
}
type SensorPropertySpec¶
SensorPropertySpec describes the values of one property: the type it carries, its enum values or numeric range, and whether it is a command or an internal detail.
type SensorPropertySpec struct {
// Type is the runtime type of the value.
Type SensorPropertyValueType `msgpack:"type" json:"type"`
// Values maps the value names of an enum property to their wire values. Names double as i18n key stems.
Values map[string]any `msgpack:"values,omitempty" json:"values,omitempty"`
// Keys lists the scalar member keys of an object property, exposed as value-path variables.
Keys []string `msgpack:"keys,omitempty" json:"keys,omitempty"`
// Min is the lowest accepted value of a numeric property.
Min *float64 `msgpack:"min,omitempty" json:"min,omitempty"`
// Max is the highest accepted value of a numeric property.
Max *float64 `msgpack:"max,omitempty" json:"max,omitempty"`
// Step is the accepted increment of a numeric property, commands are rounded to it.
Step *float64 `msgpack:"step,omitempty" json:"step,omitempty"`
// Unit is the display unit of the value, e.g. % or °C.
Unit string `msgpack:"unit,omitempty" json:"unit,omitempty"`
// Choices lists the values the device offers with their names at the device, for a property without a fixed enum.
Choices []SensorPropertyChoice `msgpack:"choices,omitempty" json:"choices,omitempty"`
// MaxLength is the longest accepted text of a string property.
MaxLength *int `msgpack:"maxLength,omitempty" json:"maxLength,omitempty"`
// Writable reports whether the property accepts external writes (commands, target states, virtual sensor state).
Writable bool `msgpack:"writable,omitempty" json:"writable,omitempty"`
// Command reports that each write is an action of its own: writes run in order and none replaces another.
Command bool `msgpack:"command,omitempty" json:"command,omitempty"`
// Internal reports that the property is no observable state, hidden from trigger and condition pickers.
Internal bool `msgpack:"internal,omitempty" json:"internal,omitempty"`
}
type SensorPropertyValueType¶
SensorPropertyValueType is the runtime type of a sensor property: boolean, number, string, enum or object.
type SensorPropertyValueType string
const (
SensorPropertyValueTypeBoolean SensorPropertyValueType = "boolean"
SensorPropertyValueTypeNumber SensorPropertyValueType = "number"
SensorPropertyValueTypeString SensorPropertyValueType = "string"
SensorPropertyValueTypeEnum SensorPropertyValueType = "enum"
SensorPropertyValueTypeObject SensorPropertyValueType = "object"
)
type SensorSourceState¶
SensorSourceState is the plugin's view of the source behind a sensor. Unavailable means wait (device or source unreachable, entity temporarily unavailable), Removed means the source reported the entity gone while it was reachable. Neither deletes the sensor: an adopted sensor is deleted by the user only.
type SensorSourceState string
const (
SensorSourceStateConnected SensorSourceState = "connected"
SensorSourceStateUnavailable SensorSourceState = "unavailable"
SensorSourceStateRemoved SensorSourceState = "removed"
)
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
SensorTypeFaceEmbedder SensorType = "faceEmbedder" // Face embedding generation from a face crop, for recognition against enrolled faces
SensorTypePersonEmbedder SensorType = "personEmbedder" // Appearance embedding of a person crop, to find the same person again without a face
SensorTypeSegmenter SensorType = "segmenter" // Outline of an object inside a crop, as a mask over its box
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
SensorTypeOutlet SensorType = "outlet" // Power outlet or smart plug
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
SensorTypeButton SensorType = "button" // Button with single, double and long presses
SensorTypeAccess SensorType = "access" // Access reader, such as a fingerprint or NFC reader
SensorTypeTemperature SensorType = "temperature" // Temperature sensor (°C)
SensorTypeHumidity SensorType = "humidity" // Humidity sensor (0-100%)
SensorTypeOccupancy SensorType = "occupancy" // Occupancy sensor, whether someone is in a room
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)
SensorTypeGlassBreak SensorType = "glassBreak" // Glass break detector
SensorTypeAirQuality SensorType = "airQuality" // Air quality level with particle and gas readings
SensorTypePresence SensorType = "presence" // Whether a person is at home
SensorTypeGarage SensorType = "garage" // Garage door opener
SensorTypeCover SensorType = "cover" // Blind, shutter, awning, curtain or other cover
SensorTypeThermostat SensorType = "thermostat" // Thermostat or air conditioner
SensorTypeFan SensorType = "fan" // Ceiling, desk or other fan
SensorTypeValve SensorType = "valve" // Water or gas valve, or an irrigation zone
SensorTypeScene SensorType = "scene" // Scene or script that runs on command
SensorTypeHumidifier SensorType = "humidifier" // Humidifier or dehumidifier
SensorTypeAirPurifier SensorType = "airPurifier" // Air purifier
SensorTypeWaterHeater SensorType = "waterHeater" // Water heater or boiler
SensorTypeVacuum SensorType = "vacuum" // Robot vacuum
SensorTypeLawnMower SensorType = "lawnMower" // Robot lawn mower
SensorTypeMediaPlayer SensorType = "mediaPlayer" // TV, speaker, receiver or projector
SensorTypeChime SensorType = "chime" // Chime that plays tones
SensorTypeDisplay SensorType = "display" // Text display on a device
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.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type SirenControl struct{ BaseSensor }
func NewSirenControl¶
func NewSirenControl(name string, opts ...SensorOption) *SirenControl
NewSirenControl creates a siren control with the given name and options.
func (*SirenControl) GetCategory¶
func (s *SirenControl) GetCategory() SensorCategory
func (*SirenControl) GetType¶
func (s *SirenControl) GetType() SensorType
func (*SirenControl) GetVolume¶
func (s *SirenControl) GetVolume() int
GetVolume returns the volume level (0-100).
func (*SirenControl) IsActive¶
func (s *SirenControl) IsActive() bool
IsActive reports whether the siren is currently active.
func (*SirenControl) SetActive¶
func (s *SirenControl) SetActive() error
SetActive activates the siren.
Example:
siren.SetActive()
func (*SirenControl) SetInactive¶
func (s *SirenControl) SetInactive() error
SetInactive deactivates the siren.
Example:
siren.SetInactive()
func (*SirenControl) SetVolume¶
func (s *SirenControl) SetVolume(value int) error
SetVolume sets the siren volume (clamped to [0,100]).
Example:
siren.SetVolume(80)
func (*SirenControl) ToJSON¶
func (s *SirenControl) ToJSON() sensorJSON
type SirenProperty¶
SirenProperty is a property name of a siren control.
type SirenProperty = string
Property names of a siren control.
const (
SirenPropertyActive SirenProperty = "active" // Whether the siren is currently active
SirenPropertyVolume SirenProperty = "volume" // Volume level (0-100)
)
type SmokeProperty¶
SmokeProperty is a property name of a smoke sensor.
type SmokeProperty = string
Property names of a smoke sensor.
const (
SmokePropertyDetected SmokeProperty = "detected" // Whether smoke is detected
)
type SmokeSensor¶
SmokeSensor reports smoke detection state.
type SmokeSensor struct{ BinarySensor }
func NewSmokeSensor¶
func NewSmokeSensor(name string, opts ...SensorOption) *SmokeSensor
NewSmokeSensor creates a smoke sensor with the given name and options.
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.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type SwitchControl struct{ BaseSensor }
func NewSwitchControl¶
func NewSwitchControl(name string, opts ...SensorOption) *SwitchControl
NewSwitchControl creates a switch control with the given name and options.
func (*SwitchControl) GetCategory¶
func (s *SwitchControl) GetCategory() SensorCategory
func (*SwitchControl) GetType¶
func (s *SwitchControl) GetType() SensorType
func (*SwitchControl) IsOn¶
func (s *SwitchControl) IsOn() bool
IsOn reports whether the switch is on.
func (*SwitchControl) SetOff¶
func (s *SwitchControl) SetOff() error
SetOff turns the switch off.
Example:
sw.SetOff()
func (*SwitchControl) SetOn¶
func (s *SwitchControl) SetOn() error
SetOn turns the switch on.
Example:
sw.SetOn()
func (*SwitchControl) ToJSON¶
func (s *SwitchControl) ToJSON() sensorJSON
type SwitchProperty¶
SwitchProperty is a property name of a switch control.
type SwitchProperty = string
Property names of a switch control.
const (
SwitchPropertyOn SwitchProperty = "on" // Whether the switch is on
)
type TamperProperty¶
TamperProperty is a property name of a tamper sensor.
type TamperProperty = string
Property names of a tamper sensor.
const (
TamperPropertyDetected TamperProperty = "detected" // Whether tampering is detected
)
type TamperSensor¶
TamperSensor reports tampering detection state.
type TamperSensor struct{ BinarySensor }
func NewTamperSensor¶
func NewTamperSensor(name string, opts ...SensorOption) *TamperSensor
NewTamperSensor creates a tamper sensor with the given name and options.
type TemperatureInfo¶
TemperatureInfo reports the current temperature in degrees Celsius.
type TemperatureInfo struct{ MeasurementInfo }
func NewTemperatureInfo¶
func NewTemperatureInfo(name string, opts ...SensorOption) *TemperatureInfo
NewTemperatureInfo creates a temperature info sensor with the given name and options.
type TemperatureProperty¶
TemperatureProperty is a property name of a temperature sensor.
type TemperatureProperty = string
Property names of a temperature sensor.
const (
TemperaturePropertyCurrent TemperatureProperty = "current" // Current temperature in degrees Celsius
)
type ThermostatAction¶
ThermostatAction is what a thermostat does right now.
type ThermostatAction = string
const (
ThermostatActionOff ThermostatAction = "off" // Thermostat is off
ThermostatActionIdle ThermostatAction = "idle" // Thermostat is on but not working right now
ThermostatActionHeating ThermostatAction = "heating" // Thermostat heats
ThermostatActionCooling ThermostatAction = "cooling" // Thermostat cools
ThermostatActionDrying ThermostatAction = "drying" // Thermostat dries the air
ThermostatActionFan ThermostatAction = "fan" // Thermostat runs only the fan
ThermostatActionPreheating ThermostatAction = "preheating" // Thermostat warms up before it heats
ThermostatActionDefrosting ThermostatAction = "defrosting" // Thermostat defrosts its outdoor unit
)
type ThermostatControl¶
ThermostatControl is a thermostat or air conditioner. Temperatures are in °C, a plugin converts from the device's unit. Override SetTargetTemperature, SetMode and the other commands (by embedding ThermostatControl in your own type and shadowing the methods) to drive hardware, then call the embedded ThermostatControl's methods to sync the SDK state. Report readings with SetCurrentTemperature, SetAction and SetCurrentHumidity.
Narrow the modes to those the device has with SetPropertySpec(ThermostatPropertyMode, &PropertySpecOverride{Values: ...}), and its temperature range with Min, Max and Step on the target properties. Presets and fan modes are the device's own, set them as Choices.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type ThermostatControl struct{ BaseSensor }
func NewThermostatControl¶
func NewThermostatControl(name string, opts ...SensorOption) *ThermostatControl
NewThermostatControl creates a thermostat with the given name and options.
func (*ThermostatControl) GetAction¶
func (s *ThermostatControl) GetAction() ThermostatAction
GetAction returns what the thermostat does right now, a ThermostatAction, empty before the first report.
func (*ThermostatControl) GetCategory¶
func (s *ThermostatControl) GetCategory() SensorCategory
func (*ThermostatControl) GetCurrentHumidity¶
func (s *ThermostatControl) GetCurrentHumidity() (float64, bool)
GetCurrentHumidity returns the current humidity in percent, false before the first reading.
func (*ThermostatControl) GetCurrentTemperature¶
func (s *ThermostatControl) GetCurrentTemperature() (float64, bool)
GetCurrentTemperature returns the current temperature in °C, false before the first reading.
func (*ThermostatControl) GetFanMode¶
func (s *ThermostatControl) GetFanMode() string
GetFanMode returns the active fan mode, one of the choices the device offers.
func (*ThermostatControl) GetMode¶
func (s *ThermostatControl) GetMode() ThermostatMode
GetMode returns the mode, a ThermostatMode.
func (*ThermostatControl) GetPreset¶
func (s *ThermostatControl) GetPreset() string
GetPreset returns the active preset, one of the choices the device offers.
func (*ThermostatControl) GetTargetHumidity¶
func (s *ThermostatControl) GetTargetHumidity() int
GetTargetHumidity returns the humidity in percent the thermostat keeps.
func (*ThermostatControl) GetTargetTemperature¶
func (s *ThermostatControl) GetTargetTemperature() float64
GetTargetTemperature returns the temperature the thermostat heats or cools to, in °C.
func (*ThermostatControl) GetTargetTemperatureHigh¶
func (s *ThermostatControl) GetTargetTemperatureHigh() float64
GetTargetTemperatureHigh returns the upper end of the target range in °C.
func (*ThermostatControl) GetTargetTemperatureLow¶
func (s *ThermostatControl) GetTargetTemperatureLow() float64
GetTargetTemperatureLow returns the lower end of the target range in °C.
func (*ThermostatControl) GetType¶
func (s *ThermostatControl) GetType() SensorType
func (*ThermostatControl) SetAction¶
func (s *ThermostatControl) SetAction(value ThermostatAction)
SetAction reports what the thermostat does right now.
Example:
thermostat.SetAction(ThermostatActionHeating)
func (*ThermostatControl) SetCurrentHumidity¶
func (s *ThermostatControl) SetCurrentHumidity(value float64)
SetCurrentHumidity reports the current humidity in percent.
Example:
thermostat.SetCurrentHumidity(45)
func (*ThermostatControl) SetCurrentTemperature¶
func (s *ThermostatControl) SetCurrentTemperature(value float64)
SetCurrentTemperature reports the current temperature in °C.
Example:
thermostat.SetCurrentTemperature(20.4)
func (*ThermostatControl) SetFanMode¶
func (s *ThermostatControl) SetFanMode(value string) error
SetFanMode sets the fan mode, one of the fan mode choices.
Example:
thermostat.SetFanMode("low")
func (*ThermostatControl) SetMode¶
func (s *ThermostatControl) SetMode(value ThermostatMode) error
SetMode sets the mode.
Example:
thermostat.SetMode(ThermostatModeHeat)
func (*ThermostatControl) SetPreset¶
func (s *ThermostatControl) SetPreset(value string) error
SetPreset sets the preset, one of the preset choices.
Example:
thermostat.SetPreset("eco")
func (*ThermostatControl) SetTargetHumidity¶
func (s *ThermostatControl) SetTargetHumidity(value int) error
SetTargetHumidity sets the target humidity in percent.
Example:
thermostat.SetTargetHumidity(45)
func (*ThermostatControl) SetTargetTemperature¶
func (s *ThermostatControl) SetTargetTemperature(value float64) error
SetTargetTemperature sets the target temperature in °C.
Example:
thermostat.SetTargetTemperature(21.5)
func (*ThermostatControl) SetTargetTemperatureHigh¶
func (s *ThermostatControl) SetTargetTemperatureHigh(value float64) error
SetTargetTemperatureHigh sets the upper end of the target range in °C.
Example:
thermostat.SetTargetTemperatureHigh(24)
func (*ThermostatControl) SetTargetTemperatureLow¶
func (s *ThermostatControl) SetTargetTemperatureLow(value float64) error
SetTargetTemperatureLow sets the lower end of the target range in °C.
Example:
thermostat.SetTargetTemperatureLow(19)
func (*ThermostatControl) ToJSON¶
func (s *ThermostatControl) ToJSON() sensorJSON
type ThermostatMode¶
ThermostatMode is what a thermostat is set to do.
type ThermostatMode = string
const (
ThermostatModeOff ThermostatMode = "off" // Thermostat is off
ThermostatModeHeat ThermostatMode = "heat" // Heats to the target temperature
ThermostatModeCool ThermostatMode = "cool" // Cools to the target temperature
ThermostatModeHeatCool ThermostatMode = "heat_cool" // Heats and cools to stay inside a target range
ThermostatModeAuto ThermostatMode = "auto" // The device decides by its own schedule or logic
ThermostatModeDry ThermostatMode = "dry" // Dries the air
ThermostatModeFanOnly ThermostatMode = "fan_only" // Runs only the fan, without heating or cooling
)
type ThermostatProperty¶
ThermostatProperty is a property name of a thermostat. Temperatures are in °C.
type ThermostatProperty = string
Property names of a thermostat.
const (
ThermostatPropertyCurrentTemperature ThermostatProperty = "currentTemperature" // Current temperature in °C
ThermostatPropertyTargetTemperature ThermostatProperty = "targetTemperature" // Temperature the thermostat heats or cools to, in °C
ThermostatPropertyTargetTemperatureLow ThermostatProperty = "targetTemperatureLow" // Lower end of the target range in °C
ThermostatPropertyTargetTemperatureHigh ThermostatProperty = "targetTemperatureHigh" // Upper end of the target range in °C
ThermostatPropertyMode ThermostatProperty = "mode" // Mode, a ThermostatMode
ThermostatPropertyAction ThermostatProperty = "action" // What the thermostat does right now, a ThermostatAction
ThermostatPropertyCurrentHumidity ThermostatProperty = "currentHumidity" // Current humidity in percent
ThermostatPropertyPreset ThermostatProperty = "preset" // Active preset, one of the choices the device offers
ThermostatPropertyFanMode ThermostatProperty = "fanMode" // Active fan mode, one of the choices the device offers
ThermostatPropertyTargetHumidity ThermostatProperty = "targetHumidity" // Humidity in percent the thermostat keeps
)
type TrackVelocity¶
TrackVelocity is the signed centroid velocity in normalized units per second. Prefer it over deriving velocity from frame-to-frame position deltas.
type TrackVelocity struct {
// X is the horizontal velocity, positive moves right.
X float64 `msgpack:"x" json:"x"`
// Y is the vertical velocity, positive moves down.
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 second
TrackVelocity *TrackVelocity `msgpack:"trackVelocity,omitempty" json:"trackVelocity,omitempty"` // Signed centroid velocity in normalized units per second
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
}
type VacuumActivity¶
VacuumActivity is what a vacuum does right now.
type VacuumActivity = string
const (
VacuumActivityCleaning VacuumActivity = "cleaning" // Vacuum is cleaning
VacuumActivityDocked VacuumActivity = "docked" // Vacuum is in its dock
VacuumActivityIdle VacuumActivity = "idle" // Vacuum is off its dock and not cleaning
VacuumActivityPaused VacuumActivity = "paused" // Vacuum paused where it is
VacuumActivityReturning VacuumActivity = "returning" // Vacuum drives back to its dock
VacuumActivityError VacuumActivity = "error" // Vacuum reports an error
)
type VacuumCommand¶
VacuumCommand is a command a vacuum takes.
type VacuumCommand = string
const (
VacuumCommandStart VacuumCommand = "start" // Start or resume cleaning
VacuumCommandPause VacuumCommand = "pause" // Pause cleaning where the vacuum is
VacuumCommandStop VacuumCommand = "stop" // Stop cleaning
VacuumCommandDock VacuumCommand = "dock" // Send the vacuum back to its dock
VacuumCommandLocate VacuumCommand = "locate" // Make the vacuum beep so it can be found
VacuumCommandSpot VacuumCommand = "spot" // Clean the spot around the vacuum
)
type VacuumControl¶
VacuumControl is a robot vacuum. Override Start, Pause, Stop, Dock, Locate, Spot and SetFanSpeed (by embedding VacuumControl in your own type and shadowing the methods) to drive hardware, then call the embedded VacuumControl's methods after success. Report what the vacuum does with SetActivity.
Narrow the commands to those the vacuum takes with SetPropertySpec(VacuumPropertyCommand, &PropertySpecOverride{Values: ...}). The suction levels come as choices with the fanSpeed capability: SetPropertySpec(VacuumPropertyFanSpeed, &PropertySpecOverride{Choices: ...}).
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type VacuumControl struct{ RobotControl }
func NewVacuumControl¶
func NewVacuumControl(name string, opts ...SensorOption) *VacuumControl
NewVacuumControl creates a vacuum with the given name and options.
func (*VacuumControl) Dock¶
func (s *VacuumControl) Dock() error
Dock sends the vacuum back to its dock.
Example:
vacuum.Dock()
func (*VacuumControl) GetFanSpeed¶
func (s *VacuumControl) GetFanSpeed() string
GetFanSpeed returns the suction level, one of the choices the plugin sets.
func (*VacuumControl) Locate¶
func (s *VacuumControl) Locate() error
Locate makes the vacuum beep so it can be found.
Example:
vacuum.Locate()
func (*VacuumControl) Pause¶
func (s *VacuumControl) Pause() error
Pause pauses cleaning where the vacuum is.
Example:
vacuum.Pause()
func (*VacuumControl) SetFanSpeed¶
func (s *VacuumControl) SetFanSpeed(value string) error
SetFanSpeed sets the suction level, one of the suction level choices.
Example:
vacuum.SetFanSpeed("turbo")
func (*VacuumControl) Spot¶
func (s *VacuumControl) Spot() error
Spot cleans the spot around the vacuum.
Example:
vacuum.Spot()
func (*VacuumControl) Start¶
func (s *VacuumControl) Start() error
Start starts or resumes cleaning.
Example:
vacuum.Start()
func (*VacuumControl) Stop¶
func (s *VacuumControl) Stop() error
Stop stops cleaning.
Example:
vacuum.Stop()
type VacuumProperty¶
VacuumProperty is a property name of a vacuum.
type VacuumProperty = string
const (
VacuumPropertyActivity VacuumProperty = "activity" // What the vacuum does right now, a VacuumActivity
VacuumPropertyCommand VacuumProperty = "command" // One-off VacuumCommand when written, empty again right after
VacuumPropertyFanSpeed VacuumProperty = "fanSpeed" // Suction level, one of the choices the plugin sets
)
type ValveConfig¶
ValveConfig describes a valve at construction.
type ValveConfig struct {
// Index is the position of the valve on its device, from 1, e.g. the zone of an irrigation controller.
Index int
}
type ValveControl¶
ValveControl is a water or gas valve, or an irrigation zone. Override SetTargetState, SetTargetPosition and SetDuration (by embedding ValveControl in your own type and shadowing the methods) to drive hardware, then call the embedded ValveControl's methods to sync the SDK state. Report what the hardware does with SetCurrentState, SetCurrentPosition and SetRemaining.
A valve that opens part way adds ValveCapabilityPosition, one that closes by itself after a set time ValveCapabilityDuration. SetKind says what the valve controls, ValveConfig.Index orders the zones of one irrigation controller.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type ValveControl struct{ BaseSensor }
func NewValveControl¶
func NewValveControl(name string, config ValveConfig, opts ...SensorOption) *ValveControl
NewValveControl creates a valve with the given name, config and options.
func (*ValveControl) GetCategory¶
func (s *ValveControl) GetCategory() SensorCategory
func (*ValveControl) GetCurrentPosition¶
func (s *ValveControl) GetCurrentPosition() int
GetCurrentPosition returns the current position, 0 (closed) to 100 (open).
func (*ValveControl) GetCurrentState¶
func (s *ValveControl) GetCurrentState() ValveState
GetCurrentState returns the current state, a ValveState.
func (*ValveControl) GetDuration¶
func (s *ValveControl) GetDuration() int
GetDuration returns the seconds the valve stays open before it closes by itself.
func (*ValveControl) GetIndex¶
func (s *ValveControl) GetIndex() int
GetIndex returns the position of the valve on its device, from 1, 0 when not set.
func (*ValveControl) GetKind¶
func (s *ValveControl) GetKind() ValveKind
GetKind returns what the valve controls, a ValveKind, empty when the plugin did not say.
func (*ValveControl) GetRemaining¶
func (s *ValveControl) GetRemaining() int
GetRemaining returns the seconds left until the open valve closes by itself.
func (*ValveControl) GetTargetPosition¶
func (s *ValveControl) GetTargetPosition() int
GetTargetPosition returns the target position, 0 (closed) to 100 (open).
func (*ValveControl) GetTargetState¶
func (s *ValveControl) GetTargetState() ValveState
GetTargetState returns the target state, Open or Closed.
func (*ValveControl) GetType¶
func (s *ValveControl) GetType() SensorType
func (*ValveControl) SetCurrentPosition¶
func (s *ValveControl) SetCurrentPosition(position int)
SetCurrentPosition reports the position of the valve, 0 (closed) to 100 (open).
Example:
valve.SetCurrentPosition(30)
func (*ValveControl) SetCurrentState¶
func (s *ValveControl) SetCurrentState(value ValveState)
SetCurrentState reports the state of the valve.
Example:
valve.SetCurrentState(ValveStateOpening)
func (*ValveControl) SetDuration¶
func (s *ValveControl) SetDuration(seconds int) error
SetDuration sets how long the valve stays open, in seconds until it closes by itself.
Example:
valve.SetDuration(900)
func (*ValveControl) SetKind¶
func (s *ValveControl) SetKind(kind ValveKind)
SetKind says what the valve controls. Smart homes show it by its kind, and Home Assistant takes it as the device class.
Example:
valve.SetKind(ValveKindGas)
func (*ValveControl) SetRemaining¶
func (s *ValveControl) SetRemaining(seconds int)
SetRemaining reports how long the open valve has left, in seconds until it closes by itself, 0 when closed.
Example:
valve.SetRemaining(420)
func (*ValveControl) SetTargetPosition¶
func (s *ValveControl) SetTargetPosition(position int) error
SetTargetPosition opens the valve to a position, 0 (closed) to 100 (open). Writes both targetPosition and currentPosition.
Example:
valve.SetTargetPosition(50)
func (*ValveControl) SetTargetState¶
func (s *ValveControl) SetTargetState(value ValveState) error
SetTargetState opens or closes the valve. Writes both targetState and currentState.
Example:
valve.SetTargetState(ValveStateOpen)
func (*ValveControl) ToJSON¶
func (s *ValveControl) ToJSON() sensorJSON
type ValveKind¶
ValveKind says what a valve controls, it decides how smart homes show it.
type ValveKind = string
const (
ValveKindWater ValveKind = "water" // A water valve
ValveKindGas ValveKind = "gas" // A gas valve
ValveKindIrrigation ValveKind = "irrigation" // An irrigation or sprinkler valve
)
type ValveProperty¶
ValveProperty is a property name of a valve.
type ValveProperty = string
const (
ValvePropertyCurrentState ValveProperty = "currentState" // Current state, a ValveState
ValvePropertyTargetState ValveProperty = "targetState" // Target state, Open or Closed
ValvePropertyCurrentPosition ValveProperty = "currentPosition" // Current position, 0 (closed) to 100 (open)
ValvePropertyTargetPosition ValveProperty = "targetPosition" // Target position, 0 (closed) to 100 (open)
ValvePropertyDuration ValveProperty = "duration" // Seconds the valve stays open before it closes by itself
ValvePropertyRemaining ValveProperty = "remaining" // Seconds left until the open valve closes by itself
ValvePropertyKind ValveProperty = "kind" // What the valve controls, a ValveKind
ValvePropertyIndex ValveProperty = "index" // Position of the valve on its device, from 1, 0 when not set
)
type ValveState¶
ValveState is the state of a valve. A target takes Open and Closed.
type ValveState int
const (
ValveStateOpen ValveState = 0 // Valve is open, fully or part-way
ValveStateClosed ValveState = 1 // Valve is fully closed
ValveStateOpening ValveState = 2 // Valve is moving towards open
ValveStateClosing ValveState = 3 // Valve is moving towards closed
)
type VibrationProperty¶
VibrationProperty is a property name of a vibration sensor.
type VibrationProperty = string
Property names of a vibration sensor.
const (
VibrationPropertyDetected VibrationProperty = "detected" // Whether vibration is detected
)
type VibrationSensor¶
VibrationSensor reports vibration detection state.
type VibrationSensor struct{ BinarySensor }
func NewVibrationSensor¶
func NewVibrationSensor(name string, opts ...SensorOption) *VibrationSensor
NewVibrationSensor creates a vibration sensor with the given name and options.
type VideoInputSpec¶
VideoInputSpec describes the expected video input dimensions and pixel format for a detector model.
type VideoInputSpec struct {
Width int `msgpack:"width" json:"width"` // Expected frame width in pixels
Height int `msgpack:"height" json:"height"` // Expected frame height in pixels
Format FrameFormat `msgpack:"format" json:"format"` // Pixel format: rgb = 3 bytes/pixel, gray = 1 byte/pixel, nv12 = YUV semi-planar
}
type WaterHeaterControl¶
WaterHeaterControl is a water heater or boiler that keeps its water at a target temperature. Override SetMode, SetTargetTemperature and SetAway (by embedding WaterHeaterControl in your own type and shadowing the methods) to drive hardware, then call the embedded WaterHeaterControl's methods to sync the SDK state. Report the water temperature with SetCurrentTemperature.
Narrow the modes to those the device has with SetPropertySpec(WaterHeaterPropertyMode, &PropertySpecOverride{Values: ...}), and its temperature range with Min, Max and Step on the target temperature. Temperatures are always in °C.
When the device refuses a command, return an error from the override instead of calling the embedded method: the write fails for whoever sent it and the state stays as it was.
type WaterHeaterControl struct{ BaseSensor }
func NewWaterHeaterControl¶
func NewWaterHeaterControl(name string, opts ...SensorOption) *WaterHeaterControl
NewWaterHeaterControl creates a water heater with the given name and options.
func (*WaterHeaterControl) GetCategory¶
func (s *WaterHeaterControl) GetCategory() SensorCategory
func (*WaterHeaterControl) GetCurrentTemperature¶
func (s *WaterHeaterControl) GetCurrentTemperature() (float64, bool)
GetCurrentTemperature returns the current water temperature in °C, false before the first reading.
func (*WaterHeaterControl) GetMode¶
func (s *WaterHeaterControl) GetMode() WaterHeaterMode
GetMode returns the operating mode, a WaterHeaterMode, a command when written.
func (*WaterHeaterControl) GetTargetTemperature¶
func (s *WaterHeaterControl) GetTargetTemperature() float64
GetTargetTemperature returns the target water temperature in °C.
func (*WaterHeaterControl) GetType¶
func (s *WaterHeaterControl) GetType() SensorType
func (*WaterHeaterControl) IsAway¶
func (s *WaterHeaterControl) IsAway() bool
IsAway reports true while the away mode is on.
func (*WaterHeaterControl) SetAway¶
func (s *WaterHeaterControl) SetAway(away bool) error
SetAway switches the away mode on, or off with false.
Example:
boiler.SetAway(true)
func (*WaterHeaterControl) SetCurrentTemperature¶
func (s *WaterHeaterControl) SetCurrentTemperature(value float64)
SetCurrentTemperature reports the current water temperature in °C.
Example:
boiler.SetCurrentTemperature(48.5)
func (*WaterHeaterControl) SetMode¶
func (s *WaterHeaterControl) SetMode(value WaterHeaterMode) error
SetMode sets the operating mode, one of the modes the water heater offers.
Example:
boiler.SetMode(WaterHeaterModeEco)
func (*WaterHeaterControl) SetTargetTemperature¶
func (s *WaterHeaterControl) SetTargetTemperature(value float64) error
SetTargetTemperature sets the target temperature in °C.
Example:
boiler.SetTargetTemperature(55)
func (*WaterHeaterControl) ToJSON¶
func (s *WaterHeaterControl) ToJSON() sensorJSON
type WaterHeaterMode¶
WaterHeaterMode is the operating mode of a water heater.
type WaterHeaterMode = string
const (
WaterHeaterModeOff WaterHeaterMode = "off" // Water heater is off
WaterHeaterModeEco WaterHeaterMode = "eco" // Energy-saving mode
WaterHeaterModeElectric WaterHeaterMode = "electric" // Heats with electricity only
WaterHeaterModeGas WaterHeaterMode = "gas" // Heats with gas only
WaterHeaterModeHeatPump WaterHeaterMode = "heat_pump" // Heats with the heat pump only
WaterHeaterModeHighDemand WaterHeaterMode = "high_demand" // Heats more to keep up with a high demand for hot water
WaterHeaterModePerformance WaterHeaterMode = "performance" // Heats as fast as it can
WaterHeaterModeAuto WaterHeaterMode = "auto" // The device decides by its own schedule or logic
WaterHeaterModeHeat WaterHeaterMode = "heat" // Heats the water
WaterHeaterModeOn WaterHeaterMode = "on" // Running in a mode without a name of its own
)
type WaterHeaterProperty¶
WaterHeaterProperty is a property name of a water heater.
type WaterHeaterProperty = string
Property names of a water heater.
const (
WaterHeaterPropertyCurrentTemperature WaterHeaterProperty = "currentTemperature" // Current water temperature in °C
WaterHeaterPropertyTargetTemperature WaterHeaterProperty = "targetTemperature" // Target water temperature in °C
WaterHeaterPropertyMode WaterHeaterProperty = "mode" // Operating mode, a WaterHeaterMode, a command when written
WaterHeaterPropertyAway WaterHeaterProperty = "away" // True while the away mode is on
)