Categorygithub.com/amimof/huego
modulepackage
1.2.1
Repository: https://github.com/amimof/huego.git
Documentation: pkg.go.dev

# README

Go Go Report Card codecov Awesome

Huego

An extensive Philips Hue client library for Go with an emphasis on simplicity. It is designed to be clean, unbloated and extensible. With Huego you can interact with any Philips Hue bridge and its resources including Lights, Groups, Scenes, Sensors, Rules, Schedules, Resourcelinks, Capabilities and Configuration .

Installation

Get the package and import it in your code.

go get github.com/amimof/huego

You may use New() if you have already created an user and know the IP address to your bridge.

package main

import (
  "github.com/amimof/huego"
  "fmt"
)

func main() {
  bridge := huego.New("192.168.1.59", "username")
  l, err := bridge.GetLights()
  if err != nil {
    panic(err)
  }
  fmt.Printf("Found %d lights", len(l))
}

Or discover a bridge on your network with Discover() and create a new user with CreateUser(). To successfully create a user, the link button on your bridge must have been pressed before calling CreateUser() in order to authorise the request.

func main() {
  bridge, _ := huego.Discover()
  user, _ := bridge.CreateUser("my awesome hue app") // Link button needs to be pressed
  bridge = bridge.Login(user)
  light, _ := bridge.GetLight(3)
  light.Off()
}

Documentation

See godoc.org/github.com/amimof/huego for the full package documentation.

Contributing

All help in any form is highly appreciated and your are welcome participate in developing Huego together. To contribute submit a Pull Request. If you want to provide feedback, open up a Github Issue or contact me personally.

# Functions

ConvertRGBToXy converts a given RGB color to the xy color of the ligth.
Discover performs a discovery on the network looking for bridges using https://www.meethue.com/api/nupnp service.
DiscoverAll performs a discovery on the network looking for bridges using https://www.meethue.com/api/nupnp service.
DiscoverAllContext performs a discovery on the network looking for bridges using https://www.meethue.com/api/nupnp service.
DiscoverContext performs a discovery on the network looking for bridges using https://www.meethue.com/api/nupnp service.
New instantiates and returns a new Bridge.

# Structs

APIError defines the error response object returned from the bridge after an invalid API request.
APIResponse holds the response data returned form the bridge after a request has been made.
AutoInstall holds automatic update configuration.
Backup holds configuration backup status information.
Bridge exposes a hardware bridge through a struct.
BridgeConfig holds information about software updates.
Capabilities holds a combined model of resource capabilities on the bridge: https://developers.meethue.com/documentation/lights-api.
Capability defines the resource and subresource capabilities.
Command defines the request to be made when the schedule occurs.
Condition defines the condition of a rule.
Config holds the bridge hardware configuration.
DeviceTypes details the type of updates available.
Group represents a bridge group https://developers.meethue.com/documentation/groups-api.
GroupState defines the state on a group.
InternetService stores information about the internet connectivity to the bridge.
Light represents a bridge light https://developers.meethue.com/documentation/lights-api.
NewLight defines a list of lights discovered the last time the bridge performed a light discovery.
NewSensor defines a list of sensors discovered the last time the bridge performed a sensor discovery.
PortalState is a struct representing the portal state.
Resourcelink represents a bridge resourcelink https://developers.meethue.com/documentation/resourcelinks-api.
Response is a wrapper struct of the success response returned from the bridge after a successful API call.
Rule represents a bridge rule https://developers.meethue.com/documentation/rules-api.
RuleAction defines the rule to execute when a rule triggers.
Scene represents a bridge scene https://developers.meethue.com/documentation/scenes-api.
Schedule represents a bridge schedule https://developers.meethue.com/documentation/schedules-api-0.
Sensor represents a bridge sensor https://developers.meethue.com/documentation/sensors-api.
State defines the attributes and properties of a light.
Stream define the stream status of a group.
SwUpdate contains information related to software updates.
SwUpdate2 contains information related to software updates.
Whitelist represents a whitelist user ID in the bridge.