Documentation ¶
Index ¶
- Constants
- func Color16ToRGB(colorStr string) (red, green, blue int, err error)
- type AdapterHandler
- type BinarySensor
- type BinarySensorHandler
- type Capability
- type Device
- func (d *Device) AddProperty(p properties.Entity)
- func (d *Device) GetAction(id string) actions.Action
- func (d *Device) GetActions() map[string]actions.Action
- func (d *Device) GetAdapter() AdapterHandler
- func (d *Device) GetAtContext() string
- func (d *Device) GetAtType() []string
- func (d *Device) GetBaseHref() string
- func (d *Device) GetCredentialsRequired() bool
- func (d *Device) GetDescription() string
- func (d *Device) GetDevice() *Device
- func (d *Device) GetEvent(id string) events.Event
- func (d *Device) GetEvents() map[string]events.Event
- func (d *Device) GetHandler() AdapterHandler
- func (d *Device) GetId() string
- func (d *Device) GetLink() []DeviceLink
- func (d *Device) GetPin() *DevicePin
- func (d *Device) GetProperties() map[string]properties.Entity
- func (d *Device) GetProperty(id string) properties.Entity
- func (d *Device) GetTitle() string
- func (d *Device) HandleRemoved()
- func (d *Device) NotifyPropertyChanged(p properties.PropertyDescription)
- func (d *Device) SetCredentials(username, password string) error
- func (d *Device) SetHandler(h AdapterHandler)
- func (d *Device) SetPin(pin string) error
- func (d *Device) ToMessage() *messages.Device
- type DeviceActions
- type DeviceDescription
- type DeviceEvents
- type DeviceForm
- type DeviceLink
- type DevicePin
- type DeviceProperties
- type Entity
- type Light
- type LightHandler
- type MotionSensor
- type MultiLevelSensor
- type MultiLevelSwitch
- type OnOffSwitch
- type OnOffSwitchDevice
- type Option
- type SmartPlug
- type SmartPlugDevice
- type Thermostat
Constants ¶
View Source
const ( TypeString = "string" TypeBoolean = "boolean" TypeInteger = "integer" TypeNumber = "number" UnitHectopascal = "hectopascal" UnitKelvin = "kelvin" UnitPercentage = "percentage" UnitArcDegrees = "arcdegrees" UnitCelsius = "celsius" UnitLux = "lux" UnitSeconds = "seconds" UnitPPM = "ppm" CapabilityAlarm Capability = "Alarm" CapabilityAirQualitySensor Capability = "AirQualitySensor" CapabilityBarometricPressureSensor Capability = "BarometricPressureSensor" CapabilityBinarySensor Capability = "BinarySensor" CapabilityCamera Capability = "Camera" CapabilityColorControl Capability = "ColorControl" CapabilityColorSensor Capability = "ColorSensor" CapabilityDoorSensor Capability = "DoorSensor" CapabilityEnergyMonitor Capability = "EnergyMonitor" CapabilityHumiditySensor Capability = "HumiditySensor" CapabilityLeakSensor Capability = "LeakSensor" CapabilityLight Capability = "Light" CapabilityLock Capability = "Lock" CapabilityMotionSensor Capability = "MotionSensor" CapabilityMultiLevelSensor Capability = "MultiLevelSensor" CapabilityMultiLevelSwitch Capability = "MultiLevelSwitch" CapabilityOnOffSwitch Capability = "OnOffSwitch" CapabilityPushButton Capability = "PushButton" CapabilitySmartPlug Capability = "SmartPlug" CapabilitySmokeSensor Capability = "SmokeSensor" CapabilityTemperatureSensor Capability = "TemperatureSensor" CapabilityThermostat Capability = "Thermostat" CapabilityVideoCamera Capability = "VideoCamera" OpenProperty = "OpenProperty" PushedProperty = "PushedProperty" SmokeProperty = "SmokeProperty" TargetTemperatureProperty = "TargetTemperatureProperty" TemperatureProperty = "TemperatureProperty" ThermostatModeProperty = "ThermostatModeProperty" VideoProperty = "VideoProperty" VoltageProperty = "VoltageProperty" )
Variables ¶
This section is empty.
Functions ¶
func Color16ToRGB ¶
Types ¶
type AdapterHandler ¶
type AdapterHandler interface { GetId() string SendPropertyChangedNotification(deviceId string, p properties.PropertyDescription) Send(messageType messages.MessageType, data any) }
type BinarySensor ¶
type BinarySensor struct { *Device Bool properties.BooleanEntity }
func NewBinarySensor ¶
func NewBinarySensor(id string, opts ...Option) *BinarySensor
func (*BinarySensor) AddProperties ¶
func (device *BinarySensor) AddProperties(props ...properties.Entity)
func (*BinarySensor) IsOn ¶
func (device *BinarySensor) IsOn() bool
type BinarySensorHandler ¶
type BinarySensorHandler interface {
IsOn() bool
}
type Capability ¶
type Capability = string
type Device ¶
type Device struct { Context string `json:"@context,omitempty"` AtType []Capability `json:"@type,omitempty"` Id string `json:"id,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Links []DeviceLink `json:"links,omitempty"` Forms []DeviceForm `json:"forms,omitempty"` BaseHref string `json:"baseHref,omitempty"` Pin *DevicePin `json:"pin,omitempty"` Properties DeviceProperties `json:"properties,omitempty"` Actions DeviceActions `json:"actions,omitempty"` Events DeviceEvents `json:"events,omitempty"` CredentialsRequired bool `json:"credentialsRequired,omitempty"` // contains filtered or unexported fields }
func NewDevice ¶
func NewDevice(description DeviceDescription, opts ...Option) *Device
func (*Device) AddProperty ¶
func (d *Device) AddProperty(p properties.Entity)
func (*Device) GetAdapter ¶
func (d *Device) GetAdapter() AdapterHandler
func (*Device) GetAtContext ¶
func (*Device) GetBaseHref ¶
func (*Device) GetCredentialsRequired ¶
func (*Device) GetDescription ¶
func (*Device) GetHandler ¶
func (d *Device) GetHandler() AdapterHandler
func (*Device) GetLink ¶
func (d *Device) GetLink() []DeviceLink
func (*Device) GetProperties ¶
func (d *Device) GetProperties() map[string]properties.Entity
func (*Device) GetProperty ¶
func (d *Device) GetProperty(id string) properties.Entity
func (*Device) HandleRemoved ¶
func (d *Device) HandleRemoved()
func (*Device) NotifyPropertyChanged ¶
func (d *Device) NotifyPropertyChanged(p properties.PropertyDescription)
func (*Device) SetCredentials ¶
func (*Device) SetHandler ¶
func (d *Device) SetHandler(h AdapterHandler)
type DeviceActions ¶
type DeviceDescription ¶
type DeviceDescription struct { Id string AtType []Capability Title string Description string }
type DeviceEvents ¶
type DeviceForm ¶
type DeviceForm struct { }
type DeviceLink ¶
type DeviceProperties ¶
type DeviceProperties map[string]properties.Entity
type Entity ¶
type Entity interface { SetHandler(h AdapterHandler) GetAdapter() AdapterHandler GetId() string GetAtContext() string GetProperty(id string) properties.Entity GetAtType() []string ToMessage() *messages.Device SetCredentials(username, password string) error SetPin(pin string) error GetDevice() *Device }
type Light ¶
type Light struct { *Device OnOff properties.BooleanEntity Brightness properties.IntegerEntity ColorMode properties.Entity Color properties.Entity ColorTemperature properties.Entity }
func NewLightBulb ¶
func NewSmartPlug ¶
func (*Light) AddProperties ¶
func (light *Light) AddProperties(props ...properties.Entity)
func (*Light) SetBrightness ¶
type LightHandler ¶
type MotionSensor ¶
type MotionSensor struct { *Device // contains filtered or unexported fields }
func NewMotionSensor ¶
func NewMotionSensor(id string, opts ...Option) *MotionSensor
func (*MotionSensor) AddProperties ¶
func (sensor *MotionSensor) AddProperties(props ...properties.Entity)
type MultiLevelSensor ¶
type MultiLevelSensor struct { *Device // contains filtered or unexported fields }
func NewMultiLevelSensor ¶
func NewMultiLevelSensor(id string, opts ...Option) *MultiLevelSensor
func (*MultiLevelSensor) AddProperties ¶
func (sensor *MultiLevelSensor) AddProperties(props ...properties.Entity)
type MultiLevelSwitch ¶
type MultiLevelSwitch struct {
*Device
}
func NewMultiLevelSwitch ¶
func NewMultiLevelSwitch(id string, opts ...Option) *MultiLevelSwitch
type OnOffSwitch ¶
type OnOffSwitch struct { *Device OnOff properties.BooleanEntity Brightness properties.IntegerEntity ColorMode properties.Entity Color properties.Entity ColorTemperature properties.Entity }
func NewOnOffSwitch ¶
func NewOnOffSwitch(id string, opts ...Option) *OnOffSwitch
func NewThermostat ¶
func NewThermostat(id string, opts ...Option) *OnOffSwitch
func (*OnOffSwitch) AddProperties ¶
func (device *OnOffSwitch) AddProperties(props ...properties.Entity)
func (*OnOffSwitch) Toggle ¶
func (device *OnOffSwitch) Toggle() error
func (*OnOffSwitch) TurnOff ¶
func (device *OnOffSwitch) TurnOff() error
func (*OnOffSwitch) TurnOn ¶
func (device *OnOffSwitch) TurnOn() error
type OnOffSwitchDevice ¶
type Option ¶
type Option func(device *Device)
func WithCredentialsRequired ¶
func WithCredentialsRequired() Option
func WithDescription ¶
type SmartPlug ¶
type SmartPlug struct { *Device OnOff properties.BooleanEntity Level properties.NumberEntity Power properties.NumberEntity PowerFactor properties.NumberEntity Voltage properties.NumberEntity Current properties.NumberEntity Frequency properties.NumberEntity }
func (*SmartPlug) AddProperties ¶
func (plug *SmartPlug) AddProperties(props ...properties.Entity)
type SmartPlugDevice ¶
type SmartPlugDevice interface { OnOffSwitchDevice }
type Thermostat ¶
type Thermostat struct { *Device Temperature properties.NumberEntity TargetTemperature properties.NumberEntity HeatingCooling properties.StringEntity ThermostatMode properties.StringEntity }
func (*Thermostat) AddProperties ¶
func (device *Thermostat) AddProperties(props ...properties.Entity)
Click to show internal directories.
Click to hide internal directories.