UNPKG

homebridge-blynk-plugin

Version:

Based on Peter J Wojciechowski but updated to use the new API

40 lines 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlynkPoller = void 0; class BlynkPoller { constructor(log, seconds, accessories) { this.oneAtAtime = false; this.stopPoller = false; this.log = log; this.pollerMilliSeconds = seconds * 1000; this.accessories = accessories; } setPollSeconds(seconds) { this.pollerMilliSeconds = seconds * 1000; } setPollerAccessoryList(accessories) { this.accessories.length = 0; this.accessories = accessories; this.log.debug(`Poller will refresh setting for ${accessories.length} item(s).`); return this; } shutdown() { this.log.info(`Poller: Asked to shutdown`); this.stopPoller = true; } poll() { if (!this.oneAtAtime) { this.oneAtAtime = true; this.accessories.forEach(accessory => { accessory.getStatus(); }); if (!this.stopPoller) { setTimeout(() => { this.poll(); }, this.pollerMilliSeconds); } else { this.log.info(`Last poller execution due to ask to shutdown.`); } this.oneAtAtime = false; } } } exports.BlynkPoller = BlynkPoller; //# sourceMappingURL=poller.js.map