hue

package module
v0.0.0-...-ea1b468 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2015 License: BSD-2-Clause Imports: 5 Imported by: 2

README

go.hue

go.hue is a Philips Hue package for the Go programming language.

Warning: This package is discontinued. Please use one of the other Hue packages: http://go-search.org/search?q=hue

Installation

Download and install this package with go get github.com/GeertJohan/go.hue

Usage

An example is located in the huexample folder. For package documentation visit godoc.org/github.com/GeertJohan/go.hue

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	IP       string
	Username string
}

Bridge represents a Hue Bridge

func NewBridge

func NewBridge(IP string) *Bridge

NewBridge creates a new Bridge instance with given IP address

func (*Bridge) CreateNewUser

func (b *Bridge) CreateNewUser(deviceType string, newUsername string) (string, error)

CreateNewUser creates a new user at the bridge. The end-user must press the link button in advance to prove physical access. When the second argument (newUsername) is left emtpy, the bridge will provide a username. CreateNewUser does not update the Bridge instance with the username. This must be done manually.

func (*Bridge) FetchConfiguration

func (b *Bridge) FetchConfiguration() (*BridgeConfiguration, error)

FetchConfiguration fetches the configuration data and returns it as *BridgeConfiguration

func (*Bridge) Lights

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

Lights returns all lights known by the bridge.

func (*Bridge) Name

func (b *Bridge) Name() (string, error)

Name returns the Name of the Bridge as string

func (*Bridge) Search

func (b *Bridge) Search() error

Search lets the bridge start a new search for lights. The bridge will search for 1 minute and will add a maximum of 15 new lights. To add further lights, the command needs to be sent again after the search has completed. If a search is already active, it will be aborted and a new search will start.

func (*Bridge) URL

func (b *Bridge) URL() string

URL returns the basic url for api requests. It includes the bridge IP and Username

type BridgeConfiguration

type BridgeConfiguration struct {
	Proxyport uint16 `json:"proxyport"` // Port of the proxy being used by the bridge. If set to 0 then a proxy is not being used.
	Utc       *Time  `json:"utc"`       // Current time stored on the bridge.
	Name      string `json:"name"`      // length 4..16. Name of the bridge. This is also its uPnP name, so will reflect the actual uPnP name after any conflicts have been resolved.
	SwUpdate  struct {
		UpdateState int    `json:"updatestate"`
		Url         string `json:"url"`
		Text        string `json:"text"`
		Notify      bool   `json:"notify"`
	} `json:"swupdate"` // Contains information related to software updates.
	Whitelist map[string]struct {
		LastUseDate *Time  `json:"last use date"`
		CreateDate  *Time  `json:"create date"`
		Name        string `json:"name"` // DeviceType (library or executable name)
	} `json:"whitelist"` // A map of whitelisted usernames with their details as mapped value (struct).
	Swversion      string `json:"swversion"`      // Software version of the bridge.
	ProxyAddress   string `json:"proxyaddress"`   // length 0..40. IP Address of the proxy server being used. A value of “none” indicates no proxy.
	Mac            string `json:"mac"`            // MAC address of the bridge.
	LinkButton     bool   `json:"linkbutton"`     // Indicates whether the link button has been pressed within the last 30 seconds.
	IPAddress      string `json:"ipaddress"`      // IP address of the bridge.
	Netmask        string `json:"netmask"`        // Network mask of the bridge.
	Gateway        string `json:"gateway"`        // Gateway IP address of the bridge.
	DHCP           bool   `json:"dhcp"`           // Whether the IP address of the bridge is obtained with DHCP.
	PortalServices bool   `json:"portalservices"` // This indicates whether the bridge is registered to synchronize data with a portal account.
}

BridgeConfiguration holds the global configuration values for a bridge.

type BrokerDetails

type BrokerDetails struct {
	ID                string `json:"id"`
	InternalIPAddress string `json:"internalipaddress"`
	MACAddress        string `json:"macaddress"`
}

BrokerDetails represents the details of a single bridge as returned by the broker service

func DiscoverBridges

func DiscoverBridges() ([]BrokerDetails, error)

DiscoverBridges requests a list of known bridges from the Philips meethue broker service. It returns a slice of BrokerBridgeDetails or a non-nil error The list of BrokerBridgeDetails can have len 0 while error is nil. This means the request was successfull, but the broker did not return any details.

type Light

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

Light points to a specific light on a specific hue bridge

func (Light) Attributes

func (l Light) Attributes() (*LightAttributes, error)

func (Light) SetName

func (l Light) SetName(newName string) error

SetName sets the name of the light. The given name must have a length between 0 and 32 characters.

type LightAttributes

type LightAttributes struct {
	State     LightState `json:"State"`     // Details the state of the light, see the state table below for more details.
	Type      string     `json:"Type"`      // A fixed name describing the type of light e.g. “Extended color light”.
	Name      string     `json:"name"`      // (lenght 0-32) A unique, editable name given to the light.
	ModelID   string     `json:"modelid"`   // (length 6) The hardware model of the light.
	Swversion string     `json:"swversion"` // (length 8) An identifier for the software version running on the light.

}

LightAttributes holds attributes of light, it includes the State and Name.

type LightState

type LightState struct {
	On         bool   `json:"On"`  // On/Off state of the light. On=true, Off=false
	Brightness uint8  `json:"Bri"` // Brightness of the light. This is a scale from the minimum brightness the light is capable of, 0, to the maximum capable brightness, 255. Note a brightness of 0 is not off.
	Hue        uint16 `json:"Hue"` // Hue of the light. This is a wrapping value between 0 and 65535. Both 0 and 65535 are red, 25500 is green and 46920 is blue.
	Saturation uint8  `json:"sat"` // Saturation of the light. 255 is the most saturated (colored) and 0 is the least saturated (white).

	CT uint16 `json:"ct"` // The Mired Color temperature of the light. 2012 connected lights are capable of 153 (6500K) to 500 (2000K).

	Alert string `json:"alert"` // The alert effect, which is a temporary change to the bulb’s state. This can take one of the following values:

	Effect string `json:"effect"` // The dynamic effect of the light, can either be “none” or “colorloop”.

	// If set to colorloop, the light will cycle through all hues using the current brightness and saturation settings.
	ColorMode string `json:"colormode"` // (length 2) Indicates the color mode in which the light is working, this is the last command type it received. Values are “hs” for Hue and Saturation, “xy” for XY and “ct” for Color Temperature. This parameter is only present when the light supports at least one of the values.
	Reachable bool   `json:"reachable"` // Indicates if a light can be reached by the bridge. Currently always returns true, functionality will be added in a future patch.
}

type Time

type Time time.Time

Time performs proper json unarmshalling with time.Parse(..)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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