https://github.com/firstthumb/go-hue
https://github.com/firstthumb/go-hue
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/firstthumb/go-hue
- Owner: firstthumb
- License: mit
- Created: 2021-05-16T12:37:49.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-10-06T11:22:37.000Z (over 4 years ago)
- Last Synced: 2023-07-27T22:06:45.815Z (almost 3 years ago)
- Language: Go
- Size: 90.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
go-hue
*** Work In Progress ***
> go-hue is a Go client library for accessing the [Philips Hue API](https://developers.meethue.com/develop/hue-api/)
## Install
```sh
go get github.com/firstthumb/go-hue
```
## Authentication
Philips Hue uses local and remote authorization. First you need to create user.
## Usage
Import the package into your project.
```Go
import "github.com/firstthumb/go-hue"
```
Use existing user and access Hue services. For example:
```Go
// Discover your network and finds the first bridge
host, _ := hue.Discover()
client := hue.NewClient(host, "", nil)
lights, resp, err := client.Light.GetAll(context.Background())
```
Or create user. Don't forget to save the clientId
```Go
// You must press Philips Hue bridge button before
host, _ := hue.Discover()
client, _ := hue.CreateUser(host, "", nil)
client.GetClientID() // Save clientID for next time
lights, resp, err := client.Light.GetAll(context.Background())
```
Supports remote API
```Go
// Create your clientId and clientSecret at https://developers.meethue.com/my-apps/
// set your environment variables HUE_CLIENT_ID, HUE_CLIENT_SECRET and HUE_APP_ID
// use the same callback url defined in your app
auth := hue.NewAuthenticator("http://localhost:8181/callback")
client, err := auth.Authenticate()
if err != nil {
panic(err)
}
username, err := client.CreateRemoteUser()
if err != nil {
panic(err)
}
client.Login(username)
result, _, _ := client.Light.GetAll(context.Background())
lights, _ := json.Marshal(result)
fmt.Println(string(lights))
```
[More Examples](https://github.com/firstthumb/go-hue/tree/main/example)
## Coverage
Currently the following services are supported:
- [x] [Remote API](https://developers.meethue.com/develop/hue-api/remote-api-quick-start-guide/)
- [x] Remote Login
- [x] [Lights API](https://developers.meethue.com/develop/hue-api/lights-api/)
- [x] Get all lights
- [x] Get new lights
- [x] Search for new lights
- [x] Get light attributes and state
- [x] Set light attributes (rename)
- [x] Set light state
- [x] Delete lights
- [x] [Groups API](https://developers.meethue.com/develop/hue-api/groupds-api/)
- [x] Get all groups
- [x] Create group
- [x] Get group attributes
- [x] Set group attributes
- [x] Set group state
- [x] Delete group
- [ ] [Schedules API](https://developers.meethue.com/develop/hue-api/3-schedules-api/)
- [ ] [Scenes API](https://developers.meethue.com/develop/hue-api/4-scenes/)
## Show your support
Give a ⭐️ if this project helped you!