Connect Hue Bulbs to SkyNet

@ChrisMatthieu
Jan 17, 2014 · 1 min read

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!

    @ChrisMatthieu

    Written by

    Builder of companies, robots, supercomputers, and motorcycles. @magicleap @computesio #IPFS #decentralized #crypto #blockchain #IoT #HPC #SkyNet

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade