UNPKG

homebridge-homewizard-power-consumption

Version:
28 lines (27 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class PowerConsumption { constructor(config, log, api, accessory, device) { this.config = config; this.log = log; this.api = api; this.accessory = accessory; this.device = device; this.Service = this.api.hap.Service; this.Characteristic = this.api.hap.Characteristic; this.accessory.getService(this.Service.AccessoryInformation) .setCharacteristic(this.Characteristic.Manufacturer, 'Homewizard') .setCharacteristic(this.Characteristic.Model, device.product_name) .setCharacteristic(this.Characteristic.SerialNumber, `${device.serial}-power-consumption`); this.powerService = this.accessory.getService(this.Service.LightSensor) || this.accessory.addService(this.Service.LightSensor); } beat(consumption) { const minimumLuxLevel = 0.0001; let newPowerConsumptionLevel = minimumLuxLevel; if (consumption > 0) { newPowerConsumptionLevel = consumption; } this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, newPowerConsumptionLevel); } } exports.default = PowerConsumption;