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.
46 lines • 1.63 kB
JavaScript
// Matterbridge plugin for Dyson robot vacuum and air treatment devices
// Copyright © 2025 Alexander Thoukydides
import { Changed } from './decorator-changed.js';
import { createHash } from 'crypto';
// A Dyson robot vacuum or air treatment device
export class DysonDevice {
log;
config;
device;
mqtt;
// Details of the device model
static model;
static filters;
// MQTT client constructor
static mqttConstructor;
// Decorator support
changed;
// Construct a new Dyson device instance
constructor(log, config, device, mqtt) {
this.log = log;
this.config = config;
this.device = device;
this.mqtt = mqtt;
// Prepare the decorator support
this.changed = new Changed(log);
}
// Stop the device when Matterbridge is shutting down
async stop() {
await this.mqtt.stop();
}
// Use the serial number to generate a 32-character opaque unique ID
get uniqueId() {
const hash = createHash('sha256').update(this.serialNumber).digest('hex');
const model = this.modelNumber.replace(/.*\//, '').toLowerCase();
return `dyson-${model}-${hash}`.substring(0, 32);
}
// Retrieve the static data for an instance
get classStatic() { return this.constructor; }
get modelName() { return this.classStatic.model.name; }
get modelNumber() { return this.classStatic.model.number; }
// Retrieve common per-device data
get deviceName() { return this.device.name; }
get serialNumber() { return this.device.serialNumber; }
}
;
//# sourceMappingURL=dyson-device-base.js.map