@george.talusan/homebridge-eufy-robovac
Version:
Homebridge Plugin for Eufy Robovac
83 lines • 2.76 kB
JavaScript
export class BaseMatterAccessory {
UUID;
displayName;
deviceType;
serialNumber;
manufacturer;
model;
firmwareRevision;
hardwareRevision;
context;
clusters;
handlers;
parts;
api;
log;
matterReady = false;
constructor(api, log, config) {
this.api = api;
this.log = log;
this.UUID = config.UUID;
this.displayName = config.displayName;
this.deviceType = config.deviceType;
this.serialNumber = config.serialNumber;
this.manufacturer = config.manufacturer;
this.model = config.model;
this.firmwareRevision = config.firmwareRevision;
this.hardwareRevision = config.hardwareRevision;
this.clusters = config.clusters;
this.handlers = config.handlers;
this.parts = config.parts;
this.context = {
serialNumber: this.serialNumber,
manufacturer: this.manufacturer,
model: this.model,
firmwareRevision: this.firmwareRevision,
hardwareRevision: this.hardwareRevision,
...config.context,
};
}
async updateState(cluster, attributes, partId) {
if (!this.matterReady) {
this.log.debug(`[${this.displayName}] Matter not ready, skipping ${cluster} state update`);
return;
}
await this.api.matter.updateAccessoryState(this.UUID, cluster, attributes, partId);
this.log.debug(`[${this.displayName}] Updated ${cluster} state:`, JSON.stringify(attributes));
}
setMatterReady() {
this.matterReady = true;
}
async readState(cluster, partId) {
return await this.api.matter.getAccessoryState(this.UUID, cluster, partId);
}
logInfo(message, ...args) {
this.log.info(`[${this.displayName}] ${message}`, ...args);
}
logError(message, ...args) {
this.log.error(`[${this.displayName}] ${message}`, ...args);
}
logDebug(message, ...args) {
this.log.debug(`[${this.displayName}] ${message}`, ...args);
}
logWarn(message, ...args) {
this.log.warn(`[${this.displayName}] ${message}`, ...args);
}
toAccessory() {
return {
UUID: this.UUID,
displayName: this.displayName,
deviceType: this.deviceType,
serialNumber: this.serialNumber,
manufacturer: this.manufacturer,
model: this.model,
firmwareRevision: this.firmwareRevision,
hardwareRevision: this.hardwareRevision,
context: this.context,
clusters: this.clusters,
handlers: this.handlers,
parts: this.parts,
};
}
}
//# sourceMappingURL=BaseMatterAccessory.js.map