type:power-plug
- Power plugs¶
Things marked with power-plug
are plugs that can be plugged in to an outlet.
Most plugs are also power outlets in that appliances can be
plugged in to them.
The power and switchable-power capability is commonly used with plugs to switch the power of the outlet of the plug. They can also be sensors if they report power load or power consumption.
if(thing.matches('type:power-plug')) {
// This is a power plug
if(thing.matches('cap:switchable-power')) {
// And it also supports power switching
thing.turnOn()
.then(...)
.catch(...);
}
}
Implementing type¶
const { PowerPlug, PowerOutlet } = require('abstract-things/electrical');
class Example extends PowerPlug.with(PowerOutlet, ...) {
}