Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: HueLabs Scenes #143

Closed
foxriver76 opened this issue Oct 24, 2019 · 5 comments
Closed

Enhancement: HueLabs Scenes #143

foxriver76 opened this issue Oct 24, 2019 · 5 comments

Comments

@foxriver76
Copy link

It seems like when activating a scene id which represents a HueLabs Scene the related lights turn on but the scene is not really triggered (dynamic is missing like when triggering the scene via Hue App)

@peter-murray
Copy link
Owner

peter-murray commented Oct 24, 2019

A lot of the HueLabs Scenes are more than just standard scenes, they introduce flags in the CLIP Sensors...

Is there a particular HueLabs scene that I can look into here so that I can attempt to reproduce the problem?

@foxriver76
Copy link
Author

Lets take https://labs.meethue.com/formulas/huelabs/meditation-lights as an example.
So what I tried was activating it like a common scene by

const groupState = new v3.lightStates.GroupLightState();
groupState.scene(`e4SezFcXkCeBaXv`); // id of my meditation lights scene
api.groups.setGroupState(0, groupState);

@peter-murray
Copy link
Owner

peter-murray commented Oct 24, 2019

Thanks for the details.

These are not standard Scene objects, but formulas.

If you take a look at the resourcelinks for the bridge (there is no API support around this in the library yet as it is on a longer list of things to add), the formula will create a resource link like so:

"62738": {
		"name": "Meditation lights",
		"description": "HaM_ofYZuQt91EaJlegnyg:0:O52Qr1gOPIGpgo+BiSiO1cGPryY",
		"type": "Link",
		"classid": 2,
		"owner": "985692e7-6abf-4043-b20e-30d75c0ab864",
		"recycle": true,
		"links": [
			"/rules/28",
			"/rules/26",
			"/rules/13",
			"/rules/12",
			"/rules/11",
			"/rules/10",
			"/scenes/36RwPeb36LqYbJl",
			"/sensors/189",
			"/sensors/188",
			"/groups/6"
		]
	}

That lists all the things that make up the Meditation Lights Formula. You can use the http://[bridge ip address]/debug/clip.html URL to run GET /api/[valid-username]/resourcelinks on your bridge to see the equivalent.

In the two sensors that were created, both of them are CLIPGenericStatus with names of Start and stop and mystate.

Toggling the Start and stop sensor state, which is an integer value.

Turning this formula on is done using (the Start and stop sensor on my bridfge is id 189):

api.sensors.get(189)
      .then(sensor => {
        sensor.status = 1;
        return api.sensors.updateSensorState(sensor);
      });
api.sensors.get(189)
      .then(sensor => {
        sensor.status = 0;
        return api.sensors.updateSensorState(sensor);
      });

@foxriver76
Copy link
Author

How do you know that sensor 189 and not 188 is the one to control in this example? In the future it would be handsome to have a wrapper for this. What are your thoughts on this?

@peter-murray
Copy link
Owner

There are two sensors, the names are myState and Start and stop in the resourcelink. For my bridge 189 was Start and stop, based on the name I took a punt on how it works.

Most formulas are built like this, creating software sensors to control on/off and other intermediate behaviour.

I am starting work on resource links, but this is only a collection mechanism, and is fairly new to the APIs. The problem is it is merely a grouping construct and there is no naming conventions about what developers, official or otherwise will use these for.

There is no simple thing like all resourcelinks will have a sensor called x for turning on say a formula. They are completely free form for connecting things that may be related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants