UNPKG

@pietrolubini/homebridge-ecoflow

Version:
74 lines 3.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeltaPro3Simulator = void 0; const deltaPro3HttpApiContracts_1 = require("@ecoflow/accessories/batteries/deltapro3/interfaces/deltaPro3HttpApiContracts"); const batteryHttpApiContracts_1 = require("@ecoflow/accessories/batteries/interfaces/batteryHttpApiContracts"); const simulator_1 = require("@ecoflow/apis/simulations/simulator"); class DeltaPro3Simulator extends simulator_1.SimulatorTyped { generateQuota() { const quota = { cmsBattSoc: this.getRandomNumber(0, 100), cmsMinDsgSoc: this.getRandomNumber(0, 20), flowInfo12v: this.getRandomBoolean() ? deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.On : deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.Off, flowInfoAcHvOut: this.getRandomBoolean() ? deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.On : deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.Off, flowInfoAcLvOut: this.getRandomBoolean() ? deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.On : deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.Off, powGet12v: -this.getRandomNumber(0, 100), powGetAc: -this.getRandomNumber(0, 1000), powGetAcHvOut: -this.getRandomNumber(0, 1000), powGetAcLvOut: -this.getRandomNumber(0, 1000), powGetQcusb1: -this.getRandomNumber(0, 100), powGetQcusb2: -this.getRandomNumber(0, 100), powGetTypec1: -this.getRandomNumber(0, 100), powGetTypec2: -this.getRandomNumber(0, 100), inputWatts: this.getRandomNumber(0, 1000), outputWatts: this.getRandomNumber(0, 1000), xboostEn: this.getRandomBoolean() ? batteryHttpApiContracts_1.AcXBoostType.On : batteryHttpApiContracts_1.AcXBoostType.Off, }; return quota; } generateSetReplyTyped(message) { const reply = { id: message.id, version: message.version, code: '0', message: 'Success', eagleEyeTraceId: '', tid: '', data: { configOk: true, actionId: Math.round(this.getRandomNumber(0, 100)), }, }; if (this.castParams(message.params).cfgHvAcOutOpen !== undefined) { this.castData(reply.data).flowInfoAcHvOut = this.castParams(message.params).cfgHvAcOutOpen ? deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.On : deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.Off; } else if (this.castParams(message.params).cfgLvAcOutOpen !== undefined) { this.castData(reply.data).flowInfoAcLvOut = this.castParams(message.params).cfgLvAcOutOpen ? deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.On : deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.Off; } else if (this.castParams(message.params).cfgDc12vOutOpen !== undefined) { this.castData(reply.data).flowInfo12v = this.castParams(message.params).cfgDc12vOutOpen ? deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.On : deltaPro3HttpApiContracts_1.DeltaPro3AcEnableType.Off; } else if (this.castParams(message.params).cfgXboostEn !== undefined) { this.castData(reply.data).xboostEn = this.castParams(message.params).cfgXboostEn; } return reply; } castData(data) { return data; } castParams(params) { return params; } } exports.DeltaPro3Simulator = DeltaPro3Simulator; //# sourceMappingURL=deltaPro3Simulator.js.map