Documentation ¶
Index ¶
- Constants
- func Bool(v bool) *bool
- func Discover() (string, error)
- func Int(v int) *int
- func Int64(v int64) *int64
- func Slice(v []string) *[]string
- func String(v string) *string
- func UInt8(v uint8) *uint8
- type ApiError
- type ApiResponse
- type Authenticator
- func (a *Authenticator) AuthURL(state string) string
- func (a *Authenticator) AuthURLWithOpts(state string, opts ...oauth2.AuthCodeOption) string
- func (a *Authenticator) Authenticate() (*Client, error)
- func (a *Authenticator) Exchange(code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
- func (a *Authenticator) GetToken() *oauth2.Token
- func (a *Authenticator) NewClient(token *oauth2.Token) *Client
- func (a *Authenticator) SetAuthInfo(clientID, secretKey string)
- func (a *Authenticator) Token(state string, r *http.Request) (*oauth2.Token, error)
- type Capabilities
- type Client
- type ClientOptions
- type Config
- type Control
- type Ct
- type Group
- type GroupAction
- type GroupService
- func (s *GroupService) CreateGroup(ctx context.Context, name string, lights []string) (string, *Response, error)
- func (s *GroupService) CreateRoom(ctx context.Context, name string, lights []string) (string, *Response, error)
- func (s *GroupService) Delete(ctx context.Context, id string) (*Response, error)
- func (s *GroupService) Get(ctx context.Context, id string) (*Group, *Response, error)
- func (s *GroupService) GetAll(ctx context.Context) ([]Group, *Response, error)
- func (s *GroupService) SetState(ctx context.Context, id string, payload SetStateParams) ([]ApiResponse, *Response, error)
- func (s *GroupService) TurnOff(ctx context.Context, id string) error
- func (s *GroupService) TurnOffAll(ctx context.Context, ids ...string)
- func (s *GroupService) TurnOn(ctx context.Context, id string) error
- func (s *GroupService) TurnOnAll(ctx context.Context, ids ...string)
- func (s *GroupService) Update(ctx context.Context, id string, name *string, lights []string, class *string) (bool, *Response, error)
- type Light
- func (l *Light) GetAlert() string
- func (l *Light) GetBri() uint8
- func (l *Light) GetCT() uint16
- func (l *Light) GetColorMode() string
- func (l *Light) GetEffect() string
- func (l *Light) GetID() int
- func (l *Light) GetMode() string
- func (l *Light) GetName() string
- func (l *Light) GetSat() uint8
- func (l *Light) GetTransitionTime() uint16
- func (l *Light) GetType() string
- func (l *Light) GetXY() []float32
- func (l *Light) IsOn() bool
- func (l *Light) IsReachable() bool
- type LightService
- func (s *LightService) Delete(ctx context.Context, id string) (*Response, error)
- func (s *LightService) Get(ctx context.Context, id string) (*Light, *Response, error)
- func (s *LightService) GetAll(ctx context.Context) ([]Light, *Response, error)
- func (s *LightService) GetNew(ctx context.Context) (map[string]string, *Response, error)
- func (s *LightService) Rename(ctx context.Context, id, name string) (*Response, error)
- func (s *LightService) Search(ctx context.Context) (*Response, error)
- func (s *LightService) SetColor(ctx context.Context, id string, clr color.Color) error
- func (s *LightService) SetColorHex(ctx context.Context, id string, hex string) error
- func (s *LightService) SetState(ctx context.Context, id string, payload SetStateParams) ([]ApiResponse, *Response, error)
- func (s *LightService) TurnOff(ctx context.Context, id string) error
- func (s *LightService) TurnOffAll(ctx context.Context, ids ...string)
- func (s *LightService) TurnOn(ctx context.Context, id string) error
- func (s *LightService) TurnOnAll(ctx context.Context, ids ...string)
- type Response
- type SWUpdate
- type SetStateParams
- type Startup
- type State
- type Streaming
Constants ¶
const ( AuthURL = "https://api.meethue.com/oauth2/auth" TokenURL = "https://api.meethue.com/oauth2/token" ApiURL = "https://api.meethue.com/bridge/" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApiError ¶
type ApiError struct { Type int `json:"type"` Address string `json:"address"` Description string `json:"description"` }
ErrorResponse that Hue returns
type ApiResponse ¶
type ApiResponse struct { Success map[string]interface{} `json:"success,omitempty"` Error *ApiError `json:"error,omitempty"` }
ApiResponse that Hue returns
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
func NewAuthenticator ¶
func NewAuthenticator(redirectURL string) Authenticator
func (*Authenticator) AuthURL ¶
func (a *Authenticator) AuthURL(state string) string
func (*Authenticator) AuthURLWithOpts ¶
func (a *Authenticator) AuthURLWithOpts(state string, opts ...oauth2.AuthCodeOption) string
func (*Authenticator) Authenticate ¶
func (a *Authenticator) Authenticate() (*Client, error)
func (*Authenticator) Exchange ¶
func (a *Authenticator) Exchange(code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
func (*Authenticator) GetToken ¶
func (a *Authenticator) GetToken() *oauth2.Token
func (*Authenticator) SetAuthInfo ¶
func (a *Authenticator) SetAuthInfo(clientID, secretKey string)
type Capabilities ¶
type Client ¶
type Client struct { Lights *LightService Groups *GroupService // contains filtered or unexported fields }
func CreateUser ¶
func CreateUser(host, deviceType string, opts *ClientOptions) (*Client, error)
CreateUser creates local user on the bridge and returns authenticated client instance Don't forget to press bridge button otherwise it will fail
func NewClient ¶
func NewClient(host, clientId string, opts *ClientOptions) *Client
func (*Client) AddWhitelistIdentifier ¶
func (*Client) CreateRemoteUser ¶
func (*Client) EnableLinkButton ¶
func (*Client) GetClientID ¶
GetClientID returns clientID of current client
type Group ¶
type Group struct { ID int Name string `json:"name"` // A unique, editable name given to the group. Lights []string `json:"lights"` // The IDs of the lights that are in the group. Type string `json:"type"` // If not provided upon creation “LightGroup” is used. Can be “LightGroup”, “Room” or either “Luminaire” or “LightSource” if a Multisource Luminaire is present in the system. Action GroupAction `json:"action"` // The light state of one of the lamps in the group. }
Group struct that represents Philips Hue Group
0 (Zero) A special group containing all lights in the system, and is not returned by the ‘get all groups’ command. This group is not visible, and cannot be created, modified or deleted using the API.
func (*Group) GetBrightness ¶
GetBrightness returns which is a scale from 0 (the minimum the light is capable of) to 254 (the maximum). Note: a brightness of 0 is not off.e.g. “brightness”: 60 will set the light to a specific brightness.
func (*Group) GetLights ¶
GetLights returns the ordered set of light ids from the lights which are in the group. This resource shall contain an array of at least one element with the exception of the “Room” type: The Room type may contain an empty lights array. Each element can appear only once. Order of lights on creation is preserved. A light id must be an existing light resource in /lights. If an invalid lights resource is given, error 7 shall be returned and the group is not created. There shall be no change in the lights. Light id can be null if a group has been automatically create by the bridge and a light source is not yet available
func (*Group) GetName ¶
GetName returns human readable name of the group. If name is not specified one is generated for you (default name is “Group”)
func (*Group) GetType ¶
GetType returns type of the Group. If not provided on creation a “LightGroup” is created. Supported types: LightGroup 1.4 Default Luminaire 1.4 multisource luminaire LightSource 1.4 multisource luminaire Room 1.11 Represents a room Entertainment 1.22 Represents an entertainment setup Zone 1.30 Represents a zone
type GroupAction ¶
type GroupAction struct { On bool `json:"on"` // On/Off state of the light. On=true, Off=false Bri int `json:"bri"` // Brightness is a scale from 0 (the minimum the light is capable of) to 254 (the maximum). Note: a brightness of 0 is not off.e.g. “brightness”: 60 will set the light to a specific brightness. Hue int `json:"hue"` // The hue value is a wrapping value between 0 and 65535. Both 0 and 65535 are red, 25500 is green and 46920 is blue.e.g. “hue”: 50000 will set the light to a specific hue. Sat int `json:"sat"` // Saturation of the light. 254 is the most saturated (colored) and 0 is the least saturated (white). Effect string `json:"effect"` // The dynamic effect of the light, currently “none” and “colorloop” are supported. Other values will generate an error of type 7.Setting the effect to colorloop will cycle through all hues using the current brightness and saturation settings. XY []float64 `json:"xy"` // The x and y coordinates of a color in CIE color spaceThe first entry is the x coordinate and the second entry is the y coordinate. Both x and y must be between 0 and 1. If the specified coordinates are not in the CIE color space, the closest color to the coordinates will be chosen. Ct int `json:"ct"` // The Mired Color temperature of the light. 2012 connected lights are capable of 153 (6500K) to 500 (2000K). Alert string `json:"alert"` Colormode string `json:"colormode"` }
GroupAction is used to execute actions on all lights in a group.
type GroupService ¶
type GroupService service
GroupService has functions for groups
func (*GroupService) CreateGroup ¶
func (s *GroupService) CreateGroup(ctx context.Context, name string, lights []string) (string, *Response, error)
CreateGroup creates light group and returns id of the created group
func (*GroupService) CreateRoom ¶
func (s *GroupService) CreateRoom(ctx context.Context, name string, lights []string) (string, *Response, error)
CreateGroup creates light room and returns id of the room
func (*GroupService) SetState ¶
func (s *GroupService) SetState(ctx context.Context, id string, payload SetStateParams) ([]ApiResponse, *Response, error)
SetState updates state of the group
func (*GroupService) TurnOffAll ¶
func (s *GroupService) TurnOffAll(ctx context.Context, ids ...string)
type Light ¶
type Light struct { ID int `json:"-"` State State `json:"state,omitempty"` SWUpdate SWUpdate `json:"swupdate,omitempty"` Type string `json:"type,omitempty"` Name string `json:"name"` ModelId string `json:"modelid,omitempty"` ManufacturerName string `json:"manufacturername,omitempty"` ProductName string `json:"productname,omitempty"` Capabilities Capabilities `json:"capabilities,omitempty"` Config Config `json:"config,omitempty"` UniqueId string `json:"uniqueid,omitempty"` SWVersion string `json:"swversion,omitempty"` SWConfigId string `json:"swconfigid,omitempty"` ProductId string `json:"productid,omitempty"` }
func (*Light) GetColorMode ¶
func (*Light) GetTransitionTime ¶
func (*Light) IsReachable ¶
type LightService ¶
type LightService service
LightService has functions for groups
func (*LightService) GetAll ¶
GetAll returns a list of all lights that have been discovered by the bridge.
func (*LightService) GetNew ¶
GetNew returns a list of lights that were discovered the last time a search for new lights was performed.
func (*LightService) Search ¶
func (s *LightService) Search(ctx context.Context) (*Response, error)
Search starts searching for new lights The bridge will open the network for 40s.
func (*LightService) SetColorHex ¶
SetColorHex changes the color of lamp with hex color code
func (*LightService) SetState ¶
func (s *LightService) SetState(ctx context.Context, id string, payload SetStateParams) ([]ApiResponse, *Response, error)
SetState allows the user to turn the light on and off, modify the hue and effects.
func (*LightService) TurnOff ¶
func (s *LightService) TurnOff(ctx context.Context, id string) error
TurnOff sets on status as false
func (*LightService) TurnOffAll ¶
func (s *LightService) TurnOffAll(ctx context.Context, ids ...string)
TurnOffAll sets on status as false
type SetStateParams ¶
type SetStateParams struct { On *bool `json:"on,omitempty"` Bri *uint8 `json:"bri,omitempty"` Hue *uint16 `json:"hue,omitempty"` Sat *uint8 `json:"sat,omitempty"` Effect *string `json:"effect,omitempty"` XY []float64 `json:"xy,omitempty"` CT *uint16 `json:"ct,omitempty"` Alert *string `json:"alert,omitempty"` TransitionTime *uint16 `json:"transitiontime,omitempty"` BriInc *uint8 `json:"bri_inc,omitempty"` SatInc *uint8 `json:"sat_inc,omitempty"` HueInc *uint16 `json:"hue_inc,omitempty"` CtInc *uint16 `json:"ct_inc,omitempty"` XYInc []float32 `json:"xy_inc,omitempty"` Scene *string `json:"scene,omitempty"` }
type State ¶
type State struct { On bool `json:"on"` Hue uint16 `json:"hue,omitempty"` Effect string `json:"effect,omitempty"` Bri uint8 `json:"bri,omitempty"` Sat uint8 `json:"sat,omitempty"` CT uint16 `json:"ct,omitempty"` XY []float32 `json:"xy,omitempty"` Alert string `json:"alert,omitempty"` TransitionTime uint16 `json:"transitiontime,omitempty"` Reachable bool `json:"reachable,omitempty"` ColorMode string `json:"colormode,omitempty"` Mode string `json:"mode,omitempty"` }