Connect Hue Bulbs to SkyNet

#InternetOfThings

We have been connecting more and more consumer devices to SkyNet (our machine-to-machine instant messaging network). This time we decided to connect the new Phillips Hue LED bulbs to SkyNet and control them with our REST API.

Here’s a quick YouTube video of our end result: http://youtu.be/LcjVxy_lKSI

Here’s the source code that we used in the demo:

var skynet = require(‘skynet’);
var request = require(‘request’);

var conn = skynet.createConnection({ “uuid”: “0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc”, “token”: “qirqglm6yb1vpldixflopnux4phtcsor”, “protocol”: “websocket”
});

conn.on(‘ready’, function(data){

console.log(‘Ready’); conn.on(‘message’, function(channel, data){ if (data.on != undefined){ request( { method: ‘PUT’ , uri: ‘http://172.22.111.174/api/newdeveloper/lights/2/state/’ , body: JSON.stringify({“on”: data.on})

});

} else if (data.hue != undefined){ request( { method: ‘PUT’ , uri: ‘http://172.22.111.174/api/newdeveloper/lights/2/state/’ , body: JSON.stringify({“hue”: data.hue})

}); }

});

});

Here’s the curl commands that we used for calling the SkyNet REST API:

curl -X POST -d ‘{“devices”: “0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc”, “message”: {“on”:true}}’ http://skynet.im/messages

curl -X POST -d ‘{“devices”: “0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc”, “message”: {“on”:false}}’ http://skynet.im/messages

curl -X POST -d ‘{“devices”: “0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc”, “message”: {“hue”:65000}}’ http://skynet.im/messages

Let us know what you build using SkyNet.IM!

Written by

Builder of companies, robots, supercomputers, & motorcycles. @xrpanet & @twelephone CEO. Formerly @magicleap @computesio @citrix @octoblu @nodester @teleku

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store