huego

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 12 Imported by: 49

README

Go Go Report Card codecov Awesome

Huego

An extensive Philips Hue client library for Go with an emphasis on simplicity. It is designed to be clean, unbloated and extensible. With Huego you can interact with any Philips Hue bridge and its resources including Lights, Groups, Scenes, Sensors, Rules, Schedules, Resourcelinks, Capabilities and Configuration .

Installation

Get the package and import it in your code.

go get github.com/amimof/huego

You may use New() if you have already created an user and know the IP address to your bridge.

package main

import (
  "github.com/amimof/huego"
  "fmt"
)

func main() {
  bridge := huego.New("192.168.1.59", "username")
  l, err := bridge.GetLights()
  if err != nil {
    panic(err)
  }
  fmt.Printf("Found %d lights", len(l))
}

Or discover a bridge on your network with Discover() and create a new user with CreateUser(). To successfully create a user, the link button on your bridge must have been pressed before calling CreateUser() in order to authorise the request.

func main() {
  bridge, _ := huego.Discover()
  user, _ := bridge.CreateUser("my awesome hue app") // Link button needs to be pressed
  bridge = bridge.Login(user)
  light, _ := bridge.GetLight(3)
  light.Off()
}

Documentation

See godoc.org/github.com/amimof/huego for the full package documentation.

Contributing

All help in any form is highly appreciated and your are welcome participate in developing Huego together. To contribute submit a Pull Request. If you want to provide feedback, open up a Github Issue or contact me personally.

Documentation

Overview

Package huego provides an extensive, easy to use interface to the Philips Hue bridge.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertRGBToXy added in v1.2.1

func ConvertRGBToXy(newcolor color.Color) ([]float32, uint8)

ConvertRGBToXy converts a given RGB color to the xy color of the ligth. implemented as in https://developers.meethue.com/develop/application-design-guidance/color-conversion-formulas-rgb-to-xy-and-back/

Types

type APIError

type APIError struct {
	Type        int
	Address     string
	Description string
}

APIError defines the error response object returned from the bridge after an invalid API request.

func (*APIError) Error

func (a *APIError) Error() string

Error returns an error string

func (*APIError) UnmarshalJSON

func (a *APIError) UnmarshalJSON(data []byte) error

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

func Discover() (*Bridge, error)

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

func DiscoverAll() ([]Bridge, error)

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 DiscoverAllContext added in v1.1.0

func DiscoverAllContext(ctx context.Context) ([]Bridge, error)

DiscoverAllContext performs a discovery on the network looking for bridges using https://www.meethue.com/api/nupnp service. DiscoverAllContext returns a list of Bridge objects.

func DiscoverContext added in v1.1.0

func DiscoverContext(ctx context.Context) (*Bridge, error)

DiscoverContext performs a discovery on the network looking for bridges using https://www.meethue.com/api/nupnp service. DiscoverContext uses DiscoverAllContext() but only returns the first instance in the array of bridges if any.

func New

func New(h, u string) *Bridge

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

func (b *Bridge) CreateGroup(g Group) (*Response, error)

CreateGroup creates one new group with attributes defined by g

func (*Bridge) CreateGroupContext added in v1.1.0

func (b *Bridge) CreateGroupContext(ctx context.Context, g Group) (*Response, error)

CreateGroupContext creates one new group with attributes defined by g

func (b *Bridge) CreateResourcelink(s *Resourcelink) (*Response, error)

CreateResourcelink creates one new resourcelink on the bridge

func (*Bridge) CreateResourcelinkContext added in v1.1.0

func (b *Bridge) CreateResourcelinkContext(ctx context.Context, s *Resourcelink) (*Response, error)

CreateResourcelinkContext creates one new resourcelink on the bridge

func (*Bridge) CreateRule

func (b *Bridge) CreateRule(s *Rule) (*Response, error)

CreateRule creates one rule with attribues defined in s

func (*Bridge) CreateRuleContext added in v1.1.0

func (b *Bridge) CreateRuleContext(ctx context.Context, s *Rule) (*Response, error)

CreateRuleContext creates one rule with attribues defined in s

func (*Bridge) CreateScene

func (b *Bridge) CreateScene(s *Scene) (*Response, error)

CreateScene creates one new scene with its attributes defined in s

func (*Bridge) CreateSceneContext added in v1.1.0

func (b *Bridge) CreateSceneContext(ctx context.Context, s *Scene) (*Response, error)

CreateSceneContext creates one new scene with its attributes defined in s

func (*Bridge) CreateSchedule

func (b *Bridge) CreateSchedule(s *Schedule) (*Response, error)

CreateSchedule creates one schedule and sets its attributes defined in s

func (*Bridge) CreateScheduleContext added in v1.1.0

func (b *Bridge) CreateScheduleContext(ctx context.Context, s *Schedule) (*Response, error)

CreateScheduleContext creates one schedule and sets its attributes defined in s

func (*Bridge) CreateSensor

func (b *Bridge) CreateSensor(s *Sensor) (*Response, error)

CreateSensor creates one new sensor

func (*Bridge) CreateSensorContext added in v1.1.0

func (b *Bridge) CreateSensorContext(ctx context.Context, s *Sensor) (*Response, error)

CreateSensorContext creates one new sensor

func (*Bridge) CreateUser

func (b *Bridge) CreateUser(n string) (string, error)

CreateUser creates a user by adding n to the list of whitelists in the bridge. The link button on the bridge must have been pressed before calling CreateUser.

Example
bridge, _ := Discover()
user, err := bridge.CreateUser("my awesome hue app") // Link button needs to be pressed
if err != nil {
	fmt.Printf("Error creating user: %s", err.Error())
}
bridge = bridge.Login(user)
light, _ := bridge.GetLight(1)
light.Off()
Output:

func (*Bridge) CreateUserContext added in v1.1.0

func (b *Bridge) CreateUserContext(ctx context.Context, n string) (string, error)

CreateUserContext creates a user by adding n to the list of whitelists in the bridge. The link button on the bridge must have been pressed before calling CreateUser.

func (*Bridge) CreateUserWithClientKey added in v1.2.0

func (b *Bridge) CreateUserWithClientKey(deviceType string) (*Whitelist, error)

CreateUserWithClientKey creates a user by adding deviceType to the list of whitelisted users on the bridge. The link button on the bridge must have been pressed before calling CreateUser.

func (*Bridge) CreateUserWithClientKeyContext added in v1.2.0

func (b *Bridge) CreateUserWithClientKeyContext(ctx context.Context, deviceType string) (*Whitelist, error)

CreateUserWithClientKeyContext creates a user by adding deviceType to the list of whitelisted users on the bridge The link button on the bridge must have been pressed before calling CreateUser.

func (*Bridge) DeleteGroup

func (b *Bridge) DeleteGroup(i int) error

DeleteGroup deletes one group with the id of i

func (*Bridge) DeleteGroupContext added in v1.1.0

func (b *Bridge) DeleteGroupContext(ctx context.Context, i int) error

DeleteGroupContext deletes one group with the id of i

func (*Bridge) DeleteLight

func (b *Bridge) DeleteLight(i int) error

DeleteLight deletes one lights from the bridge

func (*Bridge) DeleteLightContext added in v1.1.0

func (b *Bridge) DeleteLightContext(ctx context.Context, i int) error

DeleteLightContext deletes one lights from the bridge

func (b *Bridge) DeleteResourcelink(i int) error

DeleteResourcelink deletes one resourcelink with the id of i

func (*Bridge) DeleteResourcelinkContext added in v1.1.0

func (b *Bridge) DeleteResourcelinkContext(ctx context.Context, i int) error

DeleteResourcelinkContext deletes one resourcelink with the id of i

func (*Bridge) DeleteRule

func (b *Bridge) DeleteRule(i int) error

DeleteRule deletes one rule from the bridge

func (*Bridge) DeleteRuleContext added in v1.1.0

func (b *Bridge) DeleteRuleContext(ctx context.Context, i int) error

DeleteRuleContext deletes one rule from the bridge

func (*Bridge) DeleteScene

func (b *Bridge) DeleteScene(id string) error

DeleteScene deletes one scene from the bridge

func (*Bridge) DeleteSceneContext added in v1.1.0

func (b *Bridge) DeleteSceneContext(ctx context.Context, id string) error

DeleteSceneContext deletes one scene from the bridge

func (*Bridge) DeleteSchedule

func (b *Bridge) DeleteSchedule(i int) error

DeleteSchedule deletes one schedule from the bridge by its id of i

func (*Bridge) DeleteScheduleContext added in v1.1.0

func (b *Bridge) DeleteScheduleContext(ctx context.Context, i int) error

DeleteScheduleContext deletes one schedule from the bridge by its id of i

func (*Bridge) DeleteSensor

func (b *Bridge) DeleteSensor(i int) error

DeleteSensor deletes one sensor from the bridge

func (*Bridge) DeleteSensorContext added in v1.1.0

func (b *Bridge) DeleteSensorContext(ctx context.Context, i int) error

DeleteSensorContext deletes one sensor from the bridge

func (*Bridge) DeleteUser

func (b *Bridge) DeleteUser(n string) error

DeleteUser removes a whitelist item from whitelists on the bridge

func (*Bridge) DeleteUserContext added in v1.1.0

func (b *Bridge) DeleteUserContext(ctx context.Context, n string) error

DeleteUserContext removes a whitelist item from whitelists on the bridge

func (*Bridge) FindLights

func (b *Bridge) FindLights() (*Response, error)

FindLights starts a search for new lights on the bridge. Use GetNewLights() verify if new lights have been detected.

func (*Bridge) FindLightsContext added in v1.1.0

func (b *Bridge) FindLightsContext(ctx context.Context) (*Response, error)

FindLightsContext starts a search for new lights on the bridge. Use GetNewLights() verify if new lights have been detected.

func (*Bridge) FindSensors

func (b *Bridge) FindSensors() (*Response, error)

FindSensors starts a search for new sensors. Use GetNewSensors() to verify if new sensors have been discovered in the bridge.

func (*Bridge) FindSensorsContext added in v1.1.0

func (b *Bridge) FindSensorsContext(ctx context.Context) (*Response, error)

FindSensorsContext starts a search for new sensors. Use GetNewSensorsContext() 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) GetCapabilitiesContext added in v1.1.0

func (b *Bridge) GetCapabilitiesContext(ctx context.Context) (*Capabilities, error)

GetCapabilitiesContext returns a list of capabilities of resources supported in the bridge.

func (*Bridge) GetConfig

func (b *Bridge) GetConfig() (*Config, error)

GetConfig returns the bridge configuration

func (*Bridge) GetConfigContext added in v1.1.0

func (b *Bridge) GetConfigContext(ctx context.Context) (*Config, error)

GetConfigContext returns the bridge configuration

func (*Bridge) GetFullState

func (b *Bridge) GetFullState() (map[string]interface{}, error)

GetFullState returns the entire bridge configuration.

func (*Bridge) GetFullStateContext added in v1.1.0

func (b *Bridge) GetFullStateContext(ctx context.Context) (map[string]interface{}, error)

GetFullStateContext returns the entire bridge configuration.

func (*Bridge) GetGroup

func (b *Bridge) GetGroup(i int) (*Group, error)

GetGroup returns one group known to the bridge by its id

func (*Bridge) GetGroupContext added in v1.1.0

func (b *Bridge) GetGroupContext(ctx context.Context, i int) (*Group, error)

GetGroupContext returns one group known to the bridge by its id

func (*Bridge) GetGroups

func (b *Bridge) GetGroups() ([]Group, error)

GetGroups returns all groups known to the bridge

func (*Bridge) GetGroupsContext added in v1.1.0

func (b *Bridge) GetGroupsContext(ctx context.Context) ([]Group, error)

GetGroupsContext returns all groups known to the bridge

func (*Bridge) GetLight

func (b *Bridge) GetLight(i int) (*Light, error)

GetLight returns one light with the id of i

func (*Bridge) GetLightContext added in v1.1.0

func (b *Bridge) GetLightContext(ctx context.Context, i int) (*Light, error)

GetLightContext returns one light with the id of i

func (*Bridge) GetLights

func (b *Bridge) GetLights() ([]Light, error)

GetLights returns all lights known to the bridge

func (*Bridge) GetLightsContext added in v1.1.0

func (b *Bridge) GetLightsContext(ctx context.Context) ([]Light, error)

GetLightsContext returns all lights known to the bridge

func (*Bridge) GetNewLights

func (b *Bridge) GetNewLights() (*NewLight, error)

GetNewLights returns a list of lights that were discovered last time FindLights() was executed.

func (*Bridge) GetNewLightsContext added in v1.1.0

func (b *Bridge) GetNewLightsContext(ctx context.Context) (*NewLight, error)

GetNewLightsContext returns a list of lights that were discovered last time FindLights() was executed.

func (*Bridge) GetNewSensors

func (b *Bridge) GetNewSensors() (*NewSensor, error)

GetNewSensors returns a list of sensors that were discovered last time GetNewSensors() was executed.

func (*Bridge) GetNewSensorsContext added in v1.1.0

func (b *Bridge) GetNewSensorsContext(ctx context.Context) (*NewSensor, error)

GetNewSensorsContext returns a list of sensors that were discovered last time GetNewSensors() was executed.

func (b *Bridge) GetResourcelink(i int) (*Resourcelink, error)

GetResourcelink returns one resourcelink by its id defined by i

func (*Bridge) GetResourcelinkContext added in v1.1.0

func (b *Bridge) GetResourcelinkContext(ctx context.Context, i int) (*Resourcelink, error)

GetResourcelinkContext returns one resourcelink by its id defined by i

func (b *Bridge) GetResourcelinks() ([]*Resourcelink, error)

GetResourcelinks returns all resourcelinks known to the bridge

func (*Bridge) GetResourcelinksContext added in v1.1.0

func (b *Bridge) GetResourcelinksContext(ctx context.Context) ([]*Resourcelink, error)

GetResourcelinksContext returns all resourcelinks known to the bridge

func (*Bridge) GetRule

func (b *Bridge) GetRule(i int) (*Rule, error)

GetRule returns one rule by its id of i

func (*Bridge) GetRuleContext added in v1.1.0

func (b *Bridge) GetRuleContext(ctx context.Context, i int) (*Rule, error)

GetRuleContext returns one rule by its id of i

func (*Bridge) GetRules

func (b *Bridge) GetRules() ([]*Rule, error)

GetRules returns all rules known to the bridge

func (*Bridge) GetRulesContext added in v1.1.0

func (b *Bridge) GetRulesContext(ctx context.Context) ([]*Rule, error)

GetRulesContext returns all rules known to the bridge

func (*Bridge) GetScene

func (b *Bridge) GetScene(i string) (*Scene, error)

GetScene returns one scene by its id of i

func (*Bridge) GetSceneContext added in v1.1.0

func (b *Bridge) GetSceneContext(ctx context.Context, i string) (*Scene, error)

GetSceneContext returns one scene by its id of i

func (*Bridge) GetScenes

func (b *Bridge) GetScenes() ([]Scene, error)

GetScenes returns all scenes known to the bridge

func (*Bridge) GetScenesContext added in v1.1.0

func (b *Bridge) GetScenesContext(ctx context.Context) ([]Scene, error)

GetScenesContext returns all scenes known to the bridge

func (*Bridge) GetSchedule

func (b *Bridge) GetSchedule(i int) (*Schedule, error)

GetSchedule returns one schedule by id defined in i

func (*Bridge) GetScheduleContext added in v1.1.0

func (b *Bridge) GetScheduleContext(ctx context.Context, i int) (*Schedule, error)

GetScheduleContext returns one schedule by id defined in i

func (*Bridge) GetSchedules

func (b *Bridge) GetSchedules() ([]*Schedule, error)

GetSchedules returns all schedules known to the bridge

func (*Bridge) GetSchedulesContext added in v1.1.0

func (b *Bridge) GetSchedulesContext(ctx context.Context) ([]*Schedule, error)

GetSchedulesContext returns all schedules known to the bridge

func (*Bridge) GetSensor

func (b *Bridge) GetSensor(i int) (*Sensor, error)

GetSensor returns one sensor by its id of i

func (*Bridge) GetSensorContext added in v1.1.0

func (b *Bridge) GetSensorContext(ctx context.Context, i int) (*Sensor, error)

GetSensorContext returns one sensor by its id of i

func (*Bridge) GetSensors

func (b *Bridge) GetSensors() ([]Sensor, error)

GetSensors returns all sensors known to the bridge

func (*Bridge) GetSensorsContext added in v1.1.0

func (b *Bridge) GetSensorsContext(ctx context.Context) ([]Sensor, error)

GetSensorsContext returns all sensors known to the bridge

func (*Bridge) GetUsers

func (b *Bridge) GetUsers() ([]Whitelist, error)

GetUsers returns a list of whitelists from the bridge

func (*Bridge) IdentifyLight added in v1.2.1

func (b *Bridge) IdentifyLight(i int) (*Response, error)

IdentifyLight allows identifying a light

func (*Bridge) IdentifyLightContext added in v1.2.1

func (b *Bridge) IdentifyLightContext(ctx context.Context, i int) (*Response, error)

IdentifyLightContext allows identifying a light

func (*Bridge) Login

func (b *Bridge) Login(u string) *Bridge

Login calls New() and passes Host on this Bridge instance.

func (*Bridge) RecallScene

func (b *Bridge) RecallScene(id string, gid int) (*Response, error)

RecallScene will recall a scene in a group identified by both scene and group identifiers

func (*Bridge) RecallSceneContext added in v1.1.0

func (b *Bridge) RecallSceneContext(ctx context.Context, id string, gid int) (*Response, error)

RecallSceneContext will recall a scene in a group identified by both scene and group identifiers

func (*Bridge) SetGroupState

func (b *Bridge) SetGroupState(i int, l State) (*Response, error)

SetGroupState allows for setting the state of one group, controlling the state of all lights in that group.

func (*Bridge) SetGroupStateContext added in v1.1.0

func (b *Bridge) SetGroupStateContext(ctx context.Context, i int, l State) (*Response, error)

SetGroupStateContext allows for setting the state of one group, controlling the state of all lights in that group.

func (*Bridge) SetLightState

func (b *Bridge) SetLightState(i int, l State) (*Response, error)

SetLightState allows for controlling one light's state

func (*Bridge) SetLightStateContext added in v1.1.0

func (b *Bridge) SetLightStateContext(ctx context.Context, i int, l State) (*Response, error)

SetLightStateContext allows for controlling one light's state

func (*Bridge) SetSceneLightState

func (b *Bridge) SetSceneLightState(id string, iid int, l *State) (*Response, error)

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) SetSceneLightStateContext added in v1.1.0

func (b *Bridge) SetSceneLightStateContext(ctx context.Context, id string, iid int, l *State) (*Response, error)

SetSceneLightStateContext allows for setting the state of a light in a scene. SetSceneLightStateContext accepts the id of the scene, the id of a light associated with the scene and the state object.

func (*Bridge) UpdateConfig

func (b *Bridge) UpdateConfig(c *Config) (*Response, error)

UpdateConfig updates the bridge configuration with c

func (*Bridge) UpdateConfigContext added in v1.1.0

func (b *Bridge) UpdateConfigContext(ctx context.Context, c *Config) (*Response, error)

UpdateConfigContext updates the bridge configuration with c

func (*Bridge) UpdateGroup

func (b *Bridge) UpdateGroup(i int, l Group) (*Response, error)

UpdateGroup updates one group known to the bridge

func (*Bridge) UpdateGroupContext added in v1.1.0

func (b *Bridge) UpdateGroupContext(ctx context.Context, i int, l Group) (*Response, error)

UpdateGroupContext updates one group known to the bridge

func (*Bridge) UpdateLight

func (b *Bridge) UpdateLight(i int, light Light) (*Response, error)

UpdateLight updates one light's attributes and state properties

func (*Bridge) UpdateLightContext added in v1.1.0

func (b *Bridge) UpdateLightContext(ctx context.Context, i int, light Light) (*Response, error)

UpdateLightContext updates one light's attributes and state properties

func (b *Bridge) UpdateResourcelink(i int, resourcelink *Resourcelink) (*Response, error)

UpdateResourcelink updates one resourcelink with attributes defined by resourcelink

func (*Bridge) UpdateResourcelinkContext added in v1.1.0

func (b *Bridge) UpdateResourcelinkContext(ctx context.Context, i int, resourcelink *Resourcelink) (*Response, error)

UpdateResourcelinkContext updates one resourcelink with attributes defined by resourcelink

func (*Bridge) UpdateRule

func (b *Bridge) UpdateRule(i int, rule *Rule) (*Response, error)

UpdateRule updates one rule by its id of i and rule configuration of rule

func (*Bridge) UpdateRuleContext added in v1.1.0

func (b *Bridge) UpdateRuleContext(ctx context.Context, i int, rule *Rule) (*Response, error)

UpdateRuleContext updates one rule by its id of i and rule configuration of rule

func (*Bridge) UpdateScene

func (b *Bridge) UpdateScene(id string, s *Scene) (*Response, error)

UpdateScene updates one scene and its attributes by id of i

func (*Bridge) UpdateSceneContext added in v1.1.0

func (b *Bridge) UpdateSceneContext(ctx context.Context, id string, s *Scene) (*Response, error)

UpdateSceneContext updates one scene and its attributes by id of i

func (*Bridge) UpdateSchedule

func (b *Bridge) UpdateSchedule(i int, schedule *Schedule) (*Response, error)

UpdateSchedule updates one schedule by its id of i and attributes by schedule

func (*Bridge) UpdateScheduleContext added in v1.1.0

func (b *Bridge) UpdateScheduleContext(ctx context.Context, i int, schedule *Schedule) (*Response, error)

UpdateScheduleContext updates one schedule by its id of i and attributes by schedule

func (*Bridge) UpdateSensor

func (b *Bridge) UpdateSensor(i int, sensor *Sensor) (*Response, error)

UpdateSensor updates one sensor by its id and attributes by sensor

func (*Bridge) UpdateSensorConfig

func (b *Bridge) UpdateSensorConfig(i int, c interface{}) (*Response, error)

UpdateSensorConfig updates the configuration of one sensor. The allowed configuration parameters depend on the sensor type

func (*Bridge) UpdateSensorConfigContext added in v1.1.0

func (b *Bridge) UpdateSensorConfigContext(ctx context.Context, i int, c interface{}) (*Response, error)

UpdateSensorConfigContext updates the configuration of one sensor. The allowed configuration parameters depend on the sensor type

func (*Bridge) UpdateSensorContext added in v1.1.0

func (b *Bridge) UpdateSensorContext(ctx context.Context, i int, sensor *Sensor) (*Response, error)

UpdateSensorContext 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 DeviceTypes

type DeviceTypes struct {
	Bridge  bool     `json:"bridge,omitempty"`
	Lights  []string `json:"lights,omitempty"`
	Sensors []string `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"`
	Stream     *Stream              `json:"stream,omitempty"`
	Locations  map[string][]float64 `json:"locations,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

func (g *Group) Alert(new string) error

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) AlertContext added in v1.1.0

func (g *Group) AlertContext(ctx context.Context, new string) error

AlertContext 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) Bri

func (g *Group) Bri(new uint8) error

Bri sets the light brightness state property

func (*Group) BriContext added in v1.1.0

func (g *Group) BriContext(ctx context.Context, new uint8) error

BriContext sets the light brightness state property

func (*Group) Col added in v1.2.1

func (g *Group) Col(new color.Color) error

Col sets the light color as RGB (will be converted to xy)

func (*Group) ColContext added in v1.2.1

func (g *Group) ColContext(ctx context.Context, new color.Color) error

ColContext sets the light color as RGB (will be converted to xy)

func (*Group) Ct

func (g *Group) Ct(new uint16) error

Ct sets the light color temperature state property

func (*Group) CtContext added in v1.1.0

func (g *Group) CtContext(ctx context.Context, new uint16) error

CtContext sets the light color temperature state property

func (*Group) DisableStreaming added in v1.2.0

func (g *Group) DisableStreaming() error

DisableStreaming disabled streaming for the group by setting the Stream Active property to false

func (*Group) DisableStreamingContext added in v1.2.0

func (g *Group) DisableStreamingContext(ctx context.Context) error

DisableStreamingContext disabled streaming for the group by setting the Stream Active property to false

func (*Group) Effect

func (g *Group) Effect(new string) error

Effect the dynamic effect of the lights in the group, currently “none” and “colorloop” are supported

func (*Group) EffectContext added in v1.1.0

func (g *Group) EffectContext(ctx context.Context, new string) error

EffectContext the dynamic effect of the lights in the group, currently “none” and “colorloop” are supported

func (*Group) EnableStreaming added in v1.2.0

func (g *Group) EnableStreaming() error

EnableStreaming enables streaming for the group by setting the Stream Active property to true

func (*Group) EnableStreamingContext added in v1.2.0

func (g *Group) EnableStreamingContext(ctx context.Context) error

EnableStreamingContext enables streaming for the group by setting the Stream Active property to true

func (*Group) Hue

func (g *Group) Hue(new uint16) error

Hue sets the light hue state property (0-65535)

func (*Group) HueContext added in v1.1.0

func (g *Group) HueContext(ctx context.Context, new uint16) error

HueContext sets the light hue state property (0-65535)

func (*Group) IsOn

func (g *Group) IsOn() bool

IsOn returns true if light state On property is true

func (*Group) Off

func (g *Group) Off() error

Off sets the On state of one group to false, turning all lights in the group off

func (*Group) OffContext added in v1.1.0

func (g *Group) OffContext(ctx context.Context) error

OffContext sets the On state of one group to false, turning all lights in the group off

func (*Group) On

func (g *Group) On() error

On sets the On state of one group to true, turning all lights in the group on

func (*Group) OnContext added in v1.1.0

func (g *Group) OnContext(ctx context.Context) error

OnContext sets the On state of one group to true, turning all lights in the group on

func (*Group) Rename

func (g *Group) Rename(new string) error

Rename sets the name property of the group

func (*Group) RenameContext added in v1.1.0

func (g *Group) RenameContext(ctx context.Context, new string) error

RenameContext sets the name property of the group

func (*Group) Sat

func (g *Group) Sat(new uint8) error

Sat sets the light saturation state property (0-254)

func (*Group) SatContext added in v1.1.0

func (g *Group) SatContext(ctx context.Context, new uint8) error

SatContext sets the light saturation state property (0-254)

func (*Group) Scene

func (g *Group) Scene(scene string) error

Scene sets the scene by it's identifier of the scene you wish to recall

func (*Group) SceneContext added in v1.1.0

func (g *Group) SceneContext(ctx context.Context, scene string) error

SceneContext sets the scene by it's identifier of the scene you wish to recall

func (*Group) SetState

func (g *Group) SetState(s State) error

SetState sets the state of the group to s.

func (*Group) SetStateContext added in v1.1.0

func (g *Group) SetStateContext(ctx context.Context, s State) error

SetStateContext sets the state of the group to s.

func (*Group) TransitionTime

func (g *Group) TransitionTime(new uint16) error

TransitionTime sets the duration of the transition from the light’s current state to the new state

func (*Group) TransitionTimeContext added in v1.1.0

func (g *Group) TransitionTimeContext(ctx context.Context, new uint16) error

TransitionTimeContext sets the duration of the transition from the light’s current state to the new state

func (*Group) Xy

func (g *Group) Xy(new []float32) error

Xy sets the x and y coordinates of a color in CIE color space. (0-1 per value)

func (*Group) XyContext added in v1.1.0

func (g *Group) XyContext(ctx context.Context, new []float32) error

XyContext sets the x and y coordinates of a color in CIE color space. (0-1 per value)

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 individually

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"`
	ProductName      string `json:"productname,omitempty"`
	ID               int    `json:"-"`
	// contains filtered or unexported fields
}

Light represents a bridge light https://developers.meethue.com/documentation/lights-api

func (*Light) Alert

func (l *Light) Alert(new string) error

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) AlertContext added in v1.1.0

func (l *Light) AlertContext(ctx context.Context, new string) error

AlertContext 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) Bri

func (l *Light) Bri(new uint8) error

Bri sets the light brightness state property

func (*Light) BriContext added in v1.1.0

func (l *Light) BriContext(ctx context.Context, new uint8) error

BriContext sets the light brightness state property

func (*Light) Col added in v1.2.1

func (l *Light) Col(new color.Color) error

Col sets the light color as RGB (will be converted to xy)

func (*Light) ColContext added in v1.2.1

func (l *Light) ColContext(ctx context.Context, new color.Color) error

ColContext sets the light color as RGB (will be converted to xy)

func (*Light) Ct

func (l *Light) Ct(new uint16) error

Ct sets the light color temperature state property

func (*Light) CtContext added in v1.1.0

func (l *Light) CtContext(ctx context.Context, new uint16) error

CtContext sets the light color temperature state property

func (*Light) Effect

func (l *Light) Effect(new string) error

Effect the dynamic effect of the light, currently “none” and “colorloop” are supported

func (*Light) EffectContext added in v1.1.0

func (l *Light) EffectContext(ctx context.Context, new string) error

EffectContext the dynamic effect of the light, currently “none” and “colorloop” are supported

func (*Light) Hue

func (l *Light) Hue(new uint16) error

Hue sets the light hue state property (0-65535)

func (*Light) HueContext added in v1.1.0

func (l *Light) HueContext(ctx context.Context, new uint16) error

HueContext sets the light hue state property (0-65535)

func (*Light) IsOn

func (l *Light) IsOn() bool

IsOn returns true if light state On property is true

func (*Light) Off

func (l *Light) Off() error

Off sets the On state of one light to false, turning it off

func (*Light) OffContext added in v1.1.0

func (l *Light) OffContext(ctx context.Context) error

OffContext sets the On state of one light to false, turning it off

func (*Light) On

func (l *Light) On() error

On sets the On state of one light to true, turning it on

func (*Light) OnContext added in v1.1.0

func (l *Light) OnContext(ctx context.Context) error

OnContext sets the On state of one light to true, turning it on

func (*Light) Rename

func (l *Light) Rename(new string) error

Rename sets the name property of the light

func (*Light) RenameContext added in v1.1.0

func (l *Light) RenameContext(ctx context.Context, new string) error

RenameContext sets the name property of the light

func (*Light) Sat

func (l *Light) Sat(new uint8) error

Sat sets the light saturation state property (0-254)

func (*Light) SatContext added in v1.1.0

func (l *Light) SatContext(ctx context.Context, new uint8) error

SatContext sets the light saturation state property (0-254)

func (*Light) SetState

func (l *Light) SetState(s State) error

SetState sets the state of the light to s.

func (*Light) SetStateContext added in v1.1.0

func (l *Light) SetStateContext(ctx context.Context, s State) error

SetStateContext sets the state of the light to s.

func (*Light) TransitionTime

func (l *Light) TransitionTime(new uint16) error

TransitionTime sets the duration of the transition from the light’s current state to the new state

func (*Light) TransitionTimeContext added in v1.1.0

func (l *Light) TransitionTimeContext(ctx context.Context, new uint16) error

TransitionTimeContext sets the duration of the transition from the light’s current state to the new state

func (*Light) Xy

func (l *Light) Xy(new []float32) error

Xy sets the x and y coordinates of a color in CIE color space. (0-1 per value)

func (*Light) XyContext added in v1.1.0

func (l *Light) XyContext(ctx context.Context, new []float32) error

XyContext sets the x and y coordinates of a color in CIE color space. (0-1 per value)

type NewLight

type NewLight struct {
	Lights   []string
	LastScan string `json:"lastscan"`
}

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

type NewSensor struct {
	Sensors  []*Sensor
	LastScan string `json:"lastscan"`
}

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 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"`
	Type            string        `json:"type,omitempty"`
	Group           string        `json:"group,omitempty"`
	Lights          []string      `json:"lights,omitempty"`
	Owner           string        `json:"owner,omitempty"`
	Recycle         bool          `json:"recycle"`
	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"`
	StoreLightState bool          `json:"storelightstate,omitempty"`
	LightStates     map[int]State `json:"lightstates,omitempty"`
	TransitionTime  uint16        `json:"transitiontime,omitempty"`
	ID              string        `json:"-"`
	// contains filtered or unexported fields
}

Scene represents a bridge scene https://developers.meethue.com/documentation/scenes-api

func (*Scene) Recall

func (s *Scene) Recall(id int) error

Recall will recall the scene in the group identified by id

func (*Scene) RecallContext added in v1.1.0

func (s *Scene) RecallContext(ctx context.Context, id int) error

RecallContext will recall the scene in the group identified by id

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,omitempty"`
	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"`
	UniqueID         string                 `json:"uniqueid,omitempty"`
	SwVersion        string                 `json:"swversion,omitempty"`
	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 Stream added in v1.2.0

type Stream struct {
	ProxyMode string  `json:"proxymode,omitempty"`
	ProxyNode string  `json:"proxynode,omitempty"`
	ActiveRaw *bool   `json:"active,omitempty"`
	OwnerRaw  *string `json:"owner,omitempty"`
}

Stream define the stream status of a group

func (*Stream) Active added in v1.2.0

func (s *Stream) Active() bool

Active returns the stream active state, and will return false if ActiveRaw is nil

func (*Stream) Owner added in v1.2.0

func (s *Stream) Owner() string

Owner returns the stream Owner, and will return an empty string if OwnerRaw is nil

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

type Whitelist

type Whitelist struct {
	Name        string `json:"name"`
	Username    string
	CreateDate  string `json:"create date"`
	LastUseDate string `json:"last use date"`
	ClientKey   string
}

Whitelist represents a whitelist user ID in the bridge

Jump to

Keyboard shortcuts

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