Created
June 12, 2016 17:20
-
-
Save 131/3d296aeeb42d2bfadb7bd01c90c2d669 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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