hue

package module
v0.0.0-...-14fd71e Latest Latest
Warning

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

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

README

go-hue

A typesafe, fully tested, go package for the Phillip's Hue client API.

Note: This is a work in project and NOT ready to be used in production yet. I'm hoping to have it completed by the end of September 2013 and am actively working on the project.

Please see godoc.org for a detailed API description.

For more information about the Hue API see the Hue Developer API Specification.

Packages

This contains multiple packages. See the README in each package for more details. Here is a list for you reference.

  • huetest - Stub hue.API implementation to simplify testing.
  • strand - Provides a LightStrand that maps location on a strand to a light id in hue.

Todo

  • Lights API
  • [~] Configuration API
  • Discovery API
  • [~] Documentation
  • Groups API
  • Schedules API

Usage

How to contribute

  • Fork
  • Write tests and code
  • Run go fmt
  • Submit a pull request
  • Drink a beer. Good job!

Documentation

Index

Constants

View Source
const (
	UnauthorizedUserErrorType       = 1
	InvalidJsonErrorType            = 2
	ResourceNotAvailableErrorType   = 3
	MethodNotAvailableErrorType     = 4
	MissingParameterErrorType       = 5
	ParameterNotAvailableErrorType  = 6
	InvalidParameterValueErrorType  = 7
	ParameterNotModifiableErrorType = 8
	InternalErrorType               = 901
	LinkButtonNotPressedErrorType   = 101
	DeviceIsOffErrorType            = 201
	GroupTableFullErrorType         = 301
	DeviceGroupTableFullErrorType   = 302
)
View Source
const AllLightsGroupId = "0"

The group id for all lights on a bridge

View Source
const HueModelURL = "http://www.meethue.com"

Variables

This section is empty.

Functions

func NewAPIParseError

func NewAPIParseError(expected string, actual interface{}, context string) error

func NewHTTPClient

func NewHTTPClient(addr string) *client

func NewStubClient

func NewStubClient(responseFile string) *client

Types

type API

type API interface {
	GetLights() ([]Light, error)
	GetNewLights() ([]Light, time.Time, error)
	SearchForNewLights() error
	GetLightAttributes(lightId string) (*LightAttributes, error)
	SetLightName(lightId string, name string) error
	SetLightState(lightId string, state *LightState) error
	SetGroupState(groupId string, state *LightState) error
}

type APIError

type APIError struct {
	Errors []APIErrorDetail
}

func (APIError) Error

func (e APIError) Error() string

type APIErrorDetail

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

func (APIErrorDetail) Error

func (e APIErrorDetail) Error() string

type APIParseError

type APIParseError struct {
	Expected string
	Actual   interface{}
	Context  string
}

func (*APIParseError) Error

func (e *APIParseError) Error() string

type APIResult

type APIResult struct {
	Success *APISuccessDetail `json:"success"`
	Error   *APIErrorDetail   `json:"error"`
}

type APISuccessDetail

type APISuccessDetail map[string]interface{}

type AdminAPI

type AdminAPI interface {
	GetConfiguration() (*Configuration, error)
}

type Bridge

type Bridge struct {
	UniqueId string
	// contains filtered or unexported fields
}

func FindBridges

func FindBridges() ([]*Bridge, error)

func NewBridge

func NewBridge(uniqueId, addr string) *Bridge

func NewStubBridge

func NewStubBridge(stubFilename string) (*Bridge, *stubServer)

func (*Bridge) CreateUser

func (b *Bridge) CreateUser(deviceType, username string) (*User, error)

func (*Bridge) IsValidUser

func (b *Bridge) IsValidUser(username string) (bool, error)

type Configuration

type Configuration struct {
	// Read and Write
	Name           string              `json:"name,omitempty"`
	ProxyAddress   string              `json:"proxyaddress,omitempty"`
	ProxyPort      *uint16             `json:"proxyport,omitempty"`
	IPAddress      string              `json:"ipaddress,omitempty"`
	Netmask        string              `json:"netmask,omitempty"`
	Gateway        string              `json:"gateway,omitempty"`
	DHCP           *bool               `json:"dhcp,omitempty"`
	PortalServices *bool               `json:"portalservices,omitempty"`
	LinkButton     *bool               `json:"linkbutton,omitempty"`
	SoftwareUpdate *SoftwareUpdateInfo `json:"swupdate,omitempty"`

	// Read only
	UTC             string                       `json:"utc,omitempty"`
	Whitelist       map[string]map[string]string `json:"whitelist,omitempty"`
	SoftwareVersion string                       `json:"swversion,omitempty"`
	MAC             string                       `json:"mac,omitempty"`
}

type Light

type Light struct {
	Id   string
	Name string
}

type LightAttributes

type LightAttributes struct {
	Name            string      `json:"name"`
	State           *LightState `json:"state"`
	Type            string      `json:"type"`
	ModelId         string      `json:"modelid"`
	SoftwareVersion string      `json:"swversion"`
	PointSymbol     interface{} `json:"pointsymbol"`
}

type LightState

type LightState struct {
	On             *bool     `json:"on,omitempty"`
	Brightness     *uint8    `json:"bri,omitempty"`
	Hue            *uint16   `json:"hue,omitempty"`
	Saturation     *uint8    `json:"sat,omitempty"`
	XY             []float64 `json:"xy,omitempty"`
	ColorTemp      *uint16   `json:"ct,omitempty"`
	Alert          string    `json:"alert,omitempty"`
	Effect         string    `json:"effect,omitempty"`
	TransitionTime *uint16   `json:"transitiontime,omitempty"` /* write only */
	ColorMode      string    `json:"colormode,omitempty"`      /* read only */
	Reachable      bool      `json:"reachable,omitempty"`      /* read only */
}

type SoftwareUpdateInfo

type SoftwareUpdateInfo struct {
	UpdateState *uint  `json:"updatestate,omitempty"`
	URL         string `json:"url,omitempty"`
	Text        string `json:"text,omitempty"`
	Notify      *bool  `json:"notify,omitempty"`
}

type User

type User struct {
	Bridge   *Bridge
	Username string
}

func NewStubUser

func NewStubUser(stubFilename string, username string) (*User, *stubServer)

func NewUser

func NewUser(username, bridgeId, addr string) *User

func NewUserWithBridge

func NewUserWithBridge(username string, bridge *Bridge) *User

func (*User) GetConfiguration

func (u *User) GetConfiguration() (*Configuration, error)

func (*User) GetLightAttributes

func (u *User) GetLightAttributes(lightId string) (*LightAttributes, error)

func (*User) GetLights

func (u *User) GetLights() ([]Light, error)

func (*User) GetNewLights

func (u *User) GetNewLights() ([]Light, time.Time, error)

func (*User) SearchForNewLights

func (u *User) SearchForNewLights() error

func (*User) SetGroupState

func (u *User) SetGroupState(groupId string, state *LightState) error

func (*User) SetLightName

func (u *User) SetLightName(lightId string, name string) error

func (*User) SetLightState

func (u *User) SetLightState(lightId string, state *LightState) error

Directories

Path Synopsis
Package with a Stub API that conforms to the hue.API interface for testing purposes.
Package with a Stub API that conforms to the hue.API interface for testing purposes.

Jump to

Keyboard shortcuts

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