node-relayr
Relayr sensor SDK for node.
Works by connecting to the MQTT channel associated with your Relayr connected
device.
Status
This is still not much more thatn a utiity script, but will grow to expose a
lot more useful functionality.
installation
npm install relayr
connecting
Require the module
var Relayr = require('relayr');
Get the following from your account at relayr.io
var app_id = "YOURAPPID";
var dev_id = "YOURDEVICEID";
var token = "YOURSENSORTOKEN";
Initialise the libary
var relayr = new Relayr(app_id);
Connect using the keys:
relayr.connect(token, dev_id);
Listen and do stuff
relayr.on('data', function (topic, msg) {
console.log(topic + ":" + msg);
}
Send a Command
relayr.command(token, dev_id,
{
path:"led",
command:"led",
value:true
},
function (err,code) {
console.log(err||code)
});
get Info about the registered user
relayr.user(token, function (err, user) {
console.log(err || user);
}
get Info about the users devices
relayr.devices(user_id, token, function (err, devices) {
console.log(err || devices);
}
Credits
Big thanks to BinaryMax for putting in the ground work
License
MIT License