Philips Hue Golang Library Open Sourced

The open source release networld-to/philips-hue-client implements a Philips Hue API v2 library in golang.

The Philips Hue API is provided by a local, physical bridge device that is connected to the network via ethernet cable (not PoE powered). The released golang library implements the second generation of this local Philips Hue API. For more information checkout the README.md.

Release Notes - v0.1.0

First Release Functionality

  • Lights
    • Get all lights
    • Get single light by ID (uuid)
    • Switch light on and off
    • Change light state (during on switch) with presets. Able to control
      • on/off
      • brightness
      • color
      • color temperature
  • Groups, same functionality as for lights, but for a predefined set of lights
  • Rooms
    • Get all rooms
    • Get single room by ID (uuid)

Getting Started (from the README.md)

Point the domain philips-hue.home.arpa to your Philips Hue Bridge IP (not necessary, but simplifies access). Make sure you have an appropriate Philips Hue Bridge configuration under ~/.philips-hue.json. It should look like this:

{"bridge":"philips-hue.home.arpa","username":"THIS_IS_YOUR_PASSWORD","devicetype":"node-philips-hue"}

Instructions and helper code how to setup a new username is coming soon.

To test the library run the client via the following command.

# Comment or uncomment the appropriate lines in client/main.go and run
$ go run client/main.go

Use the philips-hue-client in your application. Create a main.go or any other go file that uses the library, see example below.

package main
import (
	"fmt"
	"log"
	"github.com/networld-to/philips-hue-client/bridge"
)
func main() {
	groups, _, err := bridge.GetGroups()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(bridge.ChangeGroupState(groups.Data[0].ID, bridge.BRIGHT_WARM_GREEN_ON))
}

Run the following commands. This assumes that there is a file that is using this library, see example snippet above.

# Initializes your go module. Change to a name of your liking, e.g. github.com/yourusername/yourmodulename
$ go mod init your/go/mod
$ go mod tidy
$ go run main.go
Author

Alex Oberhauser

Alex Oberhauser is a tech-entrepreneur, innovator and former C-level executive. He is currently working on user controlled identities and the empowerment of the end-users, with privacy and security as part of the value proposition, not as an afterthought.

Comments


You can use your Fediverse (e.g., Mastodon) account to reply to this post .

  

Reply to obale's post

With an account on the Fediverse, such as Mastodon, you can respond to this post. Since Mastodon is decentralized, you can use your existing account hosted by another Mastodon server or compatible platform.

Copy and paste this URL into the search field of your favorite Fediverse app or the web interface of your Mastodon server.