Skip to content

Instantly share code, notes, and snippets.

@131
Created June 12, 2016 17:20
Show Gist options
  • Save 131/3d296aeeb42d2bfadb7bd01c90c2d669 to your computer and use it in GitHub Desktop.
Save 131/3d296aeeb42d2bfadb7bd01c90c2d669 to your computer and use it in GitHub Desktop.
var ClapEngine = require('clap-trigger');
var hue = require("node-hue-api");
var HueApi = hue.HueApi;
var lightState = hue.lightState;
var hostname = "192.168.131.47";
var user_id = 'iwonttell';
var api = new HueApi(hostname, user_id);
var trigger = new ClapEngine();
var toggle = false, set = 0;
trigger.clap(function() {
toggle = set++%2 == 0;
console.log("Got clap", toggle); //swith on or off my light here \o/
api.setLightState(3, {"on": toggle, bri : 20}, function(err, lights) {
console.log(err, lights)
});
});
trigger.start(function(){ });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment