Documentation
¶
Overview ¶
Package huego provides an extensive, easy to use interface to the Philips Hue bridge.
Index ¶
- type APIError
- type APIResponse
- type AutoInstall
- type Backup
- type Bridge
- func (b *Bridge) CreateGroup(g Group) (*Response, error)
- func (b *Bridge) CreateResourcelink(s *Resourcelink) (*Response, error)
- func (b *Bridge) CreateRule(s *Rule) (*Response, error)
- func (b *Bridge) CreateScene(s *Scene) (*Response, error)
- func (b *Bridge) CreateSchedule(s *Schedule) (*Response, error)
- func (b *Bridge) CreateSensor(s *Sensor) (*Response, error)
- func (b *Bridge) CreateUser(n string) (string, error)
- func (b *Bridge) DeleteGroup(i int) error
- func (b *Bridge) DeleteLight(i int) error
- func (b *Bridge) DeleteResourcelink(i int) error
- func (b *Bridge) DeleteRule(i int) error
- func (b *Bridge) DeleteScene(id string) error
- func (b *Bridge) DeleteSchedule(i int) error
- func (b *Bridge) DeleteSensor(i int) error
- func (b *Bridge) DeleteUser(n string) error
- func (b *Bridge) FindLights() (*Response, error)
- func (b *Bridge) FindSensors() (*Response, error)
- func (b *Bridge) GetCapabilities() (*Capabilities, error)
- func (b *Bridge) GetConfig() (*Config, error)
- func (b *Bridge) GetFullState() (*Datastore, error)
- func (b *Bridge) GetGroup(i int) (*Group, error)
- func (b *Bridge) GetGroups() ([]Group, error)
- func (b *Bridge) GetLight(i int) (*Light, error)
- func (b *Bridge) GetLights() ([]Light, error)
- func (b *Bridge) GetNewLights() (*NewLight, error)
- func (b *Bridge) GetNewSensors() (*NewSensor, error)
- func (b *Bridge) GetResourcelink(i int) (*Resourcelink, error)
- func (b *Bridge) GetResourcelinks() ([]Resourcelink, error)
- func (b *Bridge) GetRule(i int) (*Rule, error)
- func (b *Bridge) GetRules() ([]Rule, error)
- func (b *Bridge) GetScene(i string) (*Scene, error)
- func (b *Bridge) GetScenes() ([]Scene, error)
- func (b *Bridge) GetSchedule(i int) (*Schedule, error)
- func (b *Bridge) GetSchedules() ([]*Schedule, error)
- func (b *Bridge) GetSensor(i int) (*Sensor, error)
- func (b *Bridge) GetSensors() ([]Sensor, error)
- func (b *Bridge) GetUsers() ([]Whitelist, error)
- func (b *Bridge) Login(u string) *Bridge
- func (b *Bridge) RecallScene(id string, gid int) (*Response, error)
- func (b *Bridge) SetGroupState(i int, l State) (*Response, error)
- func (b *Bridge) SetLightState(i int, l State) (*Response, error)
- func (b *Bridge) SetSceneLightState(id string, iid int, l *State) (*Response, error)
- func (b *Bridge) UpdateConfig(c *Config) (*Response, error)
- func (b *Bridge) UpdateGroup(i int, l Group) (*Response, error)
- func (b *Bridge) UpdateLight(i int, light Light) (*Response, error)
- func (b *Bridge) UpdateResourcelink(i int, resourcelink *Resourcelink) (*Response, error)
- func (b *Bridge) UpdateRule(i int, rule *Rule) (*Response, error)
- func (b *Bridge) UpdateScene(id string, s *Scene) (*Response, error)
- func (b *Bridge) UpdateSchedule(i int, schedule *Schedule) (*Response, error)
- func (b *Bridge) UpdateSensor(i int, sensor *Sensor) (*Response, error)
- func (b *Bridge) UpdateSensorConfig(i int, c interface{}) (*Response, error)
- type BridgeConfig
- type Capabilities
- type Capability
- type Command
- type Condition
- type Config
- type Datastore
- type DeviceTypes
- type Group
- func (g *Group) Alert(new string) error
- func (g *Group) Bri(new uint8) error
- func (g *Group) Ct(new uint16) error
- func (g *Group) Effect(new string) error
- func (g *Group) Hue(new uint16) error
- func (g *Group) IsOn() bool
- func (g *Group) Off() error
- func (g *Group) On() error
- func (g *Group) Rename(new string) error
- func (g *Group) Sat(new uint8) error
- func (g *Group) Scene(scene string) error
- func (g *Group) SetState(s State) error
- func (g *Group) TransitionTime(new uint16) error
- func (g *Group) Xy(new []float32) error
- type GroupState
- type InternetService
- type Light
- func (l *Light) Alert(new string) error
- func (l *Light) Bri(new uint8) error
- func (l *Light) Ct(new uint16) error
- func (l *Light) Effect(new string) error
- func (l *Light) Hue(new uint16) error
- func (l *Light) IsOn() bool
- func (l *Light) Off() error
- func (l *Light) On() error
- func (l *Light) Rename(new string) error
- func (l *Light) Sat(new uint8) error
- func (l *Light) SetState(s State) error
- func (l *Light) TransitionTime(new uint16) error
- func (l *Light) Xy(new []float32) error
- type NewLight
- type NewSensor
- type PortalState
- type Resourcelink
- type Response
- type Rule
- type RuleAction
- type Scene
- type Schedule
- type Sensor
- type State
- type SwUpdate
- type SwUpdate2
- type Whitelist
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError defines the error response object returned from the bridge after an invalid API request.
func (*APIError) UnmarshalJSON ¶
UnmarshalJSON makes sure that types are correct when unmarshalling. Implements package encoding/json
type APIResponse ¶
type APIResponse struct { Success map[string]interface{} `json:"success,omitempty"` Error *APIError `json:"error,omitempty"` }
APIResponse holds the response data returned form the bridge after a request has been made.
type AutoInstall ¶
type AutoInstall struct { On bool `json:"on,omitempty"` UpdateTime string `json:"updatetime,omitempty"` }
AutoInstall holds automatic update configuration
type Backup ¶
type Backup struct { Status string `json:"backup,omitempty"` ErrorCode int `json:"errorcode,omitempty"` }
Backup holds configuration backup status information
type Bridge ¶
type Bridge struct { Host string `json:"internalipaddress,omitempty"` User string ID string `json:"id,omitempty"` }
Bridge exposes a hardware bridge through a struct.
func Discover ¶
Discover performs a discovery on the network looking for bridges using https://www.meethue.com/api/nupnp service. Discover uses DiscoverAll() but only returns the first instance in the array of bridges if any.
func DiscoverAll ¶
DiscoverAll performs a discovery on the network looking for bridges using https://www.meethue.com/api/nupnp service. DiscoverAll returns a list of Bridge objects.
func New ¶
New instantiates and returns a new Bridge. New accepts hostname/ip address to the bridge (h) as well as an username (u). h may or may not be prefixed with http(s)://. For example http://192.168.1.20/ or 192.168.1.20. u is a username known to the bridge. Use Discover() and CreateUser() to create a user.
func (*Bridge) CreateGroup ¶
CreateGroup creates one new group with attributes defined by g
func (*Bridge) CreateResourcelink ¶
func (b *Bridge) CreateResourcelink(s *Resourcelink) (*Response, error)
CreateResourcelink creates one new resourcelink on the bridge
func (*Bridge) CreateRule ¶
CreateRule creates one rule with attribues defined in s
func (*Bridge) CreateScene ¶
CreateScene creates one new scene with its attributes defined in s
func (*Bridge) CreateSchedule ¶
CreateSchedule creates one schedule and sets its attributes defined in s
func (*Bridge) CreateSensor ¶
CreateSensor creates one new sensor
func (*Bridge) CreateUser ¶
CreateUser creates a user by adding n to the list of whitelists in the bridge
func (*Bridge) DeleteGroup ¶
DeleteGroup deletes one group with the id of i
func (*Bridge) DeleteLight ¶
DeleteLight deletes one lights from the bridge
func (*Bridge) DeleteResourcelink ¶
DeleteResourcelink deletes one resourcelink with the id of i
func (*Bridge) DeleteRule ¶
DeleteRule deletes one rule from the bridge
func (*Bridge) DeleteScene ¶
DeleteScene deletes one scene from the bridge
func (*Bridge) DeleteSchedule ¶
DeleteSchedule deletes one schedule from the bridge by its id of i
func (*Bridge) DeleteSensor ¶
DeleteSensor deletes one sensor from the bridge
func (*Bridge) DeleteUser ¶
DeleteUser removes a whitelist item from whitelists on the bridge
func (*Bridge) FindLights ¶
FindLights starts a search for new lights on the bridge. Use GetNewLights() verify if new lights have been detected.
func (*Bridge) FindSensors ¶
FindSensors starts a search for new sensors. Use GetNewSensors() to verify if new sensors have been discovered in the bridge.
func (*Bridge) GetCapabilities ¶
func (b *Bridge) GetCapabilities() (*Capabilities, error)
GetCapabilities returns a list of capabilities of resources supported in the bridge.
func (*Bridge) GetFullState ¶
GetFullState returns the entire bridge configuration.
func (*Bridge) GetNewLights ¶
GetNewLights returns a list of lights that were discovered last time FindLights() was executed.
func (*Bridge) GetNewSensors ¶
GetNewSensors returns a list of sensors that were discovered last time GetNewSensors() was executed.
func (*Bridge) GetResourcelink ¶
func (b *Bridge) GetResourcelink(i int) (*Resourcelink, error)
GetResourcelink returns one resourcelink by its id defined by i
func (*Bridge) GetResourcelinks ¶
func (b *Bridge) GetResourcelinks() ([]Resourcelink, error)
GetResourcelinks returns all resourcelinks known to the bridge
func (*Bridge) GetSchedule ¶
GetSchedule returns one schedule by id defined in i
func (*Bridge) GetSchedules ¶
GetSchedules returns all scehdules known to the bridge
func (*Bridge) GetSensors ¶
GetSensors returns all sensors known to the bridge
func (*Bridge) RecallScene ¶
RecallScene will recall a scene in a group identified by both scene and group identifiers
func (*Bridge) SetGroupState ¶
SetGroupState allows for setting the state of one group, controlling the state of all lights in that group.
func (*Bridge) SetLightState ¶
SetLightState allows for controlling one light's state
func (*Bridge) SetSceneLightState ¶
SetSceneLightState allows for setting the state of a light in a scene. SetSceneLightState accepts the id of the scene, the id of a light associated with the scene and the state object.
func (*Bridge) UpdateConfig ¶
UpdateConfig updates the bridge configuration with c
func (*Bridge) UpdateGroup ¶
UpdateGroup updates one group known to the bridge
func (*Bridge) UpdateLight ¶
UpdateLight updates one light's attributes and state properties
func (*Bridge) UpdateResourcelink ¶
func (b *Bridge) UpdateResourcelink(i int, resourcelink *Resourcelink) (*Response, error)
UpdateResourcelink updates one resourcelink with attributes defined by resourcelink
func (*Bridge) UpdateRule ¶
UpdateRule updates one rule by its id of i and rule configuration of rule
func (*Bridge) UpdateScene ¶
UpdateScene updates one scene and its attributes by id of i
func (*Bridge) UpdateSchedule ¶
UpdateSchedule updates one schedule by its id of i and attributes by schedule
func (*Bridge) UpdateSensor ¶
UpdateSensor updates one sensor by its id and attributes by sensor
type BridgeConfig ¶
type BridgeConfig struct { State string `json:"state,omitempty"` LastInstall string `json:"lastinstall,omitempty"` }
BridgeConfig holds information about software updates
type Capabilities ¶
type Capabilities struct { Groups *Capability `json:"groups,omitempty"` Lights *Capability `json:"lights,omitempty"` Resourcelinks *Capability `json:"resourcelinks,omitempty"` Schedules *Capability `json:"schedules,omitempty"` Rules *Capability `json:"rules,omitempty"` Scenes *Capability `json:"scenes,omitempty"` Sensors *Capability `json:"sensors,omitempty"` Streaming *Capability `json:"streaming,omitempty"` }
Capabilities holds a combined model of resource capabilities on the bridge: https://developers.meethue.com/documentation/lights-api
type Capability ¶
type Capability struct {
Available int `json:"available,omitempty"`
}
Capability defines the resource and subresource capabilities.
type Command ¶
type Command struct { Address string `json:"address"` Method string `json:"method"` Body interface{} `json:"body"` }
Command defines the request to be made when the schedule occurs
type Condition ¶
type Condition struct { Address string `json:"address,omitempty"` Operator string `json:"operator,omitempty"` Value string `json:"value,omitempty"` }
Condition defines the condition of a rule
type Config ¶
type Config struct { Name string `json:"name,omitempty"` SwUpdate *SwUpdate `json:"swupdate"` SwUpdate2 *SwUpdate2 `json:"swupdate2"` WhitelistMap map[string]Whitelist `json:"whitelist"` Whitelist []Whitelist `json:"-"` PortalState *PortalState `json:"portalstate"` APIVersion string `json:"apiversion,omitempty"` SwVersion string `json:"swversion,omitempty"` ProxyAddress string `json:"proxyaddress,omitempty"` ProxyPort uint16 `json:"proxyport,omitempty"` LinkButton bool `json:"linkbutton,omitempty"` IPAddress string `json:"ipaddress,omitempty"` Mac string `json:"mac,omitempty"` NetMask string `json:"netmask,omitempty"` Gateway string `json:"gateway,omitempty"` Dhcp bool `json:"dhcp,omitempty"` PortalServices bool `json:"portalservices,omitempty"` UTC string `json:"UTC,omitempty"` LocalTime string `json:"localtime,omitempty"` TimeZone string `json:"timezone,omitempty"` ZigbeeChannel uint8 `json:"zigbeechannel,omitempty"` ModelID string `json:"modelid,omitempty"` BridgeID string `json:"bridgeid,omitempty"` FactoryNew bool `json:"factorynew,omitempty"` ReplacesBridgeID string `json:"replacesbridgeid,omitempty"` DatastoreVersion string `json:"datastoreversion,omitempty"` StarterKitID string `json:"starterkitid,omitempty"` InternetService *InternetService `json:"internetservices,omitempty"` }
Config holds the bridge hardware configuration
type Datastore ¶
type Datastore struct { Lights []Light `json:"lights"` Groups []Group `json:"groups"` Config *Config `json:"config"` Schedules []Schedule `json:"schedules"` Scenes []Scene `json:"scenes"` Sensors []Sensor `json:"sensors"` Rules []Rule `json:"rules"` }
Datastore combines all bridge resources into one struct
type DeviceTypes ¶
type DeviceTypes struct { Bridge bool `json:"bridge,omitempty"` Lights []Light `json:"lights,omitempty"` Sensors []Sensor `json:"sensors,omitempty"` }
DeviceTypes details the type of updates available
type Group ¶
type Group struct { Name string `json:"name,omitempty"` Lights []string `json:"lights,omitempty"` Type string `json:"type,omitempty"` GroupState *GroupState `json:"state,omitempty"` Recycle bool `json:"recycle,omitempty"` Class string `json:"class,omitempty"` State *State `json:"action,omitempty"` ID int `json:"-"` // contains filtered or unexported fields }
Group represents a bridge group https://developers.meethue.com/documentation/groups-api
func (*Group) Alert ¶
Alert makes the lights in the group blink in its current color. Supported values are: “none” – The light is not performing an alert effect. “select” – The light is performing one breathe cycle. “lselect” – The light is performing breathe cycles for 15 seconds or until alert is set to "none".
func (*Group) Effect ¶
Effect the dynamic effect of the lights in the group, currently “none” and “colorloop” are supported
func (*Group) Off ¶
Off sets the On state of one group to false, turning all lights in the group off
func (*Group) TransitionTime ¶
TransitionTime sets the duration of the transition from the light’s current state to the new state
type GroupState ¶
type GroupState struct { AllOn bool `json:"all_on,omitempty"` AnyOn bool `json:"any_on,omitempty"` }
GroupState defines the state on a group. Can be used to control the state of all lights in a group rather than controlling them induvidually
type InternetService ¶
type InternetService struct { Internet string `json:"internet,omitempty"` RemoteAccess string `json:"remoteaccess,omitempty"` Time string `json:"time,omitempty"` SwUpdate string `json:"swupdate,omitempty"` }
InternetService stores information about the internet connectivity to the bridge
type Light ¶
type Light struct { State *State `json:"state,omitempty"` Type string `json:"type,omitempty"` Name string `json:"name,omitempty"` ModelID string `json:"modelid,omitempty"` ManufacturerName string `json:"manufacturername,omitempty"` UniqueID string `json:"uniqueid,omitempty"` SwVersion string `json:"swversion,omitempty"` SwConfigID string `json:"swconfigid,omitempty"` ProductID string `json:"productid,omitempty"` ID int `json:"-"` // contains filtered or unexported fields }
Light represents a bridge light https://developers.meethue.com/documentation/lights-api
func (*Light) Alert ¶
Alert makes the light blink in its current color. Supported values are: “none” – The light is not performing an alert effect. “select” – The light is performing one breathe cycle. “lselect” – The light is performing breathe cycles for 15 seconds or until alert is set to "none".
func (*Light) Effect ¶
Effect the dynamic effect of the light, currently “none” and “colorloop” are supported
func (*Light) TransitionTime ¶
TransitionTime sets the duration of the transition from the light’s current state to the new state
type NewLight ¶
NewLight defines a list of lights discovered the last time the bridge performed a light discovery. Also stores the timestamp the last time a discovery was performed.
type NewSensor ¶
NewSensor defines a list of sensors discovered the last time the bridge performed a sensor discovery. Also stores the timestamp the last time a discovery was performed.
type PortalState ¶
type PortalState struct { SignedOn bool `json:"signedon,omitempty"` Incoming bool `json:"incoming,omitempty"` Outgoing bool `json:"outgoing,omitempty"` Communication string `json:"communication,omitempty"` }
PortalState is a struct representing the portal state
type Resourcelink ¶
type Resourcelink struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Type string `json:"type,omitempty"` ClassID uint16 `json:"classid,omitempty"` Owner string `json:"owner,omitempty"` Links []string `json:"links,omitempty"` ID int `json:",omitempty"` }
Resourcelink represents a bridge resourcelink https://developers.meethue.com/documentation/resourcelinks-api
type Response ¶
type Response struct {
Success map[string]interface{}
}
Response is a wrapper struct of the success response returned from the bridge after a successful API call.
type Rule ¶
type Rule struct { Name string `json:"name,omitempty"` LastTriggered string `json:"lasttriggered,omitempty"` CreationTime string `json:"creationtime,omitempty"` TimesTriggered int `json:"timestriggered,omitempty"` Owner string `json:"owner,omitempty"` Status string `json:"status,omitempty"` Conditions []*Condition `json:"conditions,omitempty"` Actions []*RuleAction `json:"actions,omitempty"` ID int `json:",omitempty"` }
Rule represents a bridge rule https://developers.meethue.com/documentation/rules-api
type RuleAction ¶
type RuleAction struct { Address string `json:"address,omitempty"` Method string `json:"method,omitempty"` Body interface{} `json:"body,omitempty"` }
RuleAction defines the rule to execute when a rule triggers
type Scene ¶
type Scene struct { Name string `json:"name,omitempty"` Lights []string `json:"lights,omitempty"` Owner string `json:"owner,omitempty"` Recycle bool `json:"recycle,omitempty"` Locked bool `json:"locked,omitempty"` AppData interface{} `json:"appdata,omitempty"` Picture string `json:"picture,omitempty"` LastUpdated string `json:"lastupdated,omitempty"` Version int `json:"version,omitempty"` StoreSceneState bool `json:"storescenestate,omitempty"` LightStates map[int]State `json:"lightstates,omitempty"` ID string `json:"-"` // contains filtered or unexported fields }
Scene represents a bridge scene https://developers.meethue.com/documentation/scenes-api
type Schedule ¶
type Schedule struct { Name string `json:"name"` Description string `json:"description"` Command *Command `json:"command"` Time string `json:"time,omitempty"` LocalTime string `json:"localtime"` StartTime string `json:"starttime,omitempty"` Status string `json:"status,omitempty"` AutoDelete bool `json:"autodelete"` ID int `json:"-"` }
Schedule represents a bridge schedule https://developers.meethue.com/documentation/schedules-api-0
type Sensor ¶
type Sensor struct { State map[string]interface{} `json:"state,omitempty"` Config map[string]interface{} `json:"config,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` ModelID string `json:"modelid,omitempty"` ManufacturerName string `json:"manufacturername,omitempty"` SwVersion string `json:"swversion,omitemptyn"` ID int `json:",omitempty"` }
Sensor represents a bridge sensor https://developers.meethue.com/documentation/sensors-api
type State ¶
type State struct { On bool `json:"on"` 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 int `json:"bri_inc,omitempty"` SatInc int `json:"sat_inc,omitempty"` HueInc int `json:"hue_inc,omitempty"` CtInc int `json:"ct_inc,omitempty"` XyInc int `json:"xy_inc,omitempty"` ColorMode string `json:"colormode,omitempty"` Reachable bool `json:"reachable,omitempty"` Scene string `json:"scene,omitempty"` }
State defines the attributes and properties of a light
type SwUpdate ¶
type SwUpdate struct { CheckForUpdate bool `json:"checkforupdate,omitempty"` DeviceTypes *DeviceTypes `json:"devicetypes"` UpdateState uint8 `json:"updatestate,omitempty"` Notify bool `json:"notify,omitempty"` URL string `json:"url,omitempty"` Text string `json:"text,omitempty"` }
SwUpdate contains information related to software updates. Deprecated in 1.20
type SwUpdate2 ¶
type SwUpdate2 struct { Bridge *BridgeConfig `json:"bridge"` CheckForUpdate bool `json:"checkforupdate,omitempty"` State string `json:"state,omitempty"` Install bool `json:"install,omitempty"` AutoInstall *AutoInstall `json:"autoinstall"` LastChange string `json:"lastchange,omitempty"` LastInstall string `json:"lastinstall,omitempty"` }
SwUpdate2 contains information related to software updates