-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9c6d0eb
Showing
20 changed files
with
1,531 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
name: tests | ||
env: | ||
GO111MODULE: on | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [1.16.x] | ||
platform: [ubuntu-latest] | ||
include: | ||
- go-version: 1.x | ||
platform: windows-latest | ||
|
||
- go-version: 1.x | ||
platform: ubuntu-latest | ||
update-coverage: true | ||
runs-on: ${{ matrix.platform }} | ||
|
||
steps: | ||
- name: Cancel previous | ||
uses: styfle/cancel-workflow-action@89f242ee29e10c53a841bfe71cc0ce7b2f065abc #0.9.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- uses: actions/setup-go@v1 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Cache go modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-go- | ||
|
||
- name: Run go fmt | ||
if: runner.os != 'Windows' | ||
run: diff -u <(echo -n) <(gofmt -d -s .) | ||
|
||
- name: Ensure go generate produces a zero diff | ||
shell: bash | ||
run: go generate -x ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code) | ||
|
||
- name: Run go vet | ||
run: go vet ./... | ||
|
||
- name: Run go test | ||
run: go test -v -race -coverprofile coverage.txt -covermode atomic ./... | ||
|
||
- name: Upload coverage to Codecov | ||
if: ${{ matrix.update-coverage }} | ||
uses: codecov/codecov-action@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
### VisualStudioCode ### | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2021 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<h1 align="center">go-hue</h1> | ||
<h3 align="center">*** Work In Progress ***</h3> | ||
|
||
<p align="center"> | ||
<a href="https://github.com/firstthumb/go-hue/commits/master"> | ||
<img src="https://img.shields.io/github/last-commit/firstthumb/go-hue.svg" target="_blank" /> | ||
</a> | ||
<img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/firstthumb/go-hue"> | ||
<img alt="GitHub go.mod Go version" src="https://img.shields.io/github/go-mod/go-version/firstthumb/go-hue"> | ||
<a href="http://godoc.org/github.com/firstthumb/go-hue"> | ||
<img src="https://godoc.org/github.com/firstthumb/go-hue?status.svg" target="_blank" /> | ||
</a> | ||
<a href="https://github.com/firstthumb/go-hue/issues?q=is%3Apr+is%3Aclosed"> | ||
<img alt="GitHub closed pull requests" src="https://img.shields.io/github/issues-pr-closed-raw/firstthumb/go-hue"> | ||
</a> | ||
<a href="https://github.com/firstthumb/go-hue/pulls"> | ||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/firstthumb/go-hue"> | ||
</a> | ||
<a href="https://github.com/firstthumb/go-hue/issues"> | ||
<img alt="GitHub issues" src="https://img.shields.io/github/issues/firstthumb/go-hue"> | ||
</a> | ||
<a href="https://github.com/firstthumb/go-hue/graphs/contributors"> | ||
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/firstthumb/go-hue"> | ||
</a> | ||
<a href="https://github.com/firstthumb/go-hue/blob/master/LICENSE.md"> | ||
<img alt="License: BSD" src="https://img.shields.io/badge/license-MIT-green.svg" target="_blank" /> | ||
</a> | ||
</p> | ||
|
||
> 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 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 | ||
client := hue.NewClient("<BRIDGE_HOST>", "<YOUR USER TOKEN>") | ||
lights, resp, err := client.Light.GetAll(context.Background()) | ||
``` | ||
|
||
## Coverage | ||
|
||
Currently the following services are supported: | ||
|
||
- [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/) | ||
- [ ] Get all groups | ||
|
||
## Show your support | ||
|
||
Give a ⭐️ if this project helped you! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/firstthumb/go-hue" | ||
) | ||
|
||
func main() { | ||
host := "<BRIDGE_HOST>" | ||
token := "<YOUR_USER_TOKEN>" | ||
client := hue.NewClient(nil, host, token) | ||
result, _, _ := client.Light.GetAll(context.Background()) | ||
lights, _ := json.Marshal(result) | ||
fmt.Println(string(lights)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module github.com/firstthumb/go-hue/v1 | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/bombsimon/logrusr v1.1.0 | ||
github.com/go-logr/logr v0.4.0 | ||
github.com/google/go-cmp v0.5.5 | ||
github.com/sirupsen/logrus v1.8.1 | ||
github.com/stretchr/testify v1.4.0 | ||
github.com/thoas/go-funk v0.8.0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
github.com/bombsimon/logrusr v1.1.0 h1:Y03FI4Z/Shyrc9jF26vuaUbnPxC5NMJnTtJA/3Lihq8= | ||
github.com/bombsimon/logrusr v1.1.0/go.mod h1:Jq0nHtvxabKE5EMwAAdgTaz7dfWE8C4i11NOltxGQpc= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= | ||
github.com/go-logr/logr v0.4.0 h1:K7/B1jt6fIBQVd4Owv2MqGQClcgf0R266+7C/QjRcLc= | ||
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= | ||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= | ||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= | ||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | ||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= | ||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= | ||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||
github.com/thoas/go-funk v0.8.0 h1:JP9tKSvnpFVclYgDM0Is7FD9M4fhPvqA0s0BsXmzSRQ= | ||
github.com/thoas/go-funk v0.8.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= | ||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk= | ||
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
Oops, something went wrong.