Skip to content

basheuft/hue

 
 

Repository files navigation

hue travis-ci

hue

hue is a small package for interacting with a Phillips Hue 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:

package main

import (
    "log"
    "github.com/gbbr/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. 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 page.

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%