forked from aholstenson/miio
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for first generation Smart Socket Plug
- Loading branch information
1 parent
982b08d
commit f51ab5d
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |