pimote
Version:
Control Energenie Switches from a Raspberry Pi
44 lines (37 loc) • 986 B
JavaScript
// Generated by CoffeeScript 2.6.1
(function() {
//!/usr/bin/env coffee
var Pimote, device, ref, syntax,
indexOf = [].indexOf;
Pimote = require('../lib/pimote');
device = parseInt((ref = process.argv[3]) != null ? ref : 0);
syntax = function() {
console.log("Usage:");
console.log(" pimote on|off [0 or 1 - 4]");
console.log(" pimote pair 1 - 4");
return process.exit(1);
};
if (indexOf.call([0, 1, 2, 3, 4], device) < 0) {
syntax();
}
switch (process.argv[2]) {
case 'on':
console.log(`Turning on ${device ? device : 'all devices'}`);
Pimote.switchOn(device);
break;
case 'off':
console.log(`Turning off ${device ? device : 'all devices'}`);
Pimote.switchOff(device);
break;
case 'pair':
if (!device) {
syntax();
}
console.log(`Pairing ${device}`);
Pimote.pair(device);
break;
default:
syntax();
}
}).call(this);