Skip to content

Commit

Permalink
Support for first generation Smart Socket Plug
Browse files Browse the repository at this point in the history
  • Loading branch information
aholstenson committed Apr 17, 2017
1 parent 982b08d commit f51ab5d
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/devices/chuangmi.plug.v1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';

const Device = require('../device');

const PowerChannels = require('./capabilities/power-channels');

class PlugV1 extends Device {
static get TYPE() { return 'switch' }

constructor(options) {
super(options);

this.type = PlugV1.TYPE;

this.defineProperty('on', {
name: 'powerChannel0'
});
PowerChannels.extend(this, {
channels: 1,
set: (channel, power) => this.call(power ? 'set_on' : 'set_off', [])
});

this.defineProperty('usb_on', {
name: 'powerUSB'
});
}

get powerUSB() {
return this.property('powerUSB');
}

setPowerUSB(power) {
return this.call(power ? 'set_usb_on' : 'set_usb_off', [])
.then(() => power);
}
}

module.exports = PlugV1;

0 comments on commit f51ab5d

Please sign in to comment.