@pietrolubini/homebridge-ecoflow
Version:
Homebridge plugin for EcoFlow devices
33 lines • 1.7 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BatteryStatusService = void 0;
const serviceBase_1 = require("@ecoflow/services/serviceBase");
class BatteryStatusService extends serviceBase_1.ServiceBase {
ecoFlowAccessory;
batteryStatusProvider;
constructor(ecoFlowAccessory, batteryStatusProvider, serviceSubType) {
super(ecoFlowAccessory.platform.Service.Battery, ecoFlowAccessory, serviceSubType);
this.ecoFlowAccessory = ecoFlowAccessory;
this.batteryStatusProvider = batteryStatusProvider;
}
addCharacteristics() {
return [
this.addCharacteristic(this.platform.Characteristic.StatusLowBattery),
this.addCharacteristic(this.platform.Characteristic.BatteryLevel),
this.addCharacteristic(this.platform.Characteristic.ChargingState),
];
}
updateBatteryLevel(batteryLevel, dischargeLimit) {
this.updateCharacteristic(this.platform.Characteristic.BatteryLevel, 'BatteryLevel', batteryLevel);
this.updateStatusLowBattery(batteryLevel, dischargeLimit);
}
updateChargingState(isCharging) {
this.updateCharacteristic(this.platform.Characteristic.ChargingState, 'ChargingState', isCharging);
}
updateStatusLowBattery(batteryLevel, dischargeLimit) {
const statusLowBattery = this.batteryStatusProvider.getStatusLowBattery(this.platform.Characteristic, batteryLevel, dischargeLimit);
this.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, 'StatusLowBattery', statusLowBattery);
}
}
exports.BatteryStatusService = BatteryStatusService;
//# sourceMappingURL=batteryStatusService.js.map