Documentation ¶
Index ¶
- func ToDeviceResponse(device Device) interface{}
- func ToDeviceResponseProto(device Device) *pb.Device
- func ToGroupResponseProto(group Group) *pb.Group
- type BlindResponse
- type BulbResponse
- type ControlOutlet
- type Device
- type DeviceMetadata
- type DimmingRequest
- type Group
- type GroupResponse
- type PositioningRequest
- type PowerPlugResponse
- type PowerRequest
- type RemoteControl
- type Result
- type RgbColorRequest
- type StateRequest
- type TokenExchange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToDeviceResponse ¶
func ToDeviceResponse(device Device) interface{}
ToDeviceResponse transforms the passed device into either a BulbResponse or BlindResponse. (more needed)
func ToDeviceResponseProto ¶
ToDeviceResponseProto transforms the passed device into a protobuf device having its type-specific fields populated. Supports Light controls (bulbs) and blinds.
func ToGroupResponseProto ¶
ToGroupResponseProto transforms the passed group into its protobuf equivalent.
Types ¶
type BlindResponse ¶
type BlindResponse struct { DeviceMetadata DeviceMetadata `json:"deviceMetadata"` Position float32 `json:"position"` }
BlindResponse is the response from a blind GET.
type BulbResponse ¶
type BulbResponse struct { DeviceMetadata DeviceMetadata `json:"deviceMetadata"` Dimmer int `json:"dimmer"` CIE_1931_X int `json:"xcolor"` CIE_1931_Y int `json:"ycolor"` RGB string `json:"rgbcolor"` Power bool `json:"power"` }
BulbResponse is the response from a light bulb GET.
type ControlOutlet ¶
type ControlOutlet struct { Metadata struct { Manufacturer string `json:"0"` ModelNumber string `json:"1"` SerialNumber string `json:"2"` FirmwareVersion string `json:"3"` PowerType int `json:"6"` } `json:"3"` PowerControl []struct { Power int `json:"5850"` Dimmer int `json:"5851"` DeviceId int `json:"9003"` } `json:"3312"` Type int `json:"5750"` Name string `json:"9001"` CreatedAt int `json:"9002"` DeviceId int `json:"9003"` Alive int `json:"9019"` LastSeen int `json:"9020"` OtaUpdateState int `json:"9054"` HashUnknown string `json:"9084"` }
ControlOutlet defines (with JSON tags) a IKEA control outlet.
type Device ¶
type Device struct { Metadata struct { Vendor string `json:"0"` TypeName string `json:"1"` SerialNumber string `json:"2"` TypeId string `json:"3"` PowerType int `json:"6"` Battery int `json:"9"` } `json:"3"` LightControl []struct { RGBHex string `json:"5706"` Hue int `json:"5707"` Saturation int `json:"5708"` CIE_1931_X int `json:"5709"` CIE_1931_Y int `json:"5710"` ColorTemperature int `json:"5711"` TransitionTime float64 `json:"5712"` Power int `json:"5850"` Dimmer int `json:"5851"` DeviceId int `json:"9003"` } `json:"3311"` OutletControl []struct { Power int `json:"5850"` Dimmer int `json:"5851"` DeviceId int `json:"9003"` } `json:"3312"` BlindControl []struct { Position float32 `json:"5536"` DeviceId int `json:"9003"` } `json:"15015"` Type int `json:"5750"` Name string `json:"9001"` CreatedAt int `json:"9002"` DeviceId int `json:"9003"` Alive int `json:"9019"` LastSeen int `json:"9020"` OtaUpdateState int `json:"9054"` }
Device defines (with JSON tags) a IKEA trådfri device of some kind
type DeviceMetadata ¶
type DeviceMetadata struct { Id int `json:"id"` Name string `json:"name"` Vendor string `json:"vendor"` Type string `json:"type"` Battery int `json:"battery"` }
DeviceMetadata defines (with JSON tags) common device metadata. Typically embedded in other structs.
type DimmingRequest ¶
type DimmingRequest struct {
Dimming int `json:"dimming"`
}
DimmingRequest allows setting the dimmer level from 0-255.
type Group ¶
type Group struct { Power int `json:"5850"` Dimmer int `json:"5851"` Name string `json:"9001"` CreatedAt int `json:"9002"` DeviceId int `json:"9003"` Content struct { DeviceList struct { DeviceIds []int `json:"9003"` } `json:"15002"` } `json:"9018"` SceneId int `json:"9039"` GroupType int `json:"9108"` }
Group defines (with JSON tags) a IKEA trådfri Group.
type GroupResponse ¶
type GroupResponse struct { Id int `json:"id"` Power int `json:"power"` Created string `json:"created"` DeviceList []int `json:"deviceList"` }
GroupResponse defines a Group JSON response
func ToGroupResponse ¶
func ToGroupResponse(group Group) GroupResponse
ToGroupResponse transforms a group into a response format more suitable for JSON serialization
type PositioningRequest ¶
type PositioningRequest struct {
Positioning float32 `json:"positioning"`
}
PositioningRequest allows setting the position from 0-100.
type PowerPlugResponse ¶
type PowerPlugResponse struct { DeviceMetadata DeviceMetadata `json:"deviceMetadata"` Power bool `json:"power"` }
PowerPlugResponse is the response from a power plug device GET.
type PowerRequest ¶
type PowerRequest struct {
Power int `json:"power"`
}
PowerRequest contains a Power state int, 1 == on, 0 == off.
type RemoteControl ¶
type RemoteControl struct { Metadata struct { Manufacturer string `json:"0"` ModelNumber string `json:"1"` SerialNumber string `json:"2"` FirmwareVersion string `json:"3"` PowerType int `json:"6"` Battery int `json:"9"` } `json:"3"` Type int `json:"5750"` Name string `json:"9001"` CreatedAt int `json:"9002"` DeviceId int `json:"9003"` Alive int `json:"9019"` LastSeen int `json:"9020"` OtaUpdateState int `json:"9054"` SwitchList []struct { Num9003 int `json:"9003"` } `json:"15009"` }
RemoteControl defines (with JSON tags) a IKEA remote control.
type Result ¶
type Result struct {
Msg string
}
Result is a generic result containing a plain text message
type RgbColorRequest ¶
type RgbColorRequest struct {
RGBcolor string `json:"rgbcolor"`
}
RgbColorRequest allows (trying to) set a bulb color using classic hex RGB string.
type StateRequest ¶
type StateRequest struct { RGBcolor string `json:"rgbcolor"` Dimmer int `json:"dimmer"` Power int `json:"power"` }
StateRequest allows setting both color, dimmer and power setting in a single PUT.
type TokenExchange ¶
TokenExchange maps the human-readable Token and TypeIdentifies into their IKEA specific numeric codes.