UNPKG

homebridge-omnik

Version:
26 lines (25 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class TotalYield { 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, 'Omnik') .setCharacteristic(this.Characteristic.Model, device.name) .setCharacteristic(this.Characteristic.SerialNumber, `${device.serial}-total-yield`); this.powerService = this.accessory.getService(this.Service.LightSensor) || this.accessory.addService(this.Service.LightSensor); } beat(powerProduction) { const minimumValue = 0.0001; const consumption = powerProduction.total / 10; const newValue = consumption > minimumValue ? consumption : minimumValue; this.powerService.setCharacteristic(this.Characteristic.CurrentAmbientLightLevel, newValue); } } exports.default = TotalYield;