This Meteor package lets you controls your Philips Hue lights with Javascript in a Meteor app.
meteor add iwazaru:hue
To use this package, you will need to know your Hue bridge IP address and your username. If you don't know how to do that, please read the [Philips Hue API Getting started](Philips hue API) page.
Initialize Hue
let hue = new HueBridge(HUE_BRIDGE_IP, HUE_BRIDE_USERNAME);
The HueBridge
object represents your bridge. After being instanciated with a IP address and a username, it allow your app to send request to the bridge.
Passes to the callback
function an array of HueLight
objects representing all the lights that the bridge knows of.
hue.getLights(function(lights) {
// do something by iterating the lights array
});
Passes to the callback
function a unique HueLight
object representing the light found for this id
.
hue.getLight(1, function(light) {
light.setOn(); // get the first light and turn it on
});
The HueLight
object represents a light connected to your bridge. It allow you to change a light's state by sending request through the bridge.
.id
: the unique id of the light.bridge
: the bridge from which the lights depends on.params
: the lights parameters
.setOn()
: turns the light on.setOff()
: turns the light off.setBrightness(value)
: sets the light's brightness (from 1 to 254).setHue(value)
: sets the light's hue (from 0 to 65535).setSaturation(value)
: sets the light's saturation (from 0 to 254).startColorloop()
: makes the light loop through all hue values untilstopColorloop()
is called.blink(iterations, interval)
: makes the light turn on and off eachinterval
milliseconds foriterations
times
Turn all lights on
hue.getLights(function(lights) {
for (let i = 0, c = lights.length; i < c; i++) {
lights[i].setOn();
}
});
Turn one light on:
hue.getLight(1, function(light) {
light.setOn();
});
Set a light's brightness:
hue.getLight(1, function(light) {
light.setBrightness(150);
});
Loop through all colors during half a minute:
hue.getLight(3, function(light) {
light.startColorloop();
setTimeout(function() {
light.stopColorloop();
}, 30000);
});
- Allow to use promises instead of callbacks
- Control multiple lights with a
HueLights
object (composite pattern) - Hue bridge discovery and username creation
- Tests!