We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
This provides a simple API...
To turn on a light with device id 0x101010/1 you can visit (or access using curl or wget).
http://localhost:3000/light/0x101010/1/on
and to turn it off...
http://localhost:3000/light/0x101010/1/off
var rfxcom = require('rfxcom'), restify = require('restify'), rfxtrx = new rfxcom.RfxCom('/dev/ttyUSB0', {debug: true}), lightwave = new rfxcom.LightwaveRf(rfxtrx), server = restify.createServer({ name: 'lightwave', version: '0.0.1' }); server.use(restify.acceptParser(server.acceptable)); server.use(restify.queryParser()); server.use(restify.bodyParser()); server.get('/light/:device/:code/:option/', function (req, res, next) { var deviceId = req.params.device + '/' + req.params.code, statusCode = 200; switch (req.params.option) { case 'on': lightwave.switchOn(deviceId); console.log('Turning on light %s', deviceId); break; case 'off': lightwave.switchOff(deviceId); console.log('Turning off light %s', deviceId); break; default: console.log('Unknown option', req.params.option); statusCode = 400; break; } res.send(statusCode); return next(); }); rfxtrx.initialise(function (error) { if (error) { throw new Error("Unable to initialise the rfx device"); }; }); server.listen(8080, function () { console.log('%s listening at %s', server.name, server.url); });