Giter Club home page Giter Club logo

philips-hue-client's Introduction

Philips Hue API v2 Client

Go Report Card Godoc

The Philips Hue API is provided by a local bridge device that is connected to the local network via ethernet cable (not PoE powered). This client implementation in golang implements the second generation of this local Philips Hue API.

Getting Started

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

Security Scanning and Patching

# SAST Scanning, install via https://github.com/securego/gosec
$ gosec ./...

# Vulnerability and Secret Scanning, install via https://aquasecurity.github.io/trivy
$ trivy fs .

# Udate dependencies (if any)
$ go get -u ./...
$ go mod tidy

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)

Available Predefined Light States

The following presets can be used to switch on the light and configure it appropriately, see presets.go

  • BRIGHT_NEUTRAL_WHITE_ON
  • BRIGHT_WARM_RED_ON
  • BRIGHT_WARM_GREEN_ON
  • BRIGHT_WARM_BLUE_ON

philips-hue-client's People

Contributors

obale avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.