UNPKG

@pietrolubini/homebridge-ecoflow

Version:
41 lines 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SimulatorTyped = exports.Simulator = void 0; const characteristicContracts_1 = require("@ecoflow/characteristics/characteristicContracts"); class Simulator { generateStatus() { const status = { id: `${Math.floor(Math.random() * 1000000)}`, version: '1.0', timestamp: Date.now(), params: { status: this.getRandomBoolean() ? characteristicContracts_1.EnableType.On : characteristicContracts_1.EnableType.Off, }, }; return status; } getRandomNumber(min, max) { return Math.random() * (max - min) + min; } getRandomBoolean() { return Math.random() < 0.5; } } exports.Simulator = Simulator; class SimulatorTyped extends Simulator { generateSetReply(message) { const msgObj = JSON.parse(message); return this.generateSetReplyTyped(msgObj); } getRandomNumber(min, max) { return Math.random() * (max - min) + min; } getRandomInt(min, max) { return Math.round(this.getRandomNumber(min, max)); } getRandomBoolean() { return Math.random() < 0.5; } } exports.SimulatorTyped = SimulatorTyped; //# sourceMappingURL=simulator.js.map