Skip to content

Latest commit

 

History

History
56 lines (41 loc) · 1.47 KB

power-outlet.md

File metadata and controls

56 lines (41 loc) · 1.47 KB

Power Outlets

  • Devices: No outlets currently supported
  • Model identifiers: No outlets currently supported

The supported models of power outlets are mapped into a power-outlet with support for power switching.

Examples

Check if device is a power strip

if(device.matches('type:power-strip')) {
  /*
   * This device is a power strip.
   */
}

Check if powered on

// 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());

Power on device

// Switch the outlets on
device.setPower(true)
  .then(...)
  .catch(...)

// Switch on via async/await
await device.power(true);

API

  • 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