hue

package module
v0.0.0-...-008c436 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 12 Imported by: 0

README

hue-go

A golang library that wraps the Philips Hue REST API (API 1.15)

The library currently supports the following Hue API endpoints:

  • Lights
  • Sensors
  • Config

The library supports auto-detection of bridges using the Locator functionality.

The library supports auto-update of bridges using the Updater functionality.

Usage

Create an instance of the hue.Bridge struct, then call InitIP() with the IP of the bridge. If there is no error, set the Username property on the instance of the hue.Bridge to an account which is authorized to access the API. To acquire a username to use, call Pair() after calling InitIP(). This will set the Username on the bridge instance with a new username. If you wish to save the username for future use, it can be accessed via the Username property on the bridge instance.. It is possible but not advisable to call Pair() on a bridge with a username already set.

Once a Username is set, the library maps function calls on a 1:1 basis with the Hue REST API. For example, Lights() calls GET /lights, SetLightState calls PUT/lights//state, etc.

The Set functions take a corresponding Arg which specifies which of the properties are to be saved by POST or PUT calls. Each PUT endpoint has a corresponding Arg type, with the collection of valid properties exposed with Getters and Setters. The supplied Arg object has the updated value of each property after calling the Set method. If any of the properties failed to set, the Errors() function returns the details of why that property was unable to be saved.

An example of this can be found in examples/hue

It is possible to automatically get initialized Bridge instances by running a copy of the hue.Locator object in it's own goroutine. The locator has 3 possible ways to locate bridges:

  • Static addresses configured prior to Run() being called by calling AddStaticAddress (max 8 currently supported).
  • UPnP on the current network
  • N-UPnP

An example of this can be found in examples/hue_locator

It is possible to automatically update each Bridge by creating an instance of the hue.Updater object, then calling Run() in a goroutine. This updater will poll the bridge once an hour to determine if there is an update available; if there is it will automatically apply the update then continue monitoring for future updates.

An example of this can be found in examples/hue_updater

TODO

  • Groups
  • Schedules
  • Scenes
  • Rules
  • Resource links

Documentation

Index

Constants

View Source
const (
	// SourceStatic means this location came via a static configuration
	SourceStatic = iota
	// SourceUPNP means this location came via a UPNP discovery mechanism.
	SourceUPNP
	// SourceNUPNP means this location came via a nUPNP discovery mechanism.
	SourceNUPNP
)
View Source
const (
	// NoUpdateAvailable represents an up-to-date bridge
	NoUpdateAvailable = 0
	// DownloadingSystemUpdate represents a bridge downloading a system update
	DownloadingSystemUpdate = 1
	// SystemUpdateAvailable represents a bridge with a system update ready to be applied
	SystemUpdateAvailable = 2
	// SystemUpdating represents a bridge that is actively updating itself
	SystemUpdating = 3
	// LastRequestFailed represents a bridge that failed to execute its previous command
	LastRequestFailed = 10
	// NetworkUnavailable represents a bridge unable to update because it lacks Internet connectivity
	NetworkUnavailable = 11
)

Variables

View Source
var (
	// ErrBridgeNotConfigured is returned if the bridge URL configured is not valid
	ErrBridgeNotConfigured = errors.New("bridge is not configured")
	// ErrInvalidManufacturer is returned if the retrieved bridge manufacturer is invalid
	ErrInvalidManufacturer = errors.New("invalid manufacturer detected")
	// ErrInvalidModel is returned if the retrieved bridge model is invalid
	ErrInvalidModel = errors.New("invalid model detected")
)
View Source
var (
	// ErrBridgeNotAvailable is returned if the specified bridge is not yet configured for access.
	ErrBridgeNotAvailable = errors.New("bridge is not yet ready")
	// ErrBridgeUpdating is returned if the specified bridge is currently being updated.
	ErrBridgeUpdating = errors.New("bridge is currently being updated")
)

Functions

This section is empty.

Types

type Bridge

type Bridge struct {

	// An empty username implies we have not yet paired with the bridge.
	Username string
	// contains filtered or unexported fields
}

Bridge represents an instance of a Hue bridge. The locator discovery process will also create one instance for each profile detected that is not already running.

func NewBridge

func NewBridge(username string) *Bridge

NewBridge creates a new instance of a Hue bridge.

func (*Bridge) CheckForUpdate

func (b *Bridge) CheckForUpdate() error

CheckForUpdate returns whether there is a software update available for the Hue bridge.

func (*Bridge) Config

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

Config returns the configuration of the bridge

func (*Bridge) CreateSensor

func (b *Bridge) CreateSensor(sensor *Sensor) error

CreateSensor adds a new sensor to the bridge.

func (*Bridge) DeleteLight

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

DeleteLight removes the specified light from the bridge.

func (*Bridge) DeleteSensor

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

DeleteSensor removes the specified sensor from the bridge.

func (*Bridge) Description

func (b *Bridge) Description() (BridgeDescription, error)

Description parses the validation XML file present on every Hue bridge. See http://www.developers.meethue.com/documentation/hue-bridge-discovery for details of the response format.

func (*Bridge) FinishUpdate

func (b *Bridge) FinishUpdate() error

FinishUpdate completes the update process

func (*Bridge) ID

func (b *Bridge) ID() string

ID returns the unique ID of the bridge

func (*Bridge) InitIP

func (b *Bridge) InitIP(bridgeIP string) error

InitIP initializes this bridge instance with the specified IP address.

func (*Bridge) InitURL

func (b *Bridge) InitURL(validateURL *url.URL) error

InitURL initializes this bridge instance with the specified discovery URL.

func (*Bridge) IsUpdating

func (b *Bridge) IsUpdating() bool

IsUpdating returns whether a bridge is in the process of updating or not.

func (*Bridge) Light

func (b *Bridge) Light(id string) (Light, error)

Light returns a single light from the bridge.

func (*Bridge) Lights

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

Lights returns the collection of lights configured on the bridge.

func (*Bridge) NewLights

func (b *Bridge) NewLights() ([]NewLight, error)

NewLights returns the collection of newly discovered lights. Only returns a value if SearchForNewLights has previously been called.

func (*Bridge) NewSensors

func (b *Bridge) NewSensors() ([]NewSensor, error)

NewSensors returns the list of newly configured sensors. This will not return anything if SearchForNewSensors has not previously been called.

func (*Bridge) Pair

func (b *Bridge) Pair(appName string, identifier string) error

Pair sets up the bridge with a new user.

func (*Bridge) SearchForNewLights

func (b *Bridge) SearchForNewLights() error

SearchForNewLights begins the process of locating new lights on the bridge.

func (*Bridge) SearchForNewSensors

func (b *Bridge) SearchForNewSensors() error

SearchForNewSensors attempts to discover new sensors added to the bridge.

func (*Bridge) Sensor

func (b *Bridge) Sensor(id string) (Sensor, error)

Sensor returns the specified sensor.

func (*Bridge) Sensors

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

Sensors returns the list of sensors available on the bridge.

func (*Bridge) SetConfig

func (b *Bridge) SetConfig(args *ConfigArg) error

SetConfig applies the specified config options to the bridge.

func (*Bridge) SetLight

func (b *Bridge) SetLight(id string, args *LightArg) error

SetLight updates the specified light with the configuration supplied.

func (*Bridge) SetLightState

func (b *Bridge) SetLightState(id string, args *LightStateArg) error

SetLightState sets the specified light with the supplied light state.

func (*Bridge) SetSensor

func (b *Bridge) SetSensor(id string, args *SensorArg) error

SetSensor updates the configuration of the specified sensor.

func (*Bridge) SetSensorConfig

func (b *Bridge) SetSensorConfig(id string, args *SensorConfigArg) error

SetSensorConfig updates the configuration a sensor.

func (*Bridge) SetSensorState

func (b *Bridge) SetSensorState(id string, args *SensorStateArg) error

SetSensorState updates the state of the specified sensor.

func (*Bridge) StartUpdate

func (b *Bridge) StartUpdate() error

StartUpdate kicks off the update process for the Hue bridge.

type BridgeDescription

type BridgeDescription struct {
	URLBase string `xml:"URLBase"`
	Device  Device `xml:"device"`
}

BridgeDescription contains the device information and the URL base which all subsequent calls should be made against.

type Config

type Config struct {
	Name string `json:"name"`
	ID   string `json:"bridgeid"`

	SwVersion    string `json:"swversion"`
	APIVersion   string `json:"apiversion"`
	ModelVersion string `json:"modelid"`

	LinkButton     bool   `json:"linkbutton"`
	IPAddress      string `json:"ipaddress"`
	MACAddress     string `json:"mac"`
	SubnetMask     string `json:"netmask"`
	GatewayAddress string `json:"gateway"`

	IsDhcpAcquired bool `json:"dhcp"`
	PortalServices bool `json:"portalservices"`

	ZigbeeChannel int32 `json:"zigbeechannel"`

	Timezone string `json:"timezone"`

	SwUpdate struct {
		CheckForUpdates bool   `json:"checkforupdates"`
		UpdateDetails   string `json:"url"`
		UpdateSummary   string `json:"text"`
		NotifyUser      bool   `json:"notify"`
		State           int32  `json:"updateState"`

		DeviceTypes struct {
			Bridge  bool     `json:"bridge"`
			Lights  []string `json:"lights"`
			Sensors []string `json:"sensors"`
		} `json:"devicetypes"`
	} `json:"swupdate"`

	PortalState struct {
		SignedOn      bool   `json:"signedon"`
		Incoming      bool   `json:"incoming"`
		Outgoing      bool   `json:"outgoing"`
		Communication string `json:"communication"`
	} `json:"portalstate"`
}

Config represents an instance of a Hue bridge's configuration.

type ConfigArg

type ConfigArg arg

ConfigArg represents a config property that can be set.

func (*ConfigArg) DHCP

func (c *ConfigArg) DHCP() bool

DHCP returns the DHCP option, if configured.

func (*ConfigArg) Errors

func (c *ConfigArg) Errors() map[string]ResponseError

Errors exposes any errors encountered when applying the configuration.

func (*ConfigArg) Name

func (c *ConfigArg) Name() string

Name returns the name option, if configured.

func (*ConfigArg) ProxyAddress

func (c *ConfigArg) ProxyAddress() string

ProxyAddress returns the proxy address option, if configured.

func (*ConfigArg) ProxyPort

func (c *ConfigArg) ProxyPort() uint16

ProxyPort returns the proxy port option, if configured.

func (*ConfigArg) Reset

func (c *ConfigArg) Reset()

Reset clears this configuration.

func (*ConfigArg) SetDHCP

func (c *ConfigArg) SetDHCP()

SetDHCP saves the specified value to be applied.

func (*ConfigArg) SetName

func (c *ConfigArg) SetName(name string)

SetName saves the specified value to be applied.

func (*ConfigArg) SetProxyAddress

func (c *ConfigArg) SetProxyAddress(address string)

SetProxyAddress saves the specified value to be applied.

func (*ConfigArg) SetProxyPort

func (c *ConfigArg) SetProxyPort(port uint16)

SetProxyPort saves the specified value to be applied.

func (*ConfigArg) SetStaticAddress

func (c *ConfigArg) SetStaticAddress(addr string, netmask string, gateway string)

SetStaticAddress saves the specified value to be applied.

func (c *ConfigArg) SetTouchLink()

SetTouchLink saves the specified value to be applied.

func (*ConfigArg) StaticAddress

func (c *ConfigArg) StaticAddress() (string, string, string)

StaticAddress returns the static address option, if configured.

type Device

type Device struct {
	DeviceType       string `xml:"deviceType"`
	FriendlyName     string `xml:"friendlyName"`
	Manufacturer     string `xml:"manufacturer"`
	ManufacturerURL  string `xml:"manufacturerURL"`
	ModelDescription string `xml:"modelDescription"`
	ModelName        string `xml:"modelName"`
	ModelNumber      string `xml:"modelNumber"`
	ModelURL         string `xml:"modelURL"`
	SerialNumber     string `xml:"serialNumber"`
	UDN              string `xml:"UDN"`
	PresentationURL  string `xml:"presentationURL"`
	Icons            []Icon `xml:"iconList>icon"`
}

Device contains the details of the bridge itself. These are all read-only properties.

type HSB

type HSB struct {
	Hue        uint16
	Saturation uint8
	Brightness uint8
}

HSB is a colour represented using the hue/saturation/value representation of the RGB colour model.

type Icon

type Icon struct {
	MimeType string `xml:"mimetype"`
	Height   int    `xml:"height"`
	Width    int    `xml:"width"`
	Depth    int    `xml:"depth"`
	FileName string `xml:"url"`
}

Icon contains the details of an icon hosted on the bridge.

type Light

type Light struct {
	ID               string
	Name             string `json:"name"`
	Model            string `json:"type"`
	ModelID          string `json:"modelid"`
	ManufacturerName string `json:"manufacturername"`
	UniqueID         string `json:"uniqueid"`
	SwVersion        string `json:"swversion"`

	State LightState `json:"state"`
}

Light represents a single light device.

type LightArg

type LightArg arg

LightArg represents a configuration argument that can be made to a light.

func (*LightArg) Errors

func (l *LightArg) Errors() map[string]ResponseError

Errors returns any errors encountered when applying the specified configuration.

func (*LightArg) Name

func (l *LightArg) Name() string

Name returns the name option, if set.

func (*LightArg) Reset

func (l *LightArg) Reset()

Reset clears any set configuration options,

func (*LightArg) SetName

func (l *LightArg) SetName(name string)

SetName saves the specified value to be applied.

type LightState

type LightState struct {
	On               bool       `json:"on"`
	Brightness       uint8      `json:"bri"`
	Hue              uint16     `json:"hue"`
	Saturation       uint8      `json:"sat"`
	XY               [2]float64 `json:"xy"`
	ColorTemperature uint16     `json:"ct"`
	RGB              RGB
	Alert            string `json:"alert"`
	Effect           string `json:"effect"`
	ColorMode        string `json:"colormode"`
	Reachable        bool   `json:"reachable"`
}

LightState represents the state of a single light.

type LightStateArg

type LightStateArg arg

LightStateArg represents a state setting that can be applied to a light.

func (*LightStateArg) Alert

func (l *LightStateArg) Alert() string

Alert returns the alert value, if configured.

func (*LightStateArg) Brightness

func (l *LightStateArg) Brightness() uint8

Brightness returns the brightness value, if configured.

func (*LightStateArg) ColourTemperature

func (l *LightStateArg) ColourTemperature() uint16

ColourTemperature returns the colour temperature value, if configured.

func (*LightStateArg) Effect

func (l *LightStateArg) Effect() string

Effect returns the effect, if configured.

func (*LightStateArg) Errors

func (l *LightStateArg) Errors() map[string]ResponseError

Errors returns any errors encountered when applying the specified setting changes.

func (*LightStateArg) Hue

func (l *LightStateArg) Hue() uint16

Hue returns the hue value, if configured.

func (*LightStateArg) IsOn

func (l *LightStateArg) IsOn() bool

IsOn returns the 'is on' value, if configured.

func (*LightStateArg) RGB

func (l *LightStateArg) RGB(lightModel string) RGB

RGB returns the RGB value, if configured.

func (*LightStateArg) Reset

func (l *LightStateArg) Reset()

Reset clears anything set.

func (*LightStateArg) Saturation

func (l *LightStateArg) Saturation() uint8

Saturation returns the saturation value, if configured.

func (*LightStateArg) SetAlert

func (l *LightStateArg) SetAlert(alert string)

SetAlert saves the specified value to be applied.

func (*LightStateArg) SetBrightness

func (l *LightStateArg) SetBrightness(brightness uint8)

SetBrightness saves the specified value to be applied.

func (*LightStateArg) SetColourTemperature

func (l *LightStateArg) SetColourTemperature(ct uint16)

SetColourTemperature saves the specified value to be applied.

func (*LightStateArg) SetEffect

func (l *LightStateArg) SetEffect(effect string)

SetEffect saves the specified value to be applied.

func (*LightStateArg) SetHue

func (l *LightStateArg) SetHue(hue uint16)

SetHue saves the specified value to be applied.

func (*LightStateArg) SetIsOn

func (l *LightStateArg) SetIsOn(isOn bool)

SetIsOn saves the specified value to be applied.

func (*LightStateArg) SetRGB

func (l *LightStateArg) SetRGB(rgb RGB, lightModel string)

SetRGB saves the specified value to be applied.

func (*LightStateArg) SetSaturation

func (l *LightStateArg) SetSaturation(saturation uint8)

SetSaturation saves the specified value to be applied.

func (*LightStateArg) SetTransitionTime

func (l *LightStateArg) SetTransitionTime(tt uint16)

SetTransitionTime saves the specified value to be applied.

func (*LightStateArg) SetXY

func (l *LightStateArg) SetXY(xy XY)

SetXY saves the specified value to be applied.

func (*LightStateArg) TransitionTime

func (l *LightStateArg) TransitionTime() uint16

TransitionTime returns the transition time, if configured.

func (*LightStateArg) XY

func (l *LightStateArg) XY() XY

XY returns the XY value, if configured.

type Locator

type Locator struct {
	// contains filtered or unexported fields
}

Locator is an instance of the Hue auto-discovery runner.

func NewLocator

func NewLocator() *Locator

NewLocator creates a new instance of the locator.

func (*Locator) AddStaticAddress

func (d *Locator) AddStaticAddress(addr string)

AddStaticAddress inserts a static Hue address into the location detection algorithm.

func (*Locator) Run

func (d *Locator) Run(results chan Bridge)

Run begins running an instance of the Hue locator. Detected bridges will be passed along the supplied channel.

type NewLight

type NewLight struct {
	ID   string
	Name string `json:"name"`
}

NewLight represents a single, un-configured light.

type NewSensor

type NewSensor struct {
	ID   string
	Name string `json:"name"`
}

NewSensor represents an instance of a newly configured sensor instance paired to a Hue bridge.

type RGB

type RGB struct {
	Red   uint8
	Green uint8
	Blue  uint8
}

RGB is a colour represented using the red/green/blue colour model.

func (*RGB) FromCT

func (c *RGB) FromCT(from uint16)

FromCT converts the specified CT value into the RGB colour space. This algorithm is adapted from the example at http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/

func (*RGB) FromHSB

func (c *RGB) FromHSB(from HSB)

FromHSB converts the specified HSB value into the RGB colour space. This algorithm is adapted from the code at http://www.docjar.com/html/api/java/awt/Color.java.html

func (*RGB) FromXY

func (c *RGB) FromXY(from XY, model string)

FromXY converts the specified XY value into the RGB colour space. The supplied light model is used to adjust the input value accordingly. This algorithm is adapted from the examples at http://www.developers.meethue.com/documentation/color-conversions-rgb-xy

type ResponseError

type ResponseError struct {
	Type        int    `json:"type"`
	Description string `json:"description"`
	Address     string `json:"address"`
}

ResponseError is the error message returned if the given entry is invalid. The address refers to the component which failed to change; the Type maps to errorTypes above.

type Sensor

type Sensor struct {
	ID               string
	Name             string `json:"name"`
	Type             string `json:"type"`
	ModelID          string `json:"modelid"`
	ManufacturerName string `json:"manufacturername"`
	ProductID        string `json:"productid"`
	UniqueID         string `json:"uniqueid"`
	SwVersion        string `json:"swversion"`

	Sensitivity    int32 `json:"sensitivity"`
	SensitivityMax int32 `json:"sensitivitymax"`

	Config SensorConfig `json:"config"`

	State SensorState `json:"state"`
}

Sensor represents a single sensor instance on a Hue bridge.

type SensorArg

type SensorArg arg

SensorArg is an argument to configure a sensor.

func (*SensorArg) Errors

func (s *SensorArg) Errors() map[string]ResponseError

Errors exposes any errors encountered when applying the configuration.

func (*SensorArg) Name

func (s *SensorArg) Name() string

Name returns the name option, if set.

func (*SensorArg) Reset

func (s *SensorArg) Reset()

Reset clears this configuration.

func (*SensorArg) SetName

func (s *SensorArg) SetName(name string)

SetName saves the specified value to be applied.

type SensorConfig

type SensorConfig struct {
	On        bool `json:"on"`
	Reachable bool `json:"reachable"`

	Battery  uint8    `json:"battery"`
	Alert    string   `json:"alert"`
	UserTest bool     `json:"usertest"`
	URL      *url.URL `json:"url"`

	Pending       []string `json:"pending"`
	LedIndication bool     `json:"ledindication"`

	Latitude   string `json:"lat"`
	Longitude  string `json:"long"`
	Configured bool   `json:"configured"`

	SunriseOffset int8 `json:"sunriseoffset"`
	SunsetOffset  int8 `json:"sunsetoffset"`

	ThresholdDark   uint16 `json:"tholddark"`
	ThresholdOffset uint16 `json:"tholdoffset"`
}

SensorConfig represents the configuration of a sensor.

type SensorConfigArg

type SensorConfigArg arg

SensorConfigArg represents a set of configuration changes to be applied to a sensor.

func (*SensorConfigArg) Alert

func (s *SensorConfigArg) Alert() string

Alert returns the specified option, if set.

func (*SensorConfigArg) BatteryLevel

func (s *SensorConfigArg) BatteryLevel() uint8

BatteryLevel returns the specified option, if set.

func (*SensorConfigArg) DarkThreshold

func (s *SensorConfigArg) DarkThreshold() uint16

DarkThreshold returns the specified option, if set.

func (*SensorConfigArg) DarkThresholdOffset

func (s *SensorConfigArg) DarkThresholdOffset() uint16

DarkThresholdOffset returns the specified option, if set.

func (*SensorConfigArg) Errors

func (s *SensorConfigArg) Errors() map[string]ResponseError

Errors exposes any errors encountered when applying the configuration.

func (*SensorConfigArg) IsOn

func (s *SensorConfigArg) IsOn() bool

IsOn returns the name option, if set.

func (*SensorConfigArg) IsReachable

func (s *SensorConfigArg) IsReachable() bool

IsReachable returns the is reachable option, if set.

func (*SensorConfigArg) Latitude

func (s *SensorConfigArg) Latitude() string

Latitude returns the specified option, if set.

func (*SensorConfigArg) Longitude

func (s *SensorConfigArg) Longitude() string

Longitude returns the specified option, if set.

func (*SensorConfigArg) Reset

func (s *SensorConfigArg) Reset()

Reset clears this configuration.

func (*SensorConfigArg) SetAlert

func (s *SensorConfigArg) SetAlert(alert string)

SetAlert sets the specified option to be applied.

func (*SensorConfigArg) SetBatteryLevel

func (s *SensorConfigArg) SetBatteryLevel(level uint8)

SetBatteryLevel sets the specified option to be applied.

func (*SensorConfigArg) SetDarkThreshold

func (s *SensorConfigArg) SetDarkThreshold(threshold uint16)

SetDarkThreshold sets the specified option to be applied.

func (*SensorConfigArg) SetDarkThresholdOffset

func (s *SensorConfigArg) SetDarkThresholdOffset(offset uint16)

SetDarkThresholdOffset sets the specified option to be applied.

func (*SensorConfigArg) SetIsOn

func (s *SensorConfigArg) SetIsOn(isOn bool)

SetIsOn sets the sensor to be on.

func (*SensorConfigArg) SetIsReachable

func (s *SensorConfigArg) SetIsReachable(isReachable bool)

SetIsReachable sets the specified option to be applied.

func (*SensorConfigArg) SetLatitude

func (s *SensorConfigArg) SetLatitude(latitude string)

SetLatitude sets the specified option to be applied.

func (*SensorConfigArg) SetLongitude

func (s *SensorConfigArg) SetLongitude(longitude string)

SetLongitude sets the specified option to be applied.

func (*SensorConfigArg) SetSunriseOffset

func (s *SensorConfigArg) SetSunriseOffset(offset int8)

SetSunriseOffset sets the specified option to be applied.

func (*SensorConfigArg) SetSunsetOffset

func (s *SensorConfigArg) SetSunsetOffset(offset int8)

SetSunsetOffset sets the specified option to be applied.

func (*SensorConfigArg) SetURL

func (s *SensorConfigArg) SetURL(url string)

SetURL sets the specified option to be applied.

func (*SensorConfigArg) SunriseOffset

func (s *SensorConfigArg) SunriseOffset() int8

SunriseOffset returns the specified option, if set.

func (*SensorConfigArg) SunsetOffset

func (s *SensorConfigArg) SunsetOffset() int8

SunsetOffset returns the specified option, if set.

func (*SensorConfigArg) URL

func (s *SensorConfigArg) URL() string

URL returns the specified option, if set.

type SensorState

type SensorState struct {
	LastUpdated string `json:"lastupdated"`

	ButtonEvent int32 `json:"buttonevent"`

	Presence    bool  `json:"presence"`
	Temperature int32 `json:"temperature"`
	Humidity    int32 `json:"humidity"`

	Daylight bool `json:"daylight"`

	LightLevel uint16 `json:"lightlevel"`
	Dark       bool   `json:"dark"`

	Flag bool `json:"flag"`

	Status int32 `json:"status"`
}

SensorState represents the state of a sensor.

type SensorStateArg

type SensorStateArg arg

SensorStateArg is a set of options to configure a sensor state.

func (*SensorStateArg) Errors

func (s *SensorStateArg) Errors() map[string]ResponseError

Errors exposes any errors encountered when applying the configuration.

func (*SensorStateArg) Flag

func (s *SensorStateArg) Flag() bool

Flag returns the specified option, if set.

func (*SensorStateArg) Humidity

func (s *SensorStateArg) Humidity() int32

Humidity returns the specified option, if set.

func (*SensorStateArg) IsOpen

func (s *SensorStateArg) IsOpen() bool

IsOpen returns the specified option, if set.

func (*SensorStateArg) IsPresent

func (s *SensorStateArg) IsPresent() bool

IsPresent returns the specified option, if set.

func (*SensorStateArg) LightLevel

func (s *SensorStateArg) LightLevel() uint16

LightLevel returns the specified option, if set.

func (*SensorStateArg) Reset

func (s *SensorStateArg) Reset()

Reset clears any set configuration options,

func (*SensorStateArg) SetFlag

func (s *SensorStateArg) SetFlag(flag bool)

SetFlag sets the specified option to be applied.

func (*SensorStateArg) SetHumidity

func (s *SensorStateArg) SetHumidity(humidity int32)

SetHumidity sets the specified option to be applied.

func (*SensorStateArg) SetIsOpen

func (s *SensorStateArg) SetIsOpen(isOpen bool)

SetIsOpen sets the specified option to be applied.

func (*SensorStateArg) SetIsPresent

func (s *SensorStateArg) SetIsPresent(isPresent bool)

SetIsPresent sets the specified option to be applied.

func (*SensorStateArg) SetLightLevel

func (s *SensorStateArg) SetLightLevel(lightLevel uint16)

SetLightLevel sets the specified option to be applied.

func (*SensorStateArg) SetStatus

func (s *SensorStateArg) SetStatus(status int32)

SetStatus sets the specified option to be applied.

func (*SensorStateArg) SetTemperature

func (s *SensorStateArg) SetTemperature(temperature int32)

SetTemperature sets the specified option to be applied.

func (*SensorStateArg) Status

func (s *SensorStateArg) Status() int32

Status returns the specified option, if set.

func (*SensorStateArg) Temperature

func (s *SensorStateArg) Temperature() int32

Temperature returns the specified option, if set.

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Updater is an instance of a Hue bridge updater.

func NewUpdater

func NewUpdater(b *Bridge) Updater

NewUpdater creates a new bridge updater from the specified Hue bridge.

func (*Updater) Run

func (u *Updater) Run(results chan string, quit chan interface{})

Run begins the process of monitoring a bridge for updates then applying them.

func (*Updater) State

func (u *Updater) State() int32

State exposes the current state of the updater.

type XY

type XY struct {
	X float64
	Y float64
}

XY is a colour represented using the CIE colour space.

func (*XY) FromRGB

func (c *XY) FromRGB(from RGB, model string)

FromRGB converts the specified RGB value into the CIE colour space. The supplied light model is used to adjust the input value accordingly. This algorithm is adapted from the examples at http://www.developers.meethue.com/documentation/color-conversions-rgb-xy

Directories

Path Synopsis
cmd
hue

Jump to

Keyboard shortcuts

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