UNPKG

matterbridge-dyson-robot

Version:

A Matterbridge plugin that connects Dyson robot vacuums and air treatment devices to the Matter smart home ecosystem via their local or cloud MQTT APIs.

36 lines 1.21 kB
// Matterbridge plugin for Dyson robot vacuum and air treatment devices // Copyright © 2025-2026 Alexander Thoukydides import EventEmitter from 'events'; // Cache version const MQTT_CACHE_VERSION = 1; // Cache Dyson MQTT status to allow start-up when device is offline export class DysonMqttCache extends EventEmitter { log; persist; serialNumber; // Create a new MQTT cache constructor(log, persist, serialNumber) { super({ captureRejections: true }); this.log = log; this.persist = persist; this.serialNumber = serialNumber; // Attempt to restore any previously cached status void this.restore(); } // Construct a persistent storage key for the cache get key() { return `mqtt-cache-v${MQTT_CACHE_VERSION}:${this.serialNumber}`; } // Retrieve the cached status, if any async restore() { const status = await this.persist.getItem(this.key); if (!status) return; this.emit('restored', status); } // Store the current status in the cache async store(status) { await this.persist.setItem(this.key, status); } } //# sourceMappingURL=dyson-mqtt-cache.js.map