kunal732 / hookjs secret
Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View hookjs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
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
Something went wrong with that request. Please try again.