tradfri

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROOT_DEVICES                              = "15001"
	ROOT_GATEWAY                              = "15011"
	ROOT_GROUPS                               = "15004"
	ROOT_MOODS                                = "15005"
	ROOT_NOTIFICATION                         = "15006" // speculative name
	ROOT_REMOTE_CONTROL                       = "15009"
	ROOT_SIGNAL_REPEATER                      = "15014"
	ROOT_SMART_TASKS                          = "15010"
	ROOT_START_ACTION                         = "15013" // found under ATTR_START_ACTION
	ATTR_START_BLINDS                         = "15015"
	ATTR_ALEXA_PAIR_STATUS                    = "9093"
	ATTR_AUTH                                 = "9063"
	ATTR_APPLICATION_TYPE                     = "5750"
	ATTR_BLIND_CURRENT_POSITION               = "5536"
	ATTR_BLIND_TRIGGER                        = "5523"
	ATTR_CERTIFICATE_PEM                      = "9096"
	ATTR_CERTIFICATE_PROV                     = "9092"
	ATTR_CLIENT_IDENTITY_PROPOSED             = "9090"
	ATTR_CREATED_AT                           = "9002"
	ATTR_COGNITO_ID                           = "9101"
	ATTR_COMMISSIONING_MODE                   = "9061"
	ATTR_CURRENT_TIME_UNIX                    = "9059"
	ATTR_CURRENT_TIME_ISO8601                 = "9060"
	ATTR_DEVICE_INFO                          = "3"
	ATTR_GATEWAY_ID_2                         = "9100" // stored in IKEA app code as gateway id
	ATTR_GATEWAY_TIME_SOURCE                  = "9071"
	ATTR_GATEWAY_UPDATE_PROGRESS              = "9055"
	ATTR_GROUP_MEMBERS                        = "9018"
	ATTR_HOMEKIT_ID                           = "9083"
	ATTR_HS_LINK                              = "15002"
	ATTR_ID                                   = "9003"
	ATTR_IDENTITY                             = "9090"
	ATTR_IOT_ENDPOINT                         = "9103"
	ATTR_KEY_PAIR                             = "9097"
	ATTR_LAST_SEEN                            = "9020"
	ATTR_LIGHT_CONTROL                        = "3311" // array
	ATTR_MASTER_TOKEN_TAG                     = "9036"
	ATTR_MOOD                                 = "9039"
	ATTR_NAME                                 = "9001"
	ATTR_NTP                                  = "9023"
	ATTR_FIRMWARE_VERSION                     = "9029"
	ATTR_FIRST_SETUP                          = "9069" // ??? unix epoch value when gateway first setup
	ATTR_GATEWAY_INFO                         = "15012"
	ATTR_GATEWAY_ID                           = "9081" // ??? id of the gateway
	ATTR_GATEWAY_REBOOT                       = "9030" // gw reboot
	ATTR_GATEWAY_FACTORY_DEFAULTS             = "9031" // gw to factory defaults
	ATTR_GATEWAY_FACTORY_DEFAULTS_MIN_MAX_MSR = "5605"
	ATTR_GOOGLE_HOME_PAIR_STATUS              = "9105"
	ATTR_DEVICE_STATE                         = "5850" // 0 / 1
	ATTR_LIGHT_DIMMER                         = "5851" // Dimmer, not following spec: 0..255
	ATTR_LIGHT_COLOR_HEX                      = "5706" // string representing a value in hex
	ATTR_LIGHT_COLOR_X                        = "5709"
	ATTR_LIGHT_COLOR_Y                        = "5710"
	ATTR_LIGHT_COLOR_HUE                      = "5707"
	ATTR_LIGHT_COLOR_SATURATION               = "5708"
	ATTR_LIGHT_MIREDS                         = "5711"
	ATTR_NOTIFICATION_EVENT                   = "9015"
	ATTR_NOTIFICATION_NVPAIR                  = "9017"
	ATTR_NOTIFICATION_STATE                   = "9014"
	ATTR_OTA_TYPE                             = "9066"
	ATTR_OTA_UPDATE_STATE                     = "9054"
	ATTR_OTA_UPDATE                           = "9037"
	ATTR_PUBLIC_KEY                           = "9098"
	ATTR_PRIVATE_KEY                          = "9099"
	ATTR_PSK                                  = "9091"
	ATTR_REACHABLE_STATE                      = "9019"
	ATTR_REPEAT_DAYS                          = "9041"
	ATTR_SEND_CERT_TO_GATEWAY                 = "9094"
	ATTR_SEND_COGNITO_ID_TO_GATEWAY           = "9095"
	ATTR_SEND_GH_COGNITO_ID_TO_GATEWAY        = "9104"
	ATTR_SENSOR                               = "3300"
	ATTR_SENSOR_MAX_RANGE_VALUE               = "5604"
	ATTR_SENSOR_MAX_MEASURED_VALUE            = "5602"
	ATTR_SENSOR_MIN_RANGE_VALUE               = "5603"
	ATTR_SENSOR_MIN_MEASURED_VALUE            = "5601"
	ATTR_SENSOR_TYPE                          = "5751"
	ATTR_SENSOR_UNIT                          = "5701"
	ATTR_SENSOR_VALUE                         = "5700"
	ATTR_START_ACTION                         = "9042" // array
	ATTR_SMART_TASK_TYPE                      = "9040" // 4 = transition | 1 = not home | 2 = on/off
	ATTR_SMART_TASK_NOT_AT_HOME               = 1
	ATTR_SMART_TASK_LIGHTS_OFF                = 2
	ATTR_SMART_TASK_WAKE_UP                   = 4
	ATTR_SMART_TASK_TRIGGER_TIME_INTERVAL     = "9044"
	ATTR_SMART_TASK_TRIGGER_TIME_START_HOUR   = "9046"
	ATTR_SMART_TASK_TRIGGER_TIME_START_MIN    = "9047"
	ATTR_SWITCH_CUM_ACTIVE_POWER              = "5805"
	ATTR_SWITCH_ON_TIME                       = "5852"
	ATTR_SWITCH_PLUG                          = "3312"
	ATTR_SWITCH_POWER_FACTOR                  = "5820"
	ATTR_TIME_END_TIME_HOUR                   = "9048"
	ATTR_TIME_END_TIME_MINUTE                 = "9049"
	ATTR_TIME_START_TIME_HOUR                 = "9046"
	ATTR_TIME_START_TIME_MINUTE               = "9047"
	ATTR_TRANSITION_TIME                      = "5712"
	ATTR_USE_CURRENT_LIGHT_SETTINGS           = "9070"
)

https://github.com/ggravlingen/pytradfri/blob/master/pytradfri/const.py

View Source
const (
	RANGE_HUE_MIN        = 0
	RANGE_HUE_MAX        = 65535
	RANGE_SATURATION_MIN = 0
	RANGE_SATURATION_MAX = 65279
	RANGE_BRIGHTNESS_MIN = 0
	RANGE_BRIGHTNESS_MAX = 254
	RANGE_BLIND_MIN      = 0
	RANGE_BLIND_MAX      = 100
	RANGE_COLORXY_MIN    = 0
	RANGE_COLORXY_MAX    = 65535
)
View Source
const (
	DefaultPort = 5684
)
View Source
const (
	FILENAME_TOKEN = "token.json"
)

Variables

This section is empty.

Functions

func NewDeviceMap

func NewDeviceMap() *devicemap

Types

type Bool

type Bool bool

func (Bool) MarshalJSON

func (b Bool) MarshalJSON() ([]byte, error)

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(data []byte) (err error)

type Command

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

func (*Command) Body

func (c *Command) Body() (io.Reader, error)

func (*Command) Path

func (c *Command) Path() string

func (*Command) String

func (c *Command) String() string

type Config

type Config struct {
	Id      string        `yaml:"id"`
	Key     string        `yaml:"key"`
	Path    string        `yaml:"path"`
	Timeout time.Duration `yaml:"timeout"`
}

type Device

type Device struct {
	Id          uint       `json:"9003"`
	Name        string     `json:"9001"`
	Created     Time       `json:"9002"`
	Updated     Time       `json:"9020"`
	Active      Bool       `json:"9019"`
	Type        DeviceType `json:"5750,omitempty"`
	NeedsUpdate Bool       `json:"9054"`
	Metadata    struct {
		Vendor       string `json:"0"`
		Product      string `json:"1"`
		Serial       string `json:"2,omitempty"`
		Version      string `json:"3"`
		PowerSource  int    `json:"6"`
		BatteryLevel int    `json:"9,omitempty"`
	} `json:"3"`
	Lights_ []*Light `json:"3311,omitempty"` // IKEA_DEVICE_TYPE_LIGHTBULB
}

func (*Device) Equals

func (d *Device) Equals(other *Device) bool

func (*Device) Lights

func (d *Device) Lights() []*Light

func (*Device) String

func (d *Device) String() string

type DeviceType

type DeviceType uint
const (
	IKEA_DEVICE_TYPE_REMOTE       DeviceType = 0
	IKEA_DEVICE_TYPE_SLAVE_REMOTE DeviceType = 1
	IKEA_DEVICE_TYPE_LIGHT        DeviceType = 2
	IKEA_DEVICE_TYPE_PLUG         DeviceType = 3
	IKEA_DEVICE_TYPE_MOTIONSENSOR DeviceType = 4
	IKEA_DEVICE_TYPE_REPEATER     DeviceType = 6
	IKEA_DEVICE_TYPE_BLIND        DeviceType = 7
)

func (DeviceType) MarshalJSON

func (t DeviceType) MarshalJSON() ([]byte, error)

func (DeviceType) String

func (t DeviceType) String() string

type Event

type Event struct {
	EventType
	*Device
}

func (*Event) String

func (e *Event) String() string

type EventType

type EventType uint
const (
	EVENT_TYPE_DEVICE EventType = (1 << iota)
	EVENT_TYPE_GROUP
	EVENT_TYPE_SCENE
	EVENT_TYPE_NEW
	EVENT_TYPE_UPDATE
	EVENT_TYPE_DELETE
	EVENT_TYPE_MIN            = EVENT_TYPE_DEVICE
	EVENT_TYPE_MAX            = EVENT_TYPE_DELETE
	EVENT_TYPE_NONE EventType = 0
)

func (EventType) FlagString

func (t EventType) FlagString() string

func (EventType) Is

func (t EventType) Is(f EventType) bool

func (EventType) String

func (t EventType) String() string

type Gateway

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

func NewWithConfig

func NewWithConfig(cfg Config) (*Gateway, error)

func (*Gateway) Addr

func (t *Gateway) Addr() string

Return address of gateway

func (*Gateway) Connect

func (t *Gateway) Connect(addr string) error

Connect to a tradfri gateway with the given address and return any errors

func (*Gateway) Devices

func (t *Gateway) Devices(ctx context.Context) ([]uint, error)

Return a list of device id's registered with the gateway

func (*Gateway) Disconnect

func (t *Gateway) Disconnect() error

Disconnect from the gateway

func (*Gateway) GetDevice

func (t *Gateway) GetDevice(ctx context.Context, id uint) (*Device, error)

Return a device by id

func (*Gateway) GetGroup

func (t *Gateway) GetGroup(ctx context.Context, id uint) (*Group, error)

Return a group by id

func (*Gateway) GetScene

func (t *Gateway) GetScene(ctx context.Context, id uint) (*Scene, error)

Return a scene by id

func (*Gateway) Groups

func (t *Gateway) Groups(ctx context.Context) ([]uint, error)

Return a list of group id's registered with the gateway

func (*Gateway) Id

func (t *Gateway) Id() string

Return id of connection

func (*Gateway) ObserveDevice

func (t *Gateway) ObserveDevice(ctx context.Context, id uint, fn func(*Device), errs chan<- error) error

Observe a device until it is cancelled, send back devices and errors. If is the responsibility of the caller to determine if the device has changed.

func (*Gateway) Run

func (g *Gateway) Run(ctx context.Context, evts chan<- *Event, errs chan<- error) error

func (*Gateway) Scenes

func (t *Gateway) Scenes(ctx context.Context) ([]uint, error)

Return a list of scene id's registered with the gateway

func (*Gateway) Send

func (t *Gateway) Send(commands ...*Command) error

func (*Gateway) String

func (t *Gateway) String() string

func (*Gateway) Version

func (t *Gateway) Version() string

Return version of gateway

type Group

type Group struct {
	Id      uint   `json:"9003"`
	Name    string `json:"9001"`
	Created Time   `json:"9002"`
	Content struct {
		Devices struct {
			Devices []uint `json:"9003"`
		} `json:"15002"`
	} `json:"9018"`
}

func (*Group) Devices

func (g *Group) Devices() []uint

func (*Group) Equals

func (g *Group) Equals(other *Group) bool

func (*Group) String

func (g *Group) String() string

type Light

type Light struct {
	Power          Bool    `json:"5850"`
	ColorHex       string  `json:"5706,omitempty"`
	ColorX         uint16  `json:"5709,omitempty"`
	ColorY         uint16  `json:"5710,omitempty"`
	Hue            uint16  `json:"5707,omitempty"`
	Saturation     uint16  `json:"5708,omitempty"`
	Temperature    uint16  `json:"5711,omitempty"`
	Brightness     uint8   `json:"5851,omitempty"`
	TransitionTime float32 `json:"5712,omitempty"`
	// contains filtered or unexported fields
}

func (*Light) Equals

func (l *Light) Equals(other *Light) bool

func (*Light) SetBrightness

func (l *Light) SetBrightness(value uint8, transition time.Duration) *Command

func (*Light) SetColorHex

func (l *Light) SetColorHex(value string, transition time.Duration) *Command

func (*Light) SetColorXY

func (l *Light) SetColorXY(x, y uint16, transition time.Duration) *Command

func (*Light) SetHue

func (l *Light) SetHue(v uint16, transition time.Duration) *Command

func (*Light) SetPower

func (l *Light) SetPower(state bool) *Command

func (*Light) SetSaturation

func (l *Light) SetSaturation(v uint16, transition time.Duration) *Command

func (*Light) SetTemperature

func (l *Light) SetTemperature(value uint16, transition time.Duration) *Command

func (*Light) String

func (l *Light) String() string

type Scene

type Scene struct {
	Id uint `json:"9003"`
}

func (*Scene) String

func (s *Scene) String() string

type Time

type Time struct {
	time.Time
}

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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