Documentation
¶
Index ¶
- Constants
- type AppData
- type BaseScene
- type Bridge
- func (b *Bridge) CreateGroup(name string, groupType GroupType, lights []string) (string, error)
- func (b *Bridge) CreateRoom(name string, class RoomClasses, lights []string) (string, error)
- func (b *Bridge) CreateScene(s *CreationScene) (string, error)
- func (b *Bridge) DeleteScene(id string) error
- func (b *Bridge) GetAllGroups() (map[string]*Group, error)
- func (b *Bridge) GetGroupAttributes(id string) (*Group, error)
- func (b *Bridge) GetLights() (result map[string]*Light, err error)
- func (b *Bridge) GetScene(id string) (*Scene, error)
- func (b *Bridge) GetScenes() (map[string]*BaseScene, error)
- func (b *Bridge) GetState() (state *BridgeState, err error)
- func (b *Bridge) SetGroupAttributes(id string, attributes *GroupAttributes) (*BridgeResponse, error)
- func (b *Bridge) SetGroupState(id string, action *GroupAction) ([]*BridgeResponse, error)
- func (b *Bridge) SetLightState(id string, state *LightState) (result *BridgeResponse, err error)
- func (b *Bridge) ToggleLight(id string, on bool) (resp *BridgeResponse, err error)
- type BridgeResponse
- type BridgeResponseError
- type BridgeState
- type BridgeUserConfig
- type Config
- type CreationScene
- type DeviceConfig
- type DeviceStartUp
- type Group
- type GroupAction
- type GroupAttributes
- type GroupCreateResponse
- type GroupLightLevel
- type GroupPresence
- type GroupState
- type GroupType
- type Light
- type LightCapabilities
- type LightControl
- type LightCt
- type LightState
- type RoomClasses
- type Scene
- type StreamingCapabilities
- type SwUpdate
- type Time
- type User
Constants ¶
const LightsEndpoint = "/lights"
LightsEndpoint for the lights
const TimeFormat = "2006-01-02T15:04:05"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseScene ¶
type BaseScene struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Group string `json:"group,omitempty"`
Lights []int `json:"lights,omitempty"`
Owner string `json:"owner,omitempty"`
Recycle bool `json:"recycle,omitempty"`
Locked bool `json:"lcoked,omitempty"`
AppData *AppData `json:"appdata,omitempty"`
Picture string `json:"picture,omitempty"`
LastUpdated Time `json:"lastupdated,omitempty"`
Version int `json:"version,omitempty"`
}
TODO: maybe change the naming and hierachy of the types.
type Bridge ¶
type Bridge struct {
Config *Config
}
Bridge is the hue bridge interface
func (*Bridge) CreateGroup ¶
CreateGroup creates a new hue group. For rooms please use the CreateRoom call since it also needs a class
func (*Bridge) CreateRoom ¶
CreateRoom creates a new hue room.
func (*Bridge) CreateScene ¶
func (b *Bridge) CreateScene(s *CreationScene) (string, error)
TODO: probably support the old version CreateScene will create a new Scene on the bridge. It will return the id of the new scene if no error occures.
func (*Bridge) DeleteScene ¶
DeleteScene deletes the scene specified by the id. Additional to communication errors a non 2xx status code of the response will trigger an error.
func (*Bridge) GetAllGroups ¶
GetAllGroups returns all the groups for a hue bridge
func (*Bridge) GetGroupAttributes ¶
GetGroupAttributes returns the state of a group by id
func (*Bridge) GetScene ¶
GetScene will return the scene specified by the id. The result will contain the lights states of lights within the scene.
func (*Bridge) GetState ¶
func (b *Bridge) GetState() (state *BridgeState, err error)
GetState returns the current hue state
func (*Bridge) SetGroupAttributes ¶
func (b *Bridge) SetGroupAttributes(id string, attributes *GroupAttributes) (*BridgeResponse, error)
SetGroupAttributes updates a groups settings by adding devices or changing name or class
func (*Bridge) SetGroupState ¶
func (b *Bridge) SetGroupState(id string, action *GroupAction) ([]*BridgeResponse, error)
SetGroupState sets the state of a group by id
func (*Bridge) SetLightState ¶
func (b *Bridge) SetLightState(id string, state *LightState) (result *BridgeResponse, err error)
SetLightState updates the light state
func (*Bridge) ToggleLight ¶
func (b *Bridge) ToggleLight(id string, on bool) (resp *BridgeResponse, err error)
ToggleLight switches light on or off
type BridgeResponse ¶
type BridgeResponse struct {
Success map[string]interface{} `json:"success"`
Error *BridgeResponseError `json:"error"`
}
BridgeResponse is the response object returned to a bridge command
type BridgeResponseError ¶
type BridgeResponseError struct {
Type uint `json:"type"`
Address string `json:"address"`
Description string `json:"description"`
}
BridgeResponseError provides info about a bridge api error
func (*BridgeResponseError) String ¶
func (err *BridgeResponseError) String() string
type BridgeState ¶
BridgeState provides all data for a bridge
func (*BridgeState) String ¶
func (bs *BridgeState) String() string
type BridgeUserConfig ¶
type BridgeUserConfig struct {
Name string `json:"name"`
APIVersion string `json:"apiversion"`
IPAddress string `json:"ipaddress"`
MAC string `json:"mac"`
BridgeID string `json:"bridgeid"`
DataStoreVersion string `json:"datastoreversion"`
StarterKitID string `json:"starterkitid"`
ReplacesBridgeID string `json:"replacesbridgeid"`
}
BridgeUserConfig is the config provided for hue for a user
type Config ¶
type Config struct {
Username string `yaml:"name"`
Password string `yaml:"userpassword"`
BridgeAddr string `yaml:"bridgeAddress"`
BridgeAddrScheme string `yaml:"bridgeAddressScheme"`
}
Config hue api config
func ReadConfig ¶
TODO: Rename if this will be placed in a seperate package ReadConfig ...
func (*Config) WriteConfig ¶
type CreationScene ¶
type DeviceConfig ¶
type DeviceConfig struct {
ArcheType string `json:"archetype"`
Function string `json:"function"`
Direction string `json:"direction"`
Startup *DeviceStartUp `json:"startup,omitempty"`
}
type DeviceStartUp ¶
type Group ¶
type Group struct {
Name string `json:"name"`
LightIDs []string `json:"lights"`
SensorIDs []string `json:"sensors"`
Type string `json:"type"`
State *GroupState `json:"state"`
Recycle bool `json:"recycle"`
ModelID string `json:"modelid,omitempty"`
UniqueID string `json:"uniqueid,omitempty"`
Class string `json:"class,omitempty"`
Action LightState `json:"action"`
Presence *GroupPresence `json:"presence,omitempty"`
LightLevel *GroupLightLevel `json:"lightlevel,omitempty"`
}
Group hue type
type GroupAction ¶
type GroupAction struct {
On string `json:"on,omitempty"`
Bri uint8 `json:"bri,omitempty"`
Hue uint16 `json:"hue,omitempty"`
Sat uint8 `json:"sat,omitempty"`
Xy []float32 `json:"xy,omitempty"`
Ct uint16 `json:"ct,omitempty"`
Alert string `json:"alert,omitempty"`
Effect string `json:"effect,omitempty"`
TransitionTime uint16 `json:"transitiontime,omitempty"`
BriInc int16 `json:"bri_inc,omitempty"`
SatInc int16 `json:"sat_inc,omitempty"`
HueInc int `json:"hue_inc,omitempty"`
CtInc int `json:"ct_inc,omitempty"`
XyInc int8 `json:"xy_inc,omitempty"`
Scene string `json:"scene,omitempty"`
}
GroupAction is struct for changing a state of a hue group TODO: merge with light actions maybe?
type GroupAttributes ¶
type GroupAttributes struct {
Name string `json:"name,omitempty"`
LightIDs []string `json:"lights,omitempty"`
Class string `json:"class"`
}
GroupAttributes that can be changed
type GroupCreateResponse ¶
type GroupCreateResponse struct {
Success struct {
ID string `json:"id"`
} `json:"success"`
}
GroupCreateResponse is returned after a create group request
type GroupLightLevel ¶
type GroupLightLevel struct {
// State?
LastUpdated Time `json:"lastupdated"`
Dark bool `json:"dark"`
DarkAll bool `json:"dark_all"`
Daylight bool `json:"daylight"`
DaylightAny bool `json:"daylight_any"`
Level int `json:"lightlevel"`
LevelMin int `json:"lightlevel_min"`
LevelMax int `json:"lightlevel_max"`
}
GroupLightLevel light level struct
type GroupPresence ¶
type GroupPresence struct {
// State?
LastUpdated Time `json:"lastupdated"`
Presence bool `json:"presence"`
PresenceAll bool `json:"presence_all"`
}
GroupPresence only exists if sensors array contains a presence sensor of type “ZLLPresence”, “CLIPPresence” or “Geofence”. This object contains a state object which contains the aggregated state of the sensors
type GroupState ¶
GroupState describes the state of a group
type Light ¶
type Light struct {
State *LightState `json:"state,omitempty"`
SwUpdate *SwUpdate `json:"swupdate,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
ModelID string `json:"modelid,omitempty"`
ManufacturerName string `json:"manufacturername,omitempty"`
Productname string `json:"productname,omitempty"`
Capabilities *LightCapabilities `json:"capabilities,omitempty"`
Config *DeviceConfig `json:"config"`
UniqueID string `json:"uniqueid,omitempty"`
SwVersion string `json:"swversion,omitempty"`
SwConfigID string `json:"swconfigid,omitempty"`
ProductID string `json:"productid,omitempty"`
}
Light hue object
type LightCapabilities ¶
type LightCapabilities struct {
Certified bool `json:"certified"`
Control *LightControl `json:"control"`
Streaming *StreamingCapabilities `json:"streaming"`
}
LightCapabilities type providing control and certification settings
type LightControl ¶
type LightState ¶
type LightState struct {
On bool `json:"on"`
BridgeID int `json:"bri,omitempty"`
Hue uint16 `json:"hue,omitempty"`
Sat uint8 `json:"sat,omitempty"`
Effect string `json:"effect,omitempty"`
XY []float32 `json:"xy,omitempty"`
Ct uint16 `json:"ct,omitempty"`
Alert string `json:"alert,omitempty"`
TransitionTime uint16 `json:"transitiontime,omitempty"`
ColorMode string `json:"colormode,omitempty"`
Mode string `json:"mode,omitempty"`
Reachable bool `json:"reachable,omitempty"`
}
LightState is the hue light>state object
type RoomClasses ¶
type RoomClasses int
RoomClasses in hue
const ( LivingRoom RoomClasses = iota Kitchen Dining Bedroom KidsBedroom Bathroom Nursery Recreation Office Gym Hallway Toilet FrontDoor Garage Terrace Garden Driveway Carport Other )
func (RoomClasses) String ¶
func (r RoomClasses) String() string
type Scene ¶
type Scene struct {
BaseScene
LightStates map[int][]*LightState `json:"lightstates,omitempty"`
}
type StreamingCapabilities ¶
type SwUpdate ¶
type SwUpdate struct {
State string `json:"state,omitempty"`
LastInstall Time `json:"lastinstall,omitempty"`
}
SwUpdate provides the current sw state and last install
type Time ¶
func (*Time) MarshalJSON ¶
MarshalJSON marshals mite time to json
func (*Time) UnmarshalJSON ¶
UnmarshalJSON unmarshals mite time from json
type User ¶
type User struct {
// contains filtered or unexported fields
}
func CreateUser ¶
CreateNewUser will create a new user. This should be called only of there's none in the yaml config.
func CreateUserExtended ¶
TODO: remove these comments