michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
411 stars 114 forks source link

Q: Scene States #146

Closed Deery5000 closed 6 years ago

Deery5000 commented 6 years ago

Is the Scene Light State properties supposed to be null or should i be seeing the light state of the Scene?

If i get a light, in the State properties i can see the colour properties but i cannot see this for a Scene.

Im trying to set the light colours to a scene colour.

michielpost commented 6 years ago

Which api call are you using?

Getting all the scenes? Or do you get a single scene by id?

Deery5000 commented 6 years ago

Hi,

Below is the code I'm using

  1. GetScenesAsync() returns all the scenes I need however when looping the returned scenes the light state is missing

  2. GetSceneAsync(scene.Id) returns the light states but the properties are all the same on each loop.

How can I get the colour values of a scene so I can send a light command to change to the colour of a scene?

// Add scenes 
IReadOnlyCollection<Scene> scenes = await client.GetScenesAsync(); 
foreach (Scene scene in scenes) // doesnt show light states
{
    Scene se =  await client.GetSceneAsync(scene.Id); // Light states shown but are the same on each loop 
    SceneCollection.Add(scene);
}

Kevin

michielpost commented 6 years ago

There's a bug in your code here: SceneCollection.Add(scene);
It should be: SceneCollection.Add(se); because else you're not using the detailed scene info you just requested.

When you use GetScenesAsync it only has basic info about the scene. Using GetSceneAsync returns all detailed info about a scene, including lightstate.

Deery5000 commented 6 years ago

Scene se was just a test to see if i was able to retrieve the full details. Thanks though

When i get a scene say Spring Blossom, the light state colours are not the same if i was to set them from the phillip Hue app.

I want to be able to get the default scenes and colouring so i can set the lights to these colours. Is there a specific reason why the colours are not correct?

Spring Blossom is coming out as a red colour and not the pink

Kevin

michielpost commented 6 years ago

Check how the colors are set, which colormode is used. XY, Hue + Sat or CT value

You can also apply the scene and read the values from the lights?