peter-murray / node-hue-api

Node.js Library for interacting with the Philips Hue Bridge and Lights
Apache License 2.0
1.19k stars 145 forks source link

Current State #92

Closed WeslleyDeSouza closed 7 years ago

WeslleyDeSouza commented 8 years ago

Hello, I can get the state of the Lamp by:

api.lightStatus(5) .then(displayStatus) .done();

and get the value:

{ "state": { "on": true, "bri": 254, "hue": 34515, "sat": 236, "xy": [ 0.3138, 0.3239 ],

how can I get ony the value from "on" ?

thanks!

peter-murray commented 7 years ago

You would replace the displayStatus function with a function that used the status value that it is provided with to obtain the on value.

For example:

function myOnStatus(status) {
  var onState = status.state.on;
  console.log("Light on state is " + onState);
}