matterbridge-roborock-vacuum-plugin
Version:
Matterbridge Roborock Vacuum Plugin
23 lines (22 loc) • 694 B
JavaScript
import { Behavior } from 'matterbridge/matter';
export class BehaviorDeviceGeneric {
log;
commands = {};
constructor(log) {
this.log = log;
}
setCommandHandler(command, handler) {
if (this.commands[command])
throw new Error(`Handler already registered for command ${String(command)}`);
this.commands[command] = handler;
}
async executeCommand(command, ...args) {
const handler = this.commands[command];
if (!handler)
throw new Error(`${String(command)} not implemented`);
await handler(...args);
}
}
export class BehaviorRoborock extends Behavior {
static id = 'roborock.vacuum.axx';
}