hue

package module
v0.0.0-...-8a01e61 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: MIT Imports: 14 Imported by: 0

README

Hue 💡

Philips Hue client allows you to interact with your hue bridge easily

Installation

go get github.com/ermos/hue

Usage

Work in progress..

Contribution

Work in progress..

Documentation

Index

Constants

View Source
const (
	DebugNone  = 0
	DebugInfo  = 1
	DebugError = 2
	DebugAll   = 3
)
View Source
const (
	AlertNone       = "none"
	AlertCycle      = "select"
	AlertCycle15Sec = "lselect"
	EffectNone      = "none"
	EffectColorLoop = "colorloop"
)

Variables

This section is empty.

Functions

func Connx

func Connx(ctx context.Context, IPAddr, token string)

Types

type AvailableLight

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

type Bridge

type Bridge struct {
	IPAddr  string             `json:"ip_addr"`
	Token   string             `json:"token"`
	Lights  map[string]*Light  `json:"lights,omitempty"`
	Groups  map[string]*Group  `json:"groups,omitempty"`
	Sensors map[string]*Sensor `json:"sensors,omitempty"`
	Fetch   BridgeFetch
	Config  *BridgeConfig
}

func Conn

func Conn(IPAddr string, options BridgeOptions) *Bridge

Make new conn to the bridge

func (*Bridge) Rename

func (b *Bridge) Rename(name string) error

func (*Bridge) SearchNewLights

func (b *Bridge) SearchNewLights() error

The bridge will open the network for 40s and search all available devices, send multiple time append 40s. For show new devices, you need to use ShowNewLights.

func (*Bridge) ShowNewLights

func (b *Bridge) ShowNewLights() (list []AvailableLight, err error)

Gets a list of lights that were discovered the last time a search for new lights was performed. The list of new lights is always deleted when a new search is started. If you miss one light, you can find it in group "0"

type BridgeConfig

type BridgeConfig struct {
	Name             string `json:"name"`
	Zigbeechannel    int    `json:"zigbeechannel"`
	Bridgeid         string `json:"bridgeid"`
	Mac              string `json:"mac"`
	Dhcp             bool   `json:"dhcp"`
	Ipaddress        string `json:"ipaddress"`
	Netmask          string `json:"netmask"`
	Gateway          string `json:"gateway"`
	Proxyaddress     string `json:"proxyaddress"`
	Proxyport        int    `json:"proxyport"`
	UTC              string `json:"UTC"`
	Localtime        string `json:"localtime"`
	Timezone         string `json:"timezone"`
	Modelid          string `json:"modelid"`
	Datastoreversion string `json:"datastoreversion"`
	Swversion        string `json:"swversion"`
	Apiversion       string `json:"apiversion"`
	Swupdate         struct {
		Updatestate    int  `json:"updatestate"`
		Checkforupdate bool `json:"checkforupdate"`
		Devicetypes    struct {
			Bridge  bool          `json:"bridge"`
			Lights  []interface{} `json:"lights"`
			Sensors []interface{} `json:"sensors"`
		} `json:"devicetypes"`
		URL    string `json:"url"`
		Text   string `json:"text"`
		Notify bool   `json:"notify"`
	} `json:"swupdate"`
	Swupdate2 struct {
		Checkforupdate bool   `json:"checkforupdate"`
		Lastchange     string `json:"lastchange"`
		Bridge         struct {
			State       string `json:"state"`
			Lastinstall string `json:"lastinstall"`
		} `json:"bridge"`
		State       string `json:"state"`
		Autoinstall struct {
			Updatetime string `json:"updatetime"`
			On         bool   `json:"on"`
		} `json:"autoinstall"`
	} `json:"swupdate2"`
	Linkbutton       bool   `json:"linkbutton"`
	Portalservices   bool   `json:"portalservices"`
	Portalconnection string `json:"portalconnection"`
	Portalstate      struct {
		Signedon      bool   `json:"signedon"`
		Incoming      bool   `json:"incoming"`
		Outgoing      bool   `json:"outgoing"`
		Communication string `json:"communication"`
	} `json:"portalstate"`
	Internetservices struct {
		Internet     string `json:"internet"`
		Remoteaccess string `json:"remoteaccess"`
		Time         string `json:"time"`
		Swupdate     string `json:"swupdate"`
	} `json:"internetservices"`
	Factorynew       bool        `json:"factorynew"`
	Replacesbridgeid interface{} `json:"replacesbridgeid"`
	Backup           struct {
		Status    string `json:"status"`
		Errorcode int    `json:"errorcode"`
	} `json:"backup"`
	Starterkitid string `json:"starterkitid"`
	Whitelist    map[string]struct {
		LastUseDate string `json:"last use date"`
		CreateDate  string `json:"create date"`
		Name        string `json:"name"`
	} `json:"whitelist"`
}

type BridgeFetch

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

func (*BridgeFetch) Bridge

func (b *BridgeFetch) Bridge() error

func (*BridgeFetch) Lights

func (b *BridgeFetch) Lights() error

type BridgeOptions

type BridgeOptions struct {
	Token        string
	SaveToken    bool
	SaveLocation string
	Debug        int
}

type DiscoverModel

type DiscoverModel struct {
	ID                string `json:"id"`
	Internalipaddress string `json:"internalipaddress"`
}

func Discover

func Discover() (dm DiscoverModel, err error)

func DiscoverAll

func DiscoverAll() (dm []DiscoverModel, err error)

type Error

type Error []struct {
	Error struct {
		Type        int    `json:"type"`
		Address     string `json:"address"`
		Description string `json:"description"`
	} `json:"error"`
}

type Group

type Group struct {
	Name    string        `json:"name"`
	Lights  []string      `json:"lights"`
	Sensors []interface{} `json:"sensors"`
	Type    string        `json:"type"`
	State   struct {
		AllOn bool `json:"all_on"`
		AnyOn bool `json:"any_on"`
	} `json:"state"`
	Recycle bool   `json:"recycle"`
	Class   string `json:"class"`
	Action  struct {
		On        bool      `json:"on"`
		Bri       int       `json:"bri"`
		Hue       int       `json:"hue"`
		Sat       int       `json:"sat"`
		Effect    string    `json:"effect"`
		Xy        []float64 `json:"xy"`
		Ct        int       `json:"ct"`
		Alert     string    `json:"alert"`
		Colormode string    `json:"colormode"`
	} `json:"action"`
}

type Light

type Light struct {
	Key    string
	Bridge *Bridge
	// Philips Hue API
	State struct {
		On        bool      `json:"on,omitempty"`
		Bri       uint8     `json:"bri,omitempty"`
		Hue       uint16    `json:"hue,omitempty"`
		Sat       uint8     `json:"sat,omitempty"`
		Effect    string    `json:"effect,omitempty"`
		Xy        []float64 `json:"xy,omitempty"`
		Ct        uint16    `json:"ct,omitempty"`
		Alert     string    `json:"alert,omitempty"`
		Colormode string    `json:"colormode"`
		Mode      string    `json:"mode"`
		Reachable bool      `json:"reachable"`
	} `json:"state"`
	Swupdate struct {
		State       string `json:"state"`
		Lastinstall string `json:"lastinstall"`
	} `json:"swupdate"`
	Type             string `json:"type"`
	Name             string `json:"name"`
	Modelid          string `json:"modelid"`
	Manufacturername string `json:"manufacturername"`
	Productname      string `json:"productname"`
	Capabilities     struct {
		Certified bool `json:"certified"`
		Control   struct {
			Mindimlevel    int         `json:"mindimlevel"`
			Maxlumen       int         `json:"maxlumen"`
			Colorgamuttype string      `json:"colorgamuttype"`
			Colorgamut     [][]float64 `json:"colorgamut"`
			Ct             struct {
				Min int `json:"min"`
				Max int `json:"max"`
			} `json:"ct"`
		} `json:"control"`
		Streaming struct {
			Renderer bool `json:"renderer"`
			Proxy    bool `json:"proxy"`
		} `json:"streaming"`
	} `json:"capabilities"`
	Config struct {
		Archetype string `json:"archetype"`
		Function  string `json:"function"`
		Direction string `json:"direction"`
		Startup   struct {
			Mode       string `json:"mode"`
			Configured bool   `json:"configured"`
		} `json:"startup"`
	} `json:"config"`
	Uniqueid   string `json:"uniqueid"`
	Swversion  string `json:"swversion"`
	Swconfigid string `json:"swconfigid,omitempty"`
	Productid  string `json:"productid,omitempty"`
}

func (*Light) Alarm

func (l *Light) Alarm(ch chan error, duration time.Duration) error

func (*Light) Rename

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

Used to rename lights. A light can have its name changed when in any state, including when it is unreachable or off.

func (*Light) SetAlert

func (l *Light) SetAlert(alert string) error

Set alert effect to light

func (*Light) SetBrightness

func (l *Light) SetBrightness(bri uint8) error

Set brightness to the light

func (*Light) SetColorCIE

func (l *Light) SetColorCIE(x, y float64) error

Allows you to set light color with CIE value

func (*Light) SetColorHEX

func (l *Light) SetColorHEX(hex string) error

Allows you to set light color with HEX value

func (*Light) SetColorRGB

func (l *Light) SetColorRGB(r, g, b float64) error

Allows you to set light color with RGB value

func (*Light) SetColorTemperature

func (l *Light) SetColorTemperature(ct uint16) error

Allows you to set color temperature

func (*Light) SetEffect

func (l *Light) SetEffect(effect string) error

Set effect to light, actually only "colorloop" exist

func (*Light) SetHue

func (l *Light) SetHue(hue uint16) error

Set Hue to the light

func (*Light) SetSaturation

func (l *Light) SetSaturation(sat uint8) error

Set saturation of the light

func (*Light) Toggle

func (l *Light) Toggle(on bool) error

Toggle light to ON/OFF

type Sensor

type Sensor struct {
	State struct {
		Daylight    bool   `json:"daylight,omitempty"`
		Buttonevent int    `json:"buttonevent,omitempty"`
		Lastupdated string `json:"lastupdated"`
	} `json:"state"`
	Swupdate struct {
		State       string `json:"state"`
		Lastinstall string `json:"lastinstall"`
	} `json:"swupdate,omitempty"`
	Config struct {
		On            bool          `json:"on"`
		Configured    bool          `json:"configured,omitempty"`
		Sunriseoffset int           `json:"sunriseoffset,omitempty"`
		Sunsetoffset  int           `json:"sunsetoffset,omitempty"`
		Battery       int           `json:"battery,omitempty"`
		Reachable     bool          `json:"reachable,omitempty"`
		Pending       []interface{} `json:"pending,omitempty"`
	} `json:"config"`
	Name             string `json:"name"`
	Type             string `json:"type"`
	Modelid          string `json:"modelid"`
	Manufacturername string `json:"manufacturername"`
	Productname      string `json:"productname,omitempty"`
	Diversityid      string `json:"diversityid,omitempty"`
	Swversion        string `json:"swversion"`
	Uniqueid         string `json:"uniqueid,omitempty"`
	Capabilities     struct {
		Certified bool `json:"certified"`
		Primary   bool `json:"primary"`
		Inputs    []struct {
			Repeatintervals []int `json:"repeatintervals"`
			Events          []struct {
				Buttonevent int    `json:"buttonevent"`
				Eventtype   string `json:"eventtype"`
			} `json:"events"`
		} `json:"inputs"`
	} `json:"capabilities,omitempty"`
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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