- Devices: Mi Smart Socket Plug, Aqara Plug
- Model identifiers:
chuangmi.plug.v1
,chuangmi.plug.v2
,chuangmi.plug.m1
,lumi.plug
The supported models of power plugs are mapped into a power-plug
with support for power switching.
if(device.matches('type:power-strip')) {
/*
* This device is a power strip.
*/
}
// 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());
// Switch the outlets on
device.setPower(true)
.then(...)
.catch(...)
// Switch on via async/await
await device.power(true);
Power - cap:power
and cap:switchable-power
device.power()
- get if the outlets currently have powerdevice.power(boolean)
- switch if outlets have powerdevice.setPower(boolean)
- switch if outlets have powerdevice.on(power, isOn => ...)
- listen for power changes
The V1 plug has a USB-outlet that can be controlled individually. It is made available as a child that implements power switching:
const usbOutlet = light.child('usb');
const isOn = await usbOutlet.power();