Skip to content

Instantly share code, notes, and snippets.

@kunal732

kunal732/hookjs Secret

Created February 5, 2014 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunal732/c96427c82a886c9f4899 to your computer and use it in GitHub Desktop.
Save kunal732/c96427c82a886c9f4899 to your computer and use it in GitHub Desktop.
if (Meteor.isClient) {
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
Meteor.Router.add({
'/apartment': function() {
post = this.request.body;
console.log(post);
color = post.subject;
if(color.toLowerCase() == "on") {
Meteor.http.call('PUT','http://192.168.1.7/api/newdeveloper/lights/1/state', {data: {"on": true}})
Meteor.http.call('PUT','http://192.168.1.7/api/newdeveloper/lights/2/state', {data: {"on": true}})
Meteor.http.call('PUT','http://192.168.1.7/api/newdeveloper/lights/3/state', {data: {"on": true}})
}
else if(color.toLowerCase() == "off") {
Meteor.http.call('PUT','http://192.168.1.7/api/newdeveloper/lights/1/state', {data: {"on": false}})
Meteor.http.call('PUT','http://192.168.1.7/api/newdeveloper/lights/2/state', {data: {"on": false}})
Meteor.http.call('PUT','http://192.168.1.7/api/newdeveloper/lights/3/state', {data: {"on": false}})
}else {
color = parseFloat(color);
console.log(Meteor.http.call('PUT','http://192.168.1.7/api/newdeveloper/lights/2/state', {data: {"hue": color}}));
Meteor.http.call('PUT','http://192.168.1.7/api/newdeveloper/lights/1/state', {data: {"hue": color}})
Meteor.http.call('PUT','http://192.168.1.7/api/newdeveloper/lights/3/state', {data: {"hue": color}})
}
return [200, "Success"] }
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment