Implementing lights

Protected methods

setLightState(state)

Set the state of the light. Light capabilities use this as a hook for restoring state. If this is not overriden capabilities implement a default behavior.

Arguments:
  • state (object) – The state to set.
Returns:

Promise that resolves when the state is set.

Example:

Power switching

To support proper restoring of power the implementors of lights should use a custom SwitchablePower:

const { Light, SwitchablePower } = require('abstract-things/lights');

class Example extends Light.with(SwitchablePower) {

  changePower(power) {
    return changePowerOfLight(power);
  }

}