https://github.com/gbbr/hue
Philips Hue API
https://github.com/gbbr/hue
go hue
Last synced: 9 months ago
JSON representation
Philips Hue API
- Host: GitHub
- URL: https://github.com/gbbr/hue
- Owner: gbbr
- Created: 2016-08-25T15:50:11.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-14T17:21:43.000Z (almost 9 years ago)
- Last Synced: 2025-04-12T12:58:22.116Z (about 1 year ago)
- Topics: go, hue
- Language: Go
- Homepage: http://www.meethue.com
- Size: 21.5 KB
- Stars: 33
- Watchers: 5
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://godoc.org/gbbr.io/hue)
[](https://travis-ci.org/gbbr/hue)
#  hue
hue is a small package for interacting with a [Phillips Hue](http://www.meethue.com/) bridge. It facilitates discovery, authentication and control of up to one brige in your local network.
### hello world
To discover a bridge, pair with it and turn on a light named _"Desk"_, the program would be:
```go
package main
import (
"log"
"gbbr.io/hue"
)
func main() {
b, err := hue.Discover()
if err != nil {
log.Fatal(err)
}
if !b.IsPaired() {
// link button must be pressed before calling
if err := b.Pair(); err != nil {
log.Fatal(err)
}
}
light, err := b.Lights().Get("Desk")
if err != nil {
log.Fatal(err)
}
if err := light.On(); err != nil {
log.Fatal(err)
}
}
```
hue attempts to discover a bridge using UPnP (for up to 5 seconds) or by falling back to a remote [endpoint](https://www.meethue.com/api/nupnp). On subsequent calls, discovery and pairing data is readily available from cache stored on the file system in `~/.hue`. It is best practice to check that the device has not already been paired with before calling `Pair`, for performance reasons.
Shall you ever need to reset the cache, simply remove the file.
There are still aspects of the API to be implemented, but the individual light interaction is complete. To see the full documentation, visit our [godoc](https://godoc.org/gbbr.io/hue) page.