hue.rs icon indicating copy to clipboard operation
hue.rs copied to clipboard

Support for scenes

Open ThouCheese opened this issue 5 years ago • 13 comments

It would be nice if it were possible to list scenes and enable them using this library. I want to make a small interface to operate my home lights, and I want to be able to enable scenes with it.

ThouCheese avatar Dec 03 '20 13:12 ThouCheese

I'm not doing new features myself for this library at this point, but I will review and merge PR for scenes support.

kali avatar Dec 06 '20 10:12 kali

Alright! I think I can come up with a PR to rework some of the internals and add support for groups one of these days. I'd also like to add some tests here and there to make sure I don't break anything. One thing I'd like to look into is splitting the Bridge into two structs: UnauthBridge and Bridge, so that it is a compile error to try to run API calls without providing a password or logging in by making the invalid calls simply not exist. Would such a PR be welcome?

ThouCheese avatar Dec 07 '20 12:12 ThouCheese

All of this sounds pretty good. One single thing: I prefer, when practical, to have separate PRs for distinct things. At least keep the bridge state refactoring separate from new features.

kali avatar Dec 07 '20 12:12 kali

Alright, I'll try to make a couple of smaller PR's, but I might have to wait until they get accepted, or fork off them to create the next PR then.

ThouCheese avatar Dec 28 '20 18:12 ThouCheese

I'll try my best to be very reactive.

kali avatar Dec 28 '20 18:12 kali

Seems great so far :smiley:

ThouCheese avatar Dec 28 '20 19:12 ThouCheese

I went through some online docs I found and I implemented the "config", "group" and "schedule" API's, but I can't seem to find docs pertaining to scenes. Did you ever stumble on something along these lines?

ThouCheese avatar Dec 28 '20 19:12 ThouCheese

Now that you mention this, I wonder if scenes are not just a client side thing...

kali avatar Dec 28 '20 20:12 kali

I don't think that that is true. If i create a scene on one device, I can see and activate that scene from another device as well.

ThouCheese avatar Dec 28 '20 21:12 ThouCheese

I'm implementing support for schedules currently, and since the documentation is a bit lacking I am looking at the JSON for schedules and I noticed this command performed my one of my default schedules:

"command":{
    "address":"/api/<UUID>/groups/0/action",
    "body":{"scene":"BS8gROMPGsehOqT"},
    "method":"PUT"
}

So it seems like it is possible to send the desired scene to /groups/id/action. According to the docs, this endpoint expects a CommandLight, so maybe those can be interchanged.

ThouCheese avatar Dec 29 '20 17:12 ThouCheese

aha, interesting :)

kali avatar Dec 29 '20 17:12 kali

googling...

https://stackoverflow.com/questions/18274632/how-to-create-scenes-with-the-philips-hue-api https://github.com/peter-murray/node-hue-api/blob/master/examples/v3/scenes/updateSceneLightState.js#L57

kali avatar Dec 29 '20 17:12 kali

One thing I'd like to look into is splitting the Bridge into two structs: UnauthBridge and Bridge, so that it is a compile error to try to run API calls without providing a password or logging in by making the invalid calls simply not exist.

This is a great idea. I love how Rust's ownership model lets you enforce concepts like this.

rneswold avatar Jun 28 '21 18:06 rneswold