hue

package
v0.0.0-...-bc49051 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ColorTransparent is a fully transparent color.
	ColorTransparent = Color{}

	// ColorWhite is white.
	ColorWhite = Color{R: 255, G: 255, B: 255, A: 255}

	// ColorBlack is black.
	ColorBlack = Color{R: 0, G: 0, B: 0, A: 255}

	// ColorRed is red.
	ColorRed = Color{R: 255, G: 0, B: 0, A: 255}

	// ColorGreen is green.
	ColorGreen = Color{R: 0, G: 255, B: 0, A: 255}

	// ColorBlue is blue.
	ColorBlue = Color{R: 0, G: 0, B: 255, A: 255}
)
View Source
var GamutA = []XYPoint{
	{0.704, 0.296},
	{0.2151, 0.7106},
	{0.138, 0.08},
}

GamutA is a gamut profile.

View Source
var GamutB = []XYPoint{
	{0.675, 0.322},
	{0.4091, 0.518},
	{0.167, 0.04},
}

GamutB is a gamut profile.

View Source
var GamutC = []XYPoint{
	{0.692, 0.308},
	{0.17, 0.7},
	{0.153, 0.048},
}

GamutC is a gamut profile.

Functions

func CrossProduct

func CrossProduct(p1, p2 XYPoint) float64

CrossProduct returns the cross product of two given points.

func GamutContains

func GamutContains(gamut []XYPoint, p XYPoint) bool

GamutContains returns if a given point exists in a given gamut.

func GetDistance

func GetDistance(one, two XYPoint) float64

GetDistance gets the distance between two points.

func WithVerbose

func WithVerbose(ctx context.Context, verbose bool) context.Context

WithVerbose sets the verbose flag on the context.

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 {
	ID       string `json:"id,omitempty"`
	Addr     string `json:"internalipaddress,omitempty"`
	Username string `json:"user,omitempty"`
}

Bridge exposes a hardware bridge through a struct.

func DiscoverAll

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

DiscoverAll performs a discovery on the network looking for bridges using https://www.meethue.com/api/nupnp service and returns a list of Bridges.

func DiscoverFirst

func DiscoverFirst(ctx context.Context) (b Bridge, ok bool, err error)

DiscoverFirst performs a discovery on the network looking for bridges using https://www.meethue.com/api/nupnp service.

func New

func New(addr, username 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(ctx context.Context, g Group) (*Response, error)

CreateGroup creates one new group with attributes defined by g

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

CreateResourcelink creates one new resourcelink on the bridge

func (Bridge) CreateRule

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

CreateRule creates one rule with attribues defined in s

func (Bridge) CreateScene

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

CreateScene creates one new scene with its attributes defined in s

func (Bridge) CreateSchedule

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

CreateSchedule creates one schedule and sets its attributes defined in s

func (Bridge) CreateSensor

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

CreateSensor creates one new sensor

func (Bridge) CreateUser

func (b Bridge) CreateUser(ctx context.Context, 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.

func (Bridge) CreateUserWithClientKey

func (b Bridge) CreateUserWithClientKey(ctx context.Context, 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) DeleteGroup

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

DeleteGroup deletes one group with the id of i

func (Bridge) DeleteLight

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

DeleteLight deletes one lights from the bridge

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

DeleteResourcelink deletes one resourcelink with the id of i

func (Bridge) DeleteRule

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

DeleteRule deletes one rule from the bridge

func (Bridge) DeleteScene

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

DeleteScene deletes one scene from the bridge

func (Bridge) DeleteSchedule

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

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

func (Bridge) DeleteSensor

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

DeleteSensor deletes one sensor from the bridge

func (Bridge) DeleteUser

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

DeleteUser removes a whitelist item from whitelists on the bridge

func (Bridge) FindLights

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

FindLights 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(ctx context.Context) (*Response, error)

FindSensors starts a search for new sensors.

func (Bridge) GetCapabilities

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

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

func (Bridge) GetConfig

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

GetConfig returns the bridge configuration

func (Bridge) GetFullState

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

GetFullState returns the entire bridge configuration.

func (Bridge) GetGroup

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

GetGroup returns one group known to the bridge by its id

func (Bridge) GetGroups

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

GetGroups returns all groups known to the bridge

func (Bridge) GetLight

func (b Bridge) GetLight(ctx context.Context, id int) (*Light, error)

GetLight returns one light with the id of i

func (Bridge) GetLights

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

GetLights returns all lights known to the bridge

func (Bridge) GetNewLights

func (b Bridge) GetNewLights(ctx context.Context) (*Lights, error)

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

func (Bridge) GetNewSensors

func (b Bridge) GetNewSensors(ctx context.Context) (*Sensors, error)

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

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

GetResourcelink returns one resourcelink by its id defined by i

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

GetResourcelinks returns all resourcelinks known to the bridge

func (Bridge) GetRule

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

GetRule returns one rule by its id of i

func (Bridge) GetRules

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

GetRules returns all rules known to the bridge

func (Bridge) GetScene

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

GetScene returns one scene by its id of i

func (Bridge) GetScenes

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

GetScenes returns all scenes known to the bridge

func (Bridge) GetSchedule

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

GetSchedule returns one schedule by id defined in i

func (Bridge) GetSchedules

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

GetSchedules returns all schedules known to the bridge

func (Bridge) GetSensor

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

GetSensor returns one sensor by its id of i

func (Bridge) GetSensors

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

GetSensors returns all sensors known to the bridge

func (Bridge) GetUsers

func (b Bridge) GetUsers(ctx context.Context) ([]Whitelist, error)

GetUsers returns a list of whitelists from the bridge

func (Bridge) IdentifyLight

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

IdentifyLight allows identifying a light

func (Bridge) Login

func (b Bridge) Login(username string) Bridge

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

func (Bridge) RecallScene

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

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

func (Bridge) SetGroupState

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

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

func (Bridge) SetLightState

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

SetLightState allows for controlling one light's state

func (Bridge) SetSceneLightState

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

SetSceneLightState allows for setting the state of a light in a scene.

func (Bridge) UpdateConfig

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

UpdateConfig updates the bridge configuration with c

func (Bridge) UpdateGroup

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

UpdateGroup updates one group known to the bridge

func (Bridge) UpdateLight

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

UpdateLight updates one light's attributes and state properties

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

UpdateResourcelink updates one resourcelink with attributes defined by resourcelink

func (Bridge) UpdateRule

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

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

func (Bridge) UpdateScene

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

UpdateScene updates one scene and its attributes by id of i

func (Bridge) UpdateSchedule

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

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

func (Bridge) UpdateSensor

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

UpdateSensor updates one sensor by its id and attributes by sensor

func (Bridge) UpdateSensorConfig

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

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

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 Color

type Color struct {
	R, G, B, A uint8
}

Color is our internal color type because color.Color is bad.

Each "channel" (i.e. R, G, B, or A) are 0-255 values.

func ColorFromHex

func ColorFromHex(hex string) Color

ColorFromHex returns a color from a css hex code.

An example might be #efefef which would yield a color with R=239, G=239, B=239, A=255.

func (Color) AverageWith

func (c Color) AverageWith(other Color) Color

AverageWith averages two colors.

func (Color) Equals

func (c Color) Equals(other Color) bool

Equals returns true if the color equals another.

func (Color) IsTransparent

func (c Color) IsTransparent() bool

IsTransparent returns if the colors alpha channel is zero.

func (Color) IsZero

func (c Color) IsZero() bool

IsZero returns if the color has been set or not.

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint32)

RGBA returns the color as a pre-alpha mixed color set.

It also returns the alpha channel, though effectively the RGB values are modified by it already.

func (Color) String

func (c Color) String() string

String returns a css string representation of the color.

func (Color) WithAlpha

func (c Color) WithAlpha(a uint8) Color

WithAlpha returns a copy of the color with a given alpha.

func (Color) XY

func (c Color) XY(gamut []XYPoint) []float32

XY converts a given RGB color to the xy color in a given gamut.

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 {
	ID int `json:"id,omitempty"`

	Class      string               `json:"class,omitempty"`
	GroupState GroupState           `json:"state,omitempty"`
	Lights     []string             `json:"lights,omitempty"`
	Locations  map[string][]float64 `json:"locations,omitempty"`
	Name       string               `json:"name,omitempty"`
	Recycle    bool                 `json:"recycle,omitempty"`
	State      LightState           `json:"action,omitempty"`
	Stream     Stream               `json:"stream,omitempty"`
	Type       string               `json:"type,omitempty"`
	// contains filtered or unexported fields
}

Group represents a bridge group https://developers.meethue.com/documentation/groups-api

func (*Group) AlertContext

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) Brightness

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

Brightness sets the light brightness state property

func (*Group) Color

func (g *Group) Color(ctx context.Context, c Color) error

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

func (*Group) ColorTemperature

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

ColorTemperature sets the light color temperature state property

func (*Group) ColorTransition

func (g *Group) ColorTransition(ctx context.Context, c Color, transition time.Duration) error

ColorTransition sets the light color as RGB (will be converted to xy) with a given transition time.

func (*Group) DisableStreamingContext

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

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

func (*Group) EffectContext

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) EnableStreamingContext

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(ctx context.Context, new uint16) error

Hue 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(ctx context.Context) error

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

func (*Group) On

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

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

func (*Group) Rename

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

Rename sets the name property of the group

func (*Group) Saturation

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

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

func (*Group) Scene

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

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

func (*Group) SetState

func (g *Group) SetState(ctx context.Context, s LightState) error

SetState sets the state of the group to s.

func (*Group) TransitionTimeContext

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(ctx context.Context, new []float32) error

Xy 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 {
	ID               int               `json:"id,omitempty"`
	Config           LightConfig       `json:"config,omitempty"`
	Capabilities     LightCapabilities `json:"capabilities,omitempty"`
	ManufacturerName string            `json:"manufacturername,omitempty"`
	ModelID          string            `json:"modelid,omitempty"`
	Name             string            `json:"name,omitempty"`
	ProductName      string            `json:"productname,omitempty"`
	State            LightState        `json:"state,omitempty"`
	SwConfigID       string            `json:"swconfigid,omitempty"`
	SwVersion        string            `json:"swversion,omitempty"`
	Type             string            `json:"type,omitempty"`
	UniqueID         string            `json:"uniqueid,omitempty"`
	// contains filtered or unexported fields
}

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

func (*Light) Alert

func (l *Light) Alert(ctx context.Context, 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) Brightness

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

Brightness sets the light brightness state property

func (*Light) Color

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

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

func (*Light) ColorTemperature

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

ColorTemperature sets the light color temperature state property

func (*Light) Effect

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

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

func (*Light) Hue

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

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

Use the color helpers to create a more user-friendly input.

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(ctx context.Context) error

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

func (*Light) On

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

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

func (*Light) Rename

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

Rename sets the name property of the light

func (*Light) Saturation

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

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

func (*Light) SetState

func (l *Light) SetState(ctx context.Context, s LightState) error

SetState sets the state of the light to s.

func (Light) String

func (l Light) String() string

String returns a new string form of the light.

func (*Light) TransitionTime

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

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

func (*Light) Xy

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

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

type LightCapabilities

type LightCapabilities struct {
	Certified bool                       `json:"certified,omitempty"`
	Control   LightCapabilitiesControl   `json:"control,omitempty"`
	Streaming LightCapabilitiesStreaming `json:"streaming,omitempty"`
}

LightCapabilities holds light capabilities.

type LightCapabilitiesControl

type LightCapabilitiesControl struct {
	MinDimLevel      int         `json:"mindimlevel,omitempty"`
	MaxLumen         int         `json:"maxlumen,omitempty"`
	ColorGamutType   string      `json:"colorgamuttype,omitempty"`
	ColorGamut       [][]float64 `json:"colorgamut,omitempty"`
	ColorTemperature MinMaxInt   `json:"ct,omitempty"`
}

LightCapabilitiesControl holds light capabilities for control.

type LightCapabilitiesStreaming

type LightCapabilitiesStreaming struct {
	Renderer bool `json:"renderer,omitempty"`
	Proxy    bool `json:"proxy,omitempty"`
}

LightCapabilitiesStreaming holds the light streaming capabilities.

type LightConfig

type LightConfig struct {
	Archetype string `json:"archetype,omitempty"`
	Function  string `json:"function,omitempty"`
	Direction string `json:"direction,omitempty"`
}

LightConfig holds light config options.

type LightState

type LightState struct {
	Alert          string    `json:"alert,omitempty"`
	Bri            uint8     `json:"bri,omitempty"`
	BriInc         int       `json:"bri_inc,omitempty"`
	ColorMode      string    `json:"colormode,omitempty"`
	Ct             uint16    `json:"ct,omitempty"`
	CtInc          int       `json:"ct_inc,omitempty"`
	Effect         string    `json:"effect,omitempty"`
	Hue            uint16    `json:"hue,omitempty"`
	HueInc         int       `json:"hue_inc,omitempty"`
	On             bool      `json:"on"`
	Reachable      bool      `json:"reachable,omitempty"`
	Sat            uint8     `json:"sat,omitempty"`
	SatInc         int       `json:"sat_inc,omitempty"`
	Scene          string    `json:"scene,omitempty"`
	TransitionTime uint16    `json:"transitiontime,omitempty"`
	Xy             []float32 `json:"xy,omitempty"`
	XyInc          int       `json:"xy_inc,omitempty"`
}

LightState defines the attributes and properties of a light

type Lights

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

Lights 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 MinMaxInt

type MinMaxInt struct {
	Min int `json:"min,omitempty"`
	Max int `json:"max,omitempty"`
}

MinMaxInt represents a minimum and a maximum integer.

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     []*RuleCondition `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 RuleCondition

type RuleCondition struct {
	Address  string `json:"address,omitempty"`
	Operator string `json:"operator,omitempty"`
	Value    string `json:"value,omitempty"`
}

RuleCondition defines the condition of a rule

type Scene

type Scene struct {
	ID              string             `json:"-"`
	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]LightState `json:"lightstates,omitempty"`
	TransitionTime  uint16             `json:"transitiontime,omitempty"`
	// contains filtered or unexported fields
}

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

func (*Scene) Recall

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

Recall will recall the scene in the group identified by id

type Schedule

type Schedule struct {
	Name        string           `json:"name"`
	Description string           `json:"description"`
	Command     *ScheduleCommand `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 ScheduleCommand

type ScheduleCommand struct {
	Address string      `json:"address"`
	Method  string      `json:"method"`
	Body    interface{} `json:"body"`
}

ScheduleCommand defines the request to be made when the schedule occurs

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 Sensors

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

Sensors 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 Stream

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

func (s *Stream) Active() bool

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

func (*Stream) Owner

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

type XYPoint

type XYPoint struct{ X, Y float64 }

XYPoint is a struct of two float64 points.

func GamutPoint

func GamutPoint(gamut []XYPoint, p XYPoint) XYPoint

GamutPoint returns the closest point in a gamut to a given point.

func GetClosestPointToLine

func GetClosestPointToLine(a, b, p XYPoint) XYPoint

GetClosestPointToLine returns the closest point to a given line.

func GetGamutForModelID

func GetGamutForModelID(modelID string) []XYPoint

GetGamutForModelID returns the gamut for a given model id.

Jump to

Keyboard shortcuts

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