Skip to content

Commit

Permalink
Adding support for power strips
Browse files Browse the repository at this point in the history
  • Loading branch information
aholstenson committed Apr 17, 2017
1 parent 4c65731 commit 0f0b50e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ generic device types to simplify interacting with them.
Currently supported devices are:

* Air Purifiers (1, 2 and Pro)
* Mi Smart Socket Plug
* Mi Smart Socket Plug and Power Strips
* Mi Robot Vacuum
* Mi Smart Home Gateway (Aqara) and accessories

Expand Down
25 changes: 14 additions & 11 deletions docs/devices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ column can be one of the following:

* None - this device is not a miIO-device or has some quirk making it unusable
* Generic - this device is supported via the generic API but does not have a high-level API
* Untested - this device has an implementation but needs testing with a real device
* Basic - the basic functionality of the device is implemented, but more advanced features are missing
* Good - most of the functionality is available including some more advanced features such as settings
* Excellent - as close to complete support as possible

If your device is not in this list, it might still be a miIO-device and at
least have generic support. See the next section for details about how to find
out if that is the case. If your device needs a manual token and the table says
it should not, something has probably changed in the firmware, in that case please
open an issue so the table can be adjusted.
If your device is:

* Not in this list, it might still be a miIO-device and at least have generic support. See the next section for details about how to find out if that is the case.
* Needs a manual token and the table says it should not, something has probably changed in the firmware, please open an issue so the table can be adjusted.
* Marked as Untested you can help by testing the implementation is this library and opening an issue with information about the result

Name | Type | Auto-token | Support | Note
------------------------------|---------------------------------|------------|-----------|--------
Mi Air Purifier 1 | [`air-purifier`](air-purifier.md) | Yes | Good |
Mi Air Purifier 1 | [`air-purifier`](air-purifier.md) | Yes | Untested |
Mi Air Purifier 2 | [`air-purifier`](air-purifier.md) | Yes | Good |
Mi Air Purifier Pro | [`air-purifier`](air-purifier.md) | Yes | Basic | Some of the new features and sensors are not supported.
Mi Flora | - | - | None | Communicates using Bluetooth.
Expand All @@ -54,13 +55,15 @@ Mi Smart Home Gateway 1 | - | Yes | G
Mi Smart Home Gateway 2 | [`gateway`](gateway.md) | Yes | Basic | Light, sound and music features not supported.
Mi Smart Home Gateway 3 | [`gateway`](gateway.md) | Yes | Basic | Light, sound and music features not supported.
Mi Smart Home Cube | [`controller`](controller.md) | Yes | Excellent | Aqara device via Smart Home Gateway
Mi Smart Home Light Switch | [`controller`](controller.md) | Yes | Good | Aqara device via Smart Home Gateway. Needs testing.
Mi Smart Home Light Control | [`switch`](switch.md) | Yes | Good | Aqara device via Smart Home Gateway. Controls power to one or two lights. Needs testing.
Mi Smart Home Light Switch | [`controller`](controller.md) | Yes | Untested | Aqara device via Smart Home Gateway.
Mi Smart Home Light Control | [`switch`](switch.md) | Yes | Untested | Aqara device via Smart Home Gateway. Controls power to one or two lights.
Mi Smart Home Temperature and Humidity Sensor | `sensor` | Yes | Excellent | Aqara device via Smart Home Gateway.
Mi Smart Home Wireless Switch | [`controller`](controller.md) | Yes | Excellent | Aqara device via Smart Home Gateway.
Mi Smart Home Door / Window Sensor | `magnet` | Yes | Good | Aqara device via Smart Home Gateway. Needs testing.
Mi Smart Home Occupancy Sensor | `motion` | Yes | Good | Aqara device via Smart Home Gateway. Needs testing.
Mi Smart Home Aqara Plug | [`switch`](switch.md) | Yes | Good | Aqara device via Smart Home Gateway. Needs testing.
Mi Smart Home Door / Window Sensor | `magnet` | Yes | Untested | Aqara device via Smart Home Gateway.
Mi Smart Home Occupancy Sensor | `motion` | Yes | Untested | Aqara device via Smart Home Gateway.
Mi Smart Home Aqara Plug | [`switch`](switch.md) | Yes | Untested | Aqara device via Smart Home Gateway.
Mi Smart Power Strip 1 | [`switch`](switch.md) | Unknown | Untested | Setting power and mode is untested.
Mi Smart Power Strip 2 | [`switch`](switch.md) | Unknown | Untested | Setting power and mode is untested.

## Finding devices on your network

Expand Down
27 changes: 27 additions & 0 deletions lib/devices/powerstrip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

const Switch = require('./switch');

class PowerStrip extends Switch {
constructor(options) {
super(options);

this.capabilities.push('mode');
this.defineProperty('mode');
}


get modes() {
return [ 'green', 'normal' ];
}

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

setMode(mode) {
return this.call('set_power_mode', [ mode ])
.then(() => mode);
}
}

module.exports = PowerStrip;
4 changes: 4 additions & 0 deletions lib/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const AirPurifier = require('./devices/air-purifier');
const Switch = require('./devices/switch');
const Vacuum = require('./devices/vacuum');
const Gateway = require('./devices/gateway');
const PowerStrip = require('./devices/powerstrip');

module.exports = {
'zhimi.airpurifier.m1': AirPurifier,
Expand All @@ -20,4 +21,7 @@ module.exports = {

'lumi.gateway.v2': Gateway,
'lumi.gateway.v3': Gateway,

'qmi.powerstrip.v1': PowerStrip,
'zimi.powerstrip.v2': PowerStrip
};

0 comments on commit 0f0b50e

Please sign in to comment.