tradfri

package
v0.0.0-...-1b33c85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeviceEndpoint       = "15001"
	GroupEndpoint        = "15004"
	SceneEndpoint        = "15005"
	NotificationEndpoint = "15006"
	GatewayEndpoint      = "15011/15012"
)
View Source
const (
	Cold   = "f5faf6"
	Normal = "f1e0b5"
	Warm   = "efd275"
)
View Source
const (
	TypeRemote   DeviceType     = 0
	TypeLight    DeviceType     = 2
	No           YesNo          = 0
	Yes          YesNo          = 1
	PrioNormal   UpdatePriority = 0
	PrioCritical UpdatePriority = 1
	PrioRequired UpdatePriority = 2
	PrioForced   UpdatePriority = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Accessory

type Accessory struct {
	BaseType
	Type       DeviceType  `json:"5750,omitempty"`
	DeviceInfo *DeviceInfo `json:"3,omitempty"`
	Alive      YesNo       `json:"9019,omitempty"`
	LastSeen   int64       `json:"9020,omitempty"`
	Lights     []*Light    `json:"3311,omitempty"`
	Plugs      []*Plug     `json:"3312,omitempty"`
	Sensors    []*Sensor   `json:"3300,omitempty"`
	Switches   []*Switch   `json:"15009,omitempty"`
	OTAUpdate  YesNo       `json:"9054,omitempty"`
	// contains filtered or unexported fields
}

func (*Accessory) IsAlive

func (a *Accessory) IsAlive() bool

func (*Accessory) IsLight

func (a *Accessory) IsLight() bool

func (*Accessory) IsRemote

func (a *Accessory) IsRemote() bool

func (*Accessory) LastSeenTime

func (a *Accessory) LastSeenTime() time.Time

func (*Accessory) Light

func (a *Accessory) Light() *Light

func (*Accessory) Observe

func (o *Accessory) Observe(callback ObservableCallback)

func (*Accessory) ObserveFilter

func (o *Accessory) ObserveFilter(filter []ObserveFilter, callback ObservableCallback)

func (*Accessory) OnChange

func (o *Accessory) OnChange(change []*ObservedChange)

func (*Accessory) SetColor

func (a *Accessory) SetColor(c color.Color)

func (*Accessory) SetColorCold

func (a *Accessory) SetColorCold()

func (*Accessory) SetColorNormal

func (a *Accessory) SetColorNormal()

func (*Accessory) SetColorTemp

func (a *Accessory) SetColorTemp(c string)

func (*Accessory) SetColorWarm

func (a *Accessory) SetColorWarm()

func (*Accessory) SetDim

func (a *Accessory) SetDim(dim int)

func (*Accessory) SetName

func (a *Accessory) SetName(name string)

func (*Accessory) SetOn

func (a *Accessory) SetOn(on bool)

type BaseType

type BaseType struct {
	sync.RWMutex

	Name       string `json:"9001,omitempty"`
	CreatedAt  int64  `json:"9002,omitempty"`
	InstanceID int    `json:"9003,omitempty"`
	// contains filtered or unexported fields
}

func (*BaseType) CreateTime

func (b *BaseType) CreateTime() time.Time

func (*BaseType) GetInstanceID

func (b *BaseType) GetInstanceID() int

type DeviceInfo

type DeviceInfo struct {
	Manufacturer string `json:"0"`
	Model        string `json:"1"`
	SerialNumber string `json:"2"`
	Firmware     string `json:"3"`
	Power        int    `json:"6"`
	Battery      int    `json:"9"`
}

func (*DeviceInfo) IsRGBModel

func (d *DeviceInfo) IsRGBModel() bool

type DeviceType

type DeviceType uint8

type Dimmable

type Dimmable struct {
	On  *YesNo `json:"5850,omitempty"`
	Dim *uint8 `json:"5851,omitempty"`
}

func (*Dimmable) DimInt

func (d *Dimmable) DimInt() int

func (*Dimmable) DimPercent

func (d *Dimmable) DimPercent() float64

func (*Dimmable) IsOn

func (d *Dimmable) IsOn() bool

type DiscoverCallback

type DiscoverCallback interface {
	OnNewAccessory(d *Accessory)
	OnNewGroup(g *Group)
	OnNewScene(g *Group, s *Scene)
}

type Gateway

type Gateway struct {

	// NTPServer that the gateway uses
	NTPServer string `json:"9023"`

	// Version of trådfri gateway
	Version string `json:"9029"`

	// UpdateState is set to 1 if the gateway is currently
	// updating its firmware?
	UpdateState int `json:"9054"`

	// UpdateProgress seems to be a percentage
	UpdateProgress int `json:"9055"`

	// UpdateURL links to details regarding the update
	UpdateURL string `json:"9056"`

	// Current time of the gateway in unix timestamp format
	Timestamp int64 `json:"9059"`

	// TimestampUtc is the current time of the gateway in the format 2017-08-20T23:13:42.006000Z
	TimestampUtc string `json:"9060"`

	// CommissioningMode ?
	CommissioningMode int `json:"9061"`

	// UpdatePriority ?
	UpdatePriority UpdatePriority `json:"9066"`

	// UpdateAcceptedTimestamp
	UpdateAcceptedTimestamp int64 `json:"9069"`

	// TimeSource ?
	TimeSource int `json:"9071"`

	// ForceCheckOTAUpdate ?
	//
	ForceCheckOTAUpdate string `json:"9032"`

	// Name
	Name string `json:"9035"`

	// Field* are unknown fields exposed by the gateway.
	// Do not depend on the names staying the same
	Field9060 int    `json:"9060"`
	Field9062 int    `json:"9062"`
	Field9072 int    `json:"9072"`
	Field9073 int    `json:"9073"`
	Field9074 int    `json:"9074"`
	Field9075 int    `json:"9075"`
	Field9076 int    `json:"9076"`
	Field9077 int    `json:"9077"`
	Field9078 int    `json:"9078"`
	Field9079 int    `json:"9079"`
	Field9080 int    `json:"9080"`
	Field9081 string `json:"9081"`
	// contains filtered or unexported fields
}

func (*Gateway) Observe

func (o *Gateway) Observe(callback ObservableCallback)

func (*Gateway) ObserveFilter

func (o *Gateway) ObserveFilter(filter []ObserveFilter, callback ObservableCallback)

func (*Gateway) OnChange

func (o *Gateway) OnChange(change []*ObservedChange)

type Group

type Group struct {
	BaseType
	Dimmable
	Scene   *int  `json:"9039,omitempty"`
	Members []int `json:"9018,omitempty"`

	Scenes map[int]*Scene `json:"-"`
	// contains filtered or unexported fields
}

func (*Group) MarshalJSON

func (g *Group) MarshalJSON() ([]byte, error)

func (*Group) Observe

func (o *Group) Observe(callback ObservableCallback)

func (*Group) ObserveFilter

func (o *Group) ObserveFilter(filter []ObserveFilter, callback ObservableCallback)

func (*Group) OnChange

func (o *Group) OnChange(change []*ObservedChange)

func (*Group) SetDim

func (g *Group) SetDim(dim int)

func (*Group) SetName

func (g *Group) SetName(name string)

func (*Group) SetOn

func (g *Group) SetOn(on bool)

func (*Group) UnmarshalJSON

func (g *Group) UnmarshalJSON(b []byte) error

type Instance

type Instance interface {
	GetInstanceID() int
}

type Light

type Light struct {
	LightSetting
	TransitionTime        *int     `json:"5712,omitempty"`
	CumulativeActivePower *float64 `json:"5805,omitempty"`
	OnTime                *int64   `json:"5852,omitempty"`
	PowerFactor           *float64 `json:"5820,omitempty"`
	Unit                  *string  `json:"5701,omitempty"`
}

type LightSetting

type LightSetting struct {
	BaseType
	Dimmable
	Color  string `json:"5706,omitempty"`
	ColorX int    `json:"5709,omitempty"`
	ColorY int    `json:"5710,omitempty"`

	Field5707 int `json:"5707,omitempty"`
	Field5708 int `json:"5708,omitempty"`
	Field5711 int `json:"5711,omitempty"`
}

func (*LightSetting) GetColorName

func (l *LightSetting) GetColorName() string

func (*LightSetting) HasColorTemperature

func (l *LightSetting) HasColorTemperature() bool

func (*LightSetting) SetColor

func (l *LightSetting) SetColor(color color.Color)

func (*LightSetting) SetColorCold

func (l *LightSetting) SetColorCold()

func (*LightSetting) SetColorNormal

func (l *LightSetting) SetColorNormal()

func (*LightSetting) SetColorTemp

func (l *LightSetting) SetColorTemp(c string)

func (*LightSetting) SetColorWarm

func (l *LightSetting) SetColorWarm()

type Notification

type Notification struct {
	BaseType
	Event   NotificationEvent `json:"9015,omitempty"`
	Details []string          `json:"9017,omitempty"`
	State   int               `json:"9014"`
}

func (*Notification) EventString

func (n *Notification) EventString() string

type NotificationEvent

type NotificationEvent int
const (
	EventNewFirmwareAvailable NotificationEvent = 1001
	EventGatewayReboot        NotificationEvent = 1003
	EventInternetUnreachable  NotificationEvent = 5001
)

type ObservableCallback

type ObservableCallback func(change []*ObservedChange)

type ObservableTransport

type ObservableTransport interface {
	Transport
	Observe(method, uri string, callback func(data []byte)) error
}

type ObserveFilter

type ObserveFilter func(observation *ObservedChange) bool

type ObservedChange

type ObservedChange struct {
	Path     string
	Field    string
	OldValue interface{}
	NewValue interface{}
}

type Plug

type Plug struct {
	BaseType
}

Plug struct, not sure what it should contain

type Scene

type Scene struct {
	BaseType

	Index                   int             `json:"9057,omitempty"`
	IsPredefined            YesNo           `json:"9068,omitempty"`
	IsActive                YesNo           `json:"9058,omitempty"`
	LightSettings           []*LightSetting `json:"15013,omitempty"`
	UseCurrentLightSettings YesNo           `json:"9070,omitempty"`
	// contains filtered or unexported fields
}

func (*Scene) Observe

func (o *Scene) Observe(callback ObservableCallback)

func (*Scene) ObserveFilter

func (o *Scene) ObserveFilter(filter []ObserveFilter, callback ObservableCallback)

func (*Scene) OnChange

func (o *Scene) OnChange(change []*ObservedChange)

type Sensor

type Sensor struct {
	BaseType
}

Sensor struct, not sure what it should contain

type Switch

type Switch struct {
	BaseType
}

type Transport

type Transport interface {
	Get(uri string) ([]byte, error)
	Put(uri string, data []byte) error
	Delete(uri string) error
}

type Tree

type Tree struct {
	sync.RWMutex
	Devices       map[int]*Accessory
	Groups        map[int]*Group
	Notifications []*Notification
	Gateway       *Gateway
	// contains filtered or unexported fields
}

func NewTree

func NewTree(transport Transport) *Tree

func (*Tree) AddCallback

func (t *Tree) AddCallback(callback DiscoverCallback)

func (*Tree) Populate

func (t *Tree) Populate(path []string, data []byte) error

type UpdatePriority

type UpdatePriority uint8

func (UpdatePriority) String

func (u UpdatePriority) String() string

type YesNo

type YesNo uint8

func ToYesNo

func ToYesNo(t bool) YesNo

func (YesNo) Bool

func (y YesNo) Bool() bool

func (YesNo) String

func (y YesNo) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL