diff --git a/README.md b/README.md index 0d32f23..38f38d1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/devices/README.md b/docs/devices/README.md index 3dc5c06..d49f0a1 100644 --- a/docs/devices/README.md +++ b/docs/devices/README.md @@ -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. @@ -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 diff --git a/lib/devices/powerstrip.js b/lib/devices/powerstrip.js new file mode 100644 index 0000000..916bcde --- /dev/null +++ b/lib/devices/powerstrip.js @@ -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; diff --git a/lib/models.js b/lib/models.js index 856c574..696dd0f 100644 --- a/lib/models.js +++ b/lib/models.js @@ -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, @@ -20,4 +21,7 @@ module.exports = { 'lumi.gateway.v2': Gateway, 'lumi.gateway.v3': Gateway, + + 'qmi.powerstrip.v1': PowerStrip, + 'zimi.powerstrip.v2': PowerStrip };