Index | Files

package device

import ""

Package device defines the basic requirements of a device


Package Files

device.go doc.go featureTransport.go interface.go types.go

func Create Uses

func Create(d *Device) error

type Action Uses

type Action string
const (
    DeleteAction Action = "delete"
    UpdateAction Action = "update"
    LeaveAction  Action = "leave"

type Common Uses

type Common interface {
    // Id will return the unique id of the device.
    // This is currently always the same as the topic name.
    Id() string

    // Name returns the name of the device
    Name() string

    // Manufacturer returns the manufacturer
    Manufacturer() string

    // Model returns the model name/number
    Model() string

    // SerialNumber returns the serial number
    SerialNumber() string

    // Type returns the type of the device (lightbulb, outlet, etc)
    Type() string

Device contains the common functions for Client and Server

type Device Uses

type Device struct {
    Info      *Info
    Features  map[string]feature.Feature
    Transport Transport

func (*Device) Exists Uses

func (d *Device) Exists() bool

func (*Device) Feature Uses

func (d *Device) Feature(name string) feature.Feature

func (*Device) Id Uses

func (d *Device) Id() string

func (*Device) Manufacturer Uses

func (d *Device) Manufacturer() string

func (*Device) Model Uses

func (d *Device) Model() string

func (*Device) Name Uses

func (d *Device) Name() string

func (*Device) SerialNumber Uses

func (d *Device) SerialNumber() string

func (*Device) SetFeature Uses

func (d *Device) SetFeature(f *feature.Info, b []byte)

func (*Device) SubscribeFeature Uses

func (d *Device) SubscribeFeature(topic string) chan []byte

func (*Device) Type Uses

func (d *Device) Type() string

func (*Device) UpdateFeature Uses

func (d *Device) UpdateFeature(f *feature.Info, b []byte)

func (*Device) UpdateInfo Uses

func (d *Device) UpdateInfo(info *Info) (updates []*InfoUpdate, err error)

type Info Uses

type Info struct {
    Topic        string                   `json:"topic"`
    Name         string                   `json:"name"`
    Manufacturer string                   `json:"manufacturer"`
    Model        string                   `json:"model"`
    SerialNumber string                   `json:"serialNumber"`
    Type         string                   `json:"type"`
    LastWillID   string                   `json:"lastWillID,omitempty"`
    Features     map[string]*feature.Info `json:"feature"`
    Reachable    bool                     `json:"-"`

type InfoUpdate Uses

type InfoUpdate struct {
    Field       string
    Old         string
    New         string
    FeatureInfo []*feature.InfoUpdate

type State Uses

type State struct {
    Device *Info
    Action Action
    Topic  string

type Transport Uses

type Transport interface {
    Publish(topic string, payload []byte, retain bool)
    Subscribe(topic string) chan []byte
    Unsubscribe(topic string) bool
    Resubscribe(oldTopic, newTopic string) bool
    Discover() chan struct{}
    PublishMeta(topic string, payload []byte)
    LastWillID() string

type Type Uses

type Type string

Type is the type of device

const (
    AccessoryInformation         Type = "accessoryInformation"
    AirPurifier                  Type = "airPurifier"
    AirQualitySensor             Type = "airQualitySensor"
    BatteryService               Type = "batteryService"
    BridgeConfiguration          Type = "bridgeConfiguration"
    BridgingState                Type = "bridgingState"
    CameraControl                Type = "cameraControl"
    CameraRTPStreamManagement    Type = "cameraRTPStreamManagement"
    CarbonDioxideSensor          Type = "carbonDioxideSensor"
    CarbonMonoxideSensor         Type = "carbonMonoxideSensor"
    ContactSensor                Type = "contactSensor"
    Door                         Type = "door"
    Doorbell                     Type = "doorbell"
    Fan                          Type = "fan"
    FanV2                        Type = "fanV2"
    Faucet                       Type = "faucet"
    FilterMaintenance            Type = "filterMaintenance"
    GarageDoorOpener             Type = "garageDoorOpener"
    HeaterCooler                 Type = "heaterCooler"
    HumidifierDehumidifier       Type = "humidifierDehumidifier"
    HumiditySensor               Type = "humiditySensor"
    IrrigationSystem             Type = "irrigationSystem"
    LeakSensor                   Type = "leakSensor"
    LightSensor                  Type = "lightSensor"
    Lightbulb                    Type = "lightbulb"
    LockManagement               Type = "lockManagement"
    LockMechanism                Type = "lockMechanism"
    Microphone                   Type = "microphone"
    MotionSensor                 Type = "motionSensor"
    OccupancySensor              Type = "occupancySensor"
    Outlet                       Type = "outlet"
    SecuritySystem               Type = "securitySystem"
    ServiceLabel                 Type = "serviceLabel"
    Slat                         Type = "slat"
    SmokeSensor                  Type = "smokeSensor"
    Speaker                      Type = "speaker"
    StatefulProgrammableSwitch   Type = "statefulProgrammableSwitch"
    StatelessProgrammableSwitch  Type = "statelessProgrammableSwitch"
    Switch                       Type = "switch"
    TemperatureSensor            Type = "temperatureSensor"
    Thermostat                   Type = "thermostat"
    TimeInformation              Type = "timeInformation"
    TunneledBTLEAccessoryService Type = "tunneledBTLEAccessoryService"
    Valve                        Type = "valve"
    Window                       Type = "window"
    WindowCovering               Type = "windowCovering"

All supported device types

func (Type) Equal Uses

func (t Type) Equal(y Type) bool

Equal checks if two devices are the same

func (Type) String Uses

func (t Type) String() string

String returns the string representation of the device type

Package device imports 5 packages (graph) and is imported by 6 packages. Updated 2019-05-05. Refresh now. Tools for package owners.