node-miio
Version:
Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more
57 lines (41 loc) • 1.5 kB
Markdown
* **Devices**: No outlets currently supported
* **Model identifiers**: No outlets currently supported
The supported models of power outlets are mapped into a [`power-outlet`][power-outlet] with support for [power switching][switchable-power].
```javascript
if(device.matches('type:power-strip')) {
/*
* This device is a power strip.
*/
}
```
```javascript
// Get if the outlets on the strip have power
device.power()
.then(isOn => console.log('Outlet power:', isOn))
.catch(...);
// Using async/await
console.log('Outlet power:', await device.power());
```
```javascript
// Switch the outlets on
device.setPower(true)
.then(...)
.catch(...)
// Switch on via async/await
await device.power(true);
```
* `device.power()` - get if the outlets currently have power
* `device.power(boolean)` - switch if outlets have power
* `device.setPower(boolean)` - switch if outlets have power
* `device.on(power, isOn => ...)` - listen for power changes
[]: http://abstract-things.readthedocs.io/en/latest/electrical/outlets.html
[]: http://abstract-things.readthedocs.io/en/latest/sensors/index.html
[]: http://abstract-things.readthedocs.io/en/latest/common/power.html
[]: http://abstract-things.readthedocs.io/en/latest/common/switchable-power.html