Code Monkey home page Code Monkey logo

huego's People

Contributors

aliallomani avatar amimof avatar bboehmke avatar dlsniper avatar duhruh avatar emdioh avatar felixls avatar kevinms avatar martinrhoads avatar matzew avatar skroczek avatar smonesi avatar steelphase avatar willie68 avatar yunginnanet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

huego's Issues

Proposal: Please start using Semantic Versioning

I found that this project already supports Go modules. But sadly, the tags doesn't follow Semantic Versioning, which means that all tags of this project will be ignored by Go modules and replaced by pseudo-versions, go get acts weirdly when tags are not in that form. It would be great to have the tagged release be named in the format vX.X.X format so that go mod can read it.

	github.com/amimof/huego v0.0.0-20200504200310-b4a8f71aa2e3

Else the mod file shows something like github.com/amimof/huego v0.0.0-20200504200310-b4a8f71aa2e3 which is not very readable and difficult to upgrade. It’s hard to verify which version is in use. This is not conducive to version control

So, I propose this project to follow Semantic Versioning in future versions. For example, v1.0.1, v2.0.0, v3.1.0-alpha, v3.1.0-beta.2etc.

First Class Support for Hue Entertainment API

Hue now has the Entertainment API which allows for faster syncing through their DTLS/UDP protocol. https://developers.meethue.com/develop/hue-entertainment/philips-hue-entertainment-api/

Looking at this Go project, it seems like some of the stuff has been already worked on (creating user registration with generateclientkey set to true and groups light support). The only thing left seems to be getting a nice interface surrounding the DTLS/UDP part of the entertainment API. I'm wondering if anyone on this project has attempted to do this?

Cannot update Scene -- parameter not modifiable

Probably related to #45 -- the recycle parameter is marked as bool without any omit directive. It works for creating the scene but not for updating it.

Steps to reproduce the issue:

  1. Try to update a scene name
  2. Error: parameter, recycle, is not modifiable

Describe the results you received:
I am implementing a terraform provider, this is the JSON:
{"name":"Testing","recycle":false}

│ Error: ERROR 8 [/scenes/jeU0J-6kXNVvnnL/recycle]: "parameter, recycle, is not modifiable"

Describe the results you expected:

Hue Bridge Version

"apiversion": "1.48.0",
"swversion": "1948086000",

Can I help?

I am learning go as I write this provider, if you provide me some pointers I can contribute towards the solution.

My naive solution would be adding a map to the "update" instead of using the struct so we have fine control over the elements -- but I think the solution from #45 would solve this in a better way.

CreateUser

Running the example from the readme I get an error:

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()
}
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0x60ab3b]

goroutine 1 [running]:
github.com/amimof/huego.(*Bridge).getAPIPath(0x0, 0xc042089d60, 0x3, 0x3, 0x40, 0x0, 0x0, 0x62a740)
        C:/Go/bin/src/github.com/amimof/huego/bridge.go:21 +0x4b
github.com/amimof/huego.(*Bridge).SetLightState(0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        C:/Go/bin/src/github.com/amimof/huego/bridge.go:487 +0x181
github.com/amimof/huego.(*Light).Off(0xc0421da0a0, 0x3, 0xc0421da0a0)
        C:/Go/bin/src/github.com/amimof/huego/light.go:59 +0xa7
main.main()
        C:/Users/Julian/Documents/WaterCan/main/main.go:16 +0x126
exit status 2

Unable to rename group

I get the following error when trying to call group.Rename(): ERROR 6 [/groups/9/state]: "parameter, state, not available"

Is this a change in the API perhaps? Using the version of this code.

Won't "login"

I'm able to use the "discover -> create user" when I press the button on the bridge, but I'm not able to get the "new" command to work. Each time I run the line it says "ERROR 1 [/lights]: "unauthorized user"

But I know I've created that user ( by pushing the button and running the other code ) many times! Help.

bridge := huego.New("192.168.1.4", "tyler")

Bug: setting bright will not effect state on

This is a little bug.
The light is off.
If you set the brightness to 254 for a light, the light will be switched on, but the State will remain off.
So, this code will never work...

if light.IsOn() {
  light.Off()
} else {
  light.Bri(254)
}

problem seems to be that the BriContext Method on the light object will not parse the response of the bridge. NOr does it directly change to state.on parameter. (Because it's not possible to set the bri to a light with state off...)

Hue v2 API support?

  • This feature/enhancement benefits everyone

Description

Hi. Really love this library. I was wondering if you have any plans to support the v2 Hue API. I can’t see anything browsing from my mobile. Thanks for any feedback you can provide.

Additional information

Add context.Context support in APIs

First, thanks for this library: the work is outstanding and I really, really love it! Impressive work!

I am integrating Huego (and many other libraries) into a library for my home-automation hub. My goal is to provide a technology-agnostic REST web-service.

A very common pattern for web-services, is to handle properly requests lifetime by honoring the status of the context.Context that is attached to *http.Request instances. Since this context automatically expires when the client underlying connection closes (or any other fatal network condition), this allows for circuit-breaking: for instance, if I use the context.Context from the HTTP request and pass it in an underlying "turn this light on" operation, and the initiating request closes early, it gives a chance to the program to avoid doing unnecessary work by also stopping the "turn this light on" operation sooner.

It is as simple as doing:

req = req.WithContext(ctx)

Before issuing a HTTP request.

The current Huego APIs don't expose a way of passing in a context.Context for each operation. Is that something you'd be interested in? I can probably make a pull-request for it, but I figured I'd discuss it with you first.

There is a way to do that without breaking the API by "overloading" each operation method with a Ctx suffix. Say:

// Context creation: can be done in many ways.
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

// Example call.
light.OnCtx(ctx) // Guaranteed to complete when the operation is over or one second passes by, whichever happens first.

Please let me know what you think of this.

Remote Authentication

Hello,

Could you give an example of Remote Authentication, or add it to the readme? Thank you!

`omitempty` on boolean attributes prevents changing them to `false`

Some boolean attributes are annotated with json:"attributename,omitempty", which means they are omitted from requests when set to the default value for their type, i.e. false. This means that it is impossible to set a boolean attribute to false using a Create* or Update* method.

AutoDelete in Schedule is one example of an affected attribute. It defaults to true when not provided, and there currently appears to be no way in huego to set it to false.

Here's a quick program that reproduces this:

package main

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

func main() {
	bridge := huego.New("192.168.0.221", "[redacted]")

	schedule := huego.Schedule{
		Name: "Test schedule",
		Command: &huego.Command{
			Address: "/api/0/lights/4/state",
			Method: "PUT",
			Body: map[string]bool{
				"on": true,
			},
		},
		LocalTime: "PT00:00:03",
		AutoDelete: false,
	}

	schedule_json, err := json.Marshal(schedule)
	if err != nil {
		fmt.Printf("error: %v\n", err)
		return
	}

	fmt.Printf("JSONd schedule looks like this:\n%v\n", string(schedule_json))

	response, err := bridge.CreateSchedule(&schedule)
	if err != nil {
		fmt.Printf("error: %v\n", err)
		return
	}

	fmt.Printf("response: %v\n", response)
}

and here's what it outputs on my machine:

JSONd schedule looks like this:
{"name":"Test schedule","description":"","command":{"address":"/api/0/lights/4/state","method":"PUT","body":{"on":true}},"localtime":"PT00:00:03"}
response: &{map[id:2]}

Checking the Bridge API manually confirms that this schedule has autodelete: true, and three seconds later it's gone.

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.