homebridge#CharacteristicEventTypes TypeScript Examples

The following examples show how to use homebridge#CharacteristicEventTypes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: outlet-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withVoltage(): OutletServiceBuilder {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.OutletInUse)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        this.client.getVoltageState(this.device).catch(e => this.log.error(e.message));
        callback(null, get(this.state, 'voltage', 0) > 0);
      });

    this.service.addOptionalCharacteristic(HAP.CurrentVoltage);

    return this;
  }
Example #2
Source File: humidity-sensor-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withHumidity(): HumiditySensorServiceBuilder {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.CurrentRelativeHumidity)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        callback(null, Math.round(get(this.state, 'humidity', 0)));
      });

    return this;
  }
Example #3
Source File: leak-sensor-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withGasLeak(): LeakSensorServiceBuilder {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.LeakDetected)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        const leakDetected = this.state.gas === true;
        callback(
          null,
          leakDetected
            ? Characteristic.LeakDetected.LEAK_DETECTED
            : Characteristic.LeakDetected.LEAK_NOT_DETECTED
        );
      });

    return this;
  }
Example #4
Source File: leak-sensor-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withSmokeLeak(): LeakSensorServiceBuilder {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.LeakDetected)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        const leakDetected = this.state.smoke === true;
        callback(
          null,
          leakDetected
            ? Characteristic.LeakDetected.LEAK_DETECTED
            : Characteristic.LeakDetected.LEAK_NOT_DETECTED
        );
      });

    return this;
  }
Example #5
Source File: lighbulb-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withOnOff(): LighbulbServiceBuilder {
    const Characteristic = this.Characteristic;

    this.service
      .getCharacteristic(Characteristic.On)
      .on(
        CharacteristicEventTypes.SET,
        async (yes: boolean, callback: CharacteristicSetCallback) => {
          if (this.isOnline) {
            try {
              Object.assign(this.state, await this.client.setOnState(this.device, yes));
              return callback();
            } catch (e) {
              return callback(e);
            }
          } else {
            return callback(new Error('Device is offline'));
          }
        }
      );
    this.service
      .getCharacteristic(Characteristic.On)
      .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
        if (this.isOnline) {
          this.client.getOnOffState(this.device).catch((e) => {
            this.log.error(e.message);
          });
          return callback(null, this.state.state === 'ON');
        } else {
          return callback(new Error('Device is offline'));
        }
      });

    return this;
  }
Example #6
Source File: lighbulb-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withColorTemperature(): LighbulbServiceBuilder {
    const Characteristic = this.Characteristic;
    this.state.color_temp = 140;

    this.service
      .getCharacteristic(Characteristic.ColorTemperature)
      .on(
        CharacteristicEventTypes.SET,
        async (colorTemperature: number, callback: CharacteristicSetCallback) => {
          try {
            if (this.isOnline) {
              Object.assign(
                this.state,
                await this.client.setColorTemperature(this.device, colorTemperature)
              );
              return callback();
            } else {
              return callback(new Error('Device is offline'));
            }
          } catch (e) {
            return callback(e);
          }
        }
      );
    this.service
      .getCharacteristic(Characteristic.ColorTemperature)
      .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
        if (this.isOnline) {
          this.client.getColorTemperature(this.device).catch((e) => this.log.error(e.message));
          this.log.debug(`Reading Color temp for ${this.friendlyName}: ${this.state.color_temp}`);
          return callback(null, get(this.state, 'color_temp', 140));
        } else {
          return callback(new Error('Device is offline'));
        }
      });

    return this;
  }
Example #7
Source File: lighbulb-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
private withSaturation(): LighbulbServiceBuilder {
    const Characteristic = this.platform.Characteristic;
    this.state.color = {
      ...this.state.color,
      s: 100,
    };

    this.service
      .getCharacteristic(Characteristic.Saturation)
      .on(
        CharacteristicEventTypes.SET,
        async (saturation: number, callback: CharacteristicSetCallback) => {
          try {
            if (this.isOnline) {
              await this.client.setSaturation(this.device, saturation);
              return callback();
            } else {
              return callback(new Error('Device is offline'));
            }
          } catch (e) {
            return callback(e);
          }
        }
      );
    this.service
      .getCharacteristic(Characteristic.Saturation)
      .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
        if (this.isOnline) {
          this.log.debug(`Reading Saturation for ${this.friendlyName}: ${this.state.color.s}`);
          this.client.getSaturation(this.device).catch((e) => this.log.error(e.message));
          callback(null, get(this.state, 'color.s', 100));
        } else {
          return callback(new Error('Device is offline'));
        }
      });

    return this;
  }
Example #8
Source File: lock-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withLockState(): LockServiceBuilder {
    const Characteristic = this.platform.Characteristic;
    this.state.state = 'LOCK';

    this.service
      .getCharacteristic(Characteristic.LockTargetState)
      .on(
        CharacteristicEventTypes.SET,
        async (yes: boolean, callback: CharacteristicSetCallback) => {
          try {
            Object.assign(this.state, await this.client.setLockState(this.device, yes));
            callback();
          } catch (e) {
            callback(e);
          }
        }
      );
    this.service
      .getCharacteristic(Characteristic.LockCurrentState)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        try {
          this.client.getLockState(this.device).catch(e => this.log.error(e.message));
          const locked: boolean = this.state.state === 'LOCK' || this.state.lock_state === 'locked';
          const notFullyLocked: boolean = this.state.lock_state === 'not_fully_locked';
          callback(
            null,
            locked
              ? Characteristic.LockCurrentState.SECURED
              : notFullyLocked
              ? Characteristic.LockCurrentState.JAMMED
              : Characteristic.LockCurrentState.UNSECURED
          );
        } catch (e) {
          callback(e);
        }
      });

    return this;
  }
Example #9
Source File: motion-sensor-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withOccupancy(): MotionSensorServiceBuilder {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.MotionDetected)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        this.log.debug(
          `Getting state for motion sensor ${this.friendlyName}: ${this.state.occupancy === true}`
        );
        callback(null, this.state.occupancy === true);
      });

    return this;
  }
Example #10
Source File: outlet-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withOnOff(): OutletServiceBuilder {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.On)
      .on(
        CharacteristicEventTypes.SET,
        async (on: boolean, callback: CharacteristicSetCallback) => {
          try {
            const status = await this.client.setOnState(this.device, on);
            Object.assign(this.state, status);
            callback();
          } catch (e) {
            callback(e);
          }
        }
      );
    this.service
      .getCharacteristic(Characteristic.On)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        this.client.getOnOffState(this.device).catch(e => this.log.error(e.message));
        callback(null, get(this.state, 'state', 'OFF') === 'ON');
      });

    return this;
  }
Example #11
Source File: outlet-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withPower(): OutletServiceBuilder {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.OutletInUse)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        this.client.getPowerState(this.device).catch(e => this.log.error(e.message));
        callback(null, get(this.state, 'power', 0) > 0);
      });

    this.service.addOptionalCharacteristic(HAP.CurrentPowerConsumption);

    return this;
  }
Example #12
Source File: leak-sensor-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withWaterLeak(): LeakSensorServiceBuilder {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.LeakDetected)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        const leakDetected = this.state.water_leak === true;
        callback(
          null,
          leakDetected
            ? Characteristic.LeakDetected.LEAK_DETECTED
            : Characteristic.LeakDetected.LEAK_NOT_DETECTED
        );
      });

    return this;
  }
Example #13
Source File: outlet-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withCurrent(): OutletServiceBuilder {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.OutletInUse)
      .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
        this.client.getCurrentState(this.device).catch(e => this.log.error(e.message));
        callback(null, get(this.state, 'current', 0) > 0);
      });

    this.service.addOptionalCharacteristic(HAP.CurrentConsumption);

    return this;
  }
Example #14
Source File: sensor-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
withBatteryLow() {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.StatusLowBattery)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        callback(
          null,
          this.state.battery_low
            ? Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
            : Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
        );
      });

    return this;
  }
Example #15
Source File: sensor-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
withTamper() {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.StatusTampered)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        callback(
          null,
          this.state.tamper
            ? Characteristic.StatusTampered.TAMPERED
            : Characteristic.StatusTampered.NOT_TAMPERED
        );
      });

    return this;
  }
Example #16
Source File: switch-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withOnOff(): SwitchServiceBuilder {
    const Characteristic = this.platform.Characteristic;

    this.service
      .getCharacteristic(Characteristic.On)
      .on(
        CharacteristicEventTypes.SET,
        async (yes: boolean, callback: CharacteristicSetCallback) => {
          try {
            Object.assign(this.state, await this.client.setOnState(this.device, yes));
            callback();
          } catch (e) {
            callback(e);
          }
        }
      );
    this.service
      .getCharacteristic(Characteristic.On)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        this.client.getOnOffState(this.device).catch(e => this.log.error(e.message));
        callback(null, this.state.state === 'ON');
      });

    return this;
  }
Example #17
Source File: temperature-sensor-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withTemperature(): TemperatureSensorServiceBuilder {
    const Characteristic = this.platform.Characteristic;
    this.state.temperature = 0;

    this.service
      .getCharacteristic(Characteristic.CurrentTemperature)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        callback(null, this.state.temperature);
      });

    return this;
  }
Example #18
Source File: thermostat-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withCurrentHeatingCoolingState(): ThermostatServiceBuilder {
    const Characteristic = this.platform.Characteristic;
    this.service
      .getCharacteristic(Characteristic.CurrentHeatingCoolingState)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        try {
          callback(null, translateCurrentStateFromSystemMode(this.state.system_mode));
        } catch (e) {
          callback(e);
        }
      });

    return this;
  }
Example #19
Source File: thermostat-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withCurrentTemperature(): ThermostatServiceBuilder {
    const Characteristic = this.platform.Characteristic;
    this.service
      .getCharacteristic(Characteristic.CurrentTemperature)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        callback(null, this.state.local_temperature);
      });
    return this;
  }
Example #20
Source File: thermostat-service-builder.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
public withTargetTemperature(min: number, max: number): ThermostatServiceBuilder {
    const Characteristic = this.platform.Characteristic;
    const temperatureFixer = getTemperatureFixer(min, max);
    this.service
      .getCharacteristic(Characteristic.TargetTemperature)
      .on(
        CharacteristicEventTypes.SET,
        async (targetTemp: number, callback: CharacteristicSetCallback) => {
          const temperature = temperatureFixer(targetTemp);
          try {
            Object.assign(
              this.state,
              await this.client.setCurrentHeatingSetpoint(this.device, temperature)
            );
            callback();
          } catch (e) {
            callback(e);
          }
        }
      );
    this.service
      .getCharacteristic(Characteristic.TargetTemperature)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        callback(null, temperatureFixer(this.state.current_heating_setpoint));
      });
    return this;
  }
Example #21
Source File: abstractCharacteristic.ts    From homebridge-lg-thinq-ac with Apache License 2.0 6 votes vote down vote up
constructor(
    platform: HomebridgeLgThinqPlatform,
    service: Service,
    deviceId: string,
    characteristic: Characteristic,
    apiCommand: 'Set' | 'Operation',
    apiDataKey: keyof GetDeviceResponse['result']['snapshot'],
  ) {
    this.platform = platform
    this.service = service
    this.deviceId = deviceId
    this.characteristic = characteristic
    this.apiCommand = apiCommand
    this.apiDataKey = apiDataKey

    if (this.handleSet) {
      // read-only characteristics won't have a handleSet
      this.service
        .getCharacteristic(this.characteristic)
        .on(CharacteristicEventTypes.SET, this.handleSet.bind(this))
    }
  }
Example #22
Source File: ikea-motion-sensor.ts    From homebridge-zigbee-nt with Apache License 2.0 6 votes vote down vote up
getAvailableServices(): Service[] {
    const Service = this.platform.api.hap.Service;
    const Characteristic = this.platform.api.hap.Characteristic;

    this.sensorService =
      this.accessory.getService(Service.MotionSensor) ||
      this.accessory.addService(Service.MotionSensor);
    this.sensorService.setCharacteristic(Characteristic.Name, this.friendlyName);
    this.sensorService
      .getCharacteristic(Characteristic.MotionDetected)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        if (this.state.occupancy) {
          this.log.debug(`Motion detected for sensor ${this.friendlyName}`);
        }
        callback(null, this.state.occupancy === true);
      });

    this.sensorService
      .getCharacteristic(Characteristic.StatusLowBattery)
      .on(CharacteristicEventTypes.GET, async (callback: CharacteristicGetCallback) => {
        callback(
          null,
          this.state.battery && this.state.battery <= 10
            ? Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
            : Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
        );
      });

    this.batteryService =
      this.accessory.getService(Service.BatteryService) ||
      this.accessory.addService(Service.BatteryService);

    return [this.sensorService, this.batteryService];
  }
Example #23
Source File: accessory.ts    From homebridge-nest-cam with GNU General Public License v3.0 6 votes vote down vote up
createSwitchService(
    name: string,
    serviceType: ServiceType,
    _key: keyof Properties,
    cb: (value: CharacteristicValue) => Promise<void>,
  ): void {
    const service = this.createService(serviceType, name);
    this.log.debug(`Creating switch for ${this.accessory.displayName} ${name}.`);
    service
      .setCharacteristic(this.hap.Characteristic.On, this.camera.info.properties[_key])
      .getCharacteristic(this.hap.Characteristic.On)
      .on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {
        cb(value);
        this.log.info(`Setting ${this.accessory.displayName} ${name} to ${value ? 'on' : 'off'}`);
        callback();
      })
      .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
        callback(undefined, this.camera.info.properties[_key]);
      });
  }
Example #24
Source File: wled-accessory.ts    From homebridge-simple-wled with ISC License 6 votes vote down vote up
registerCharacteristicOnOff(): void {

    this.lightService.getCharacteristic(this.hap.Characteristic.On)
      .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
        if (this.debug)
          this.log("Current state of the switch was returned: " + (this.lightOn ? "ON" : "OFF"));

        callback(undefined, this.lightOn);
      })
      .on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {
        let tempLightOn = value as boolean;
        if (tempLightOn && !this.lightOn) {
          this.turnOnWLED();
          if (this.debug)
            this.log("Light was turned on!");
        } else if (!tempLightOn && this.lightOn) {
          this.turnOffWLED();
          if (this.debug)
            this.log("Light was turned off!");
        }
        this.lightOn = tempLightOn;
        callback();
      });

  }
Example #25
Source File: wled-accessory.ts    From homebridge-simple-wled with ISC License 6 votes vote down vote up
registerCharacteristicAmbilightOnOff(): void {

    this.ambilightService.getCharacteristic(this.hap.Characteristic.On)
      .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
        if (this.debug)
          this.log("Current state of the switch was returned: " + (this.ambilightOn ? "ON" : "OFF"));

        callback(undefined, this.ambilightOn);
      })
      .on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {
        this.ambilightOn = value as boolean;
        if (this.ambilightOn) {
          this.turnOnAmbilight();
        } else {
          this.turnOffAmbilight();
        }
        if (this.debug)
          this.log("Switch state was set to: " + (this.ambilightOn ? "ON" : "OFF"));
        callback();
      });

  }
Example #26
Source File: wled-accessory.ts    From homebridge-simple-wled with ISC License 6 votes vote down vote up
registerCharacteristicBrightness(): void {

    this.lightService.getCharacteristic(this.hap.Characteristic.Brightness)
      .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
        if (this.debug)
          this.log("Current brightness: " + this.brightness);
        callback(undefined, this.currentBrightnessToPercent());
      })
      .on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {

        this.brightness = Math.round(255 / 100 * (value as number));
        this.httpSetBrightness();

        if (this.prodLogging)
          this.log("Set brightness to " + value + "% " + this.brightness);

        callback();
      });

    if (this.showEffectControl) {
      // EFFECT SPEED
      this.speedService.getCharacteristic(this.hap.Characteristic.Brightness)
        .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
          callback(undefined, Math.round(this.effectSpeed / 2.55));

        }).on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {

          this.effectSpeed = value as number;
          this.effectSpeed = Math.round(this.effectSpeed * 2.55);
          if (this.prodLogging)
            this.log("Speed set to " + this.effectSpeed);

          this.effectsService.setCharacteristic(this.Characteristic.ActiveIdentifier, this.lastPlayedEffect);

          callback();
        });
    }

  }
Example #27
Source File: wled-accessory.ts    From homebridge-simple-wled with ISC License 6 votes vote down vote up
registerCharacteristicHue(): void {

    this.lightService.getCharacteristic(this.hap.Characteristic.Hue)
      .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
        let colorArray = this.HSVtoRGB(this.hue, this.saturation, this.currentBrightnessToPercent());
        this.colorArray = colorArray;
        if (this.debug)
          this.log("Current hue: " + this.hue + "%");

        callback(undefined, this.hue);
      })
      .on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {

        this.hue = value as number;
        this.turnOffAllEffects();
        let colorArray = this.HSVtoRGB(this.hue, this.saturation, this.currentBrightnessToPercent());

        this.host.forEach((host) => {
          httpSendData(`http://${host}/json`, "POST", { "bri": this.brightness, "seg": [{ "col": [colorArray] }] }, (error: any, response: any) => { if (error) this.log("Error while changing color of WLED " + this.name + " (" + host + ")"); });
          if (this.prodLogging)
            this.log("Changed color to " + colorArray + " on host " + host);
        })
        this.colorArray = colorArray;

        callback();
      });

  }
Example #28
Source File: wled-accessory.ts    From homebridge-simple-wled with ISC License 6 votes vote down vote up
registerCharacteristicSaturation(): void {

    this.lightService.getCharacteristic(this.hap.Characteristic.Saturation)
      .on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
        if (this.debug)
          this.log("Current saturation: " + this.saturation + "%");
        callback(undefined, this.saturation);
      })
      .on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {
        this.saturation = value as number;
        this.turnOffAllEffects();
        callback();
      });

  }
Example #29
Source File: wled-accessory.ts    From homebridge-simple-wled with ISC License 6 votes vote down vote up
registerCharacteristicActive(): void {
    this.effectsService.getCharacteristic(this.Characteristic.Active)
      .on(CharacteristicEventTypes.SET, (newValue: any, callback: any) => {

        if (newValue == 0) {
          if (this.turnOffWledWithEffect) {
            this.turnOffWLED();
          } else {
            this.turnOffAllEffects();
          }
          this.effectsAreActive = false;
        } else {
          if (this.turnOffWledWithEffect) {
            this.turnOnWLED();
          }
          this.effectsAreActive = true;
          this.effectsService.setCharacteristic(this.Characteristic.ActiveIdentifier, this.lastPlayedEffect);
        }

        this.effectsService.updateCharacteristic(this.Characteristic.Active, newValue);
        callback(null);
      });
  }