matterbridge-roborock-vacuum-plugin
Version:
Matterbridge Roborock Vacuum Plugin
34 lines • 1.09 kB
JavaScript
import { Behavior } from 'matterbridge/matter';
// Command names as constants to avoid typos and improve maintainability
// Shared across all device types (default, type1, type2, etc.)
export const CommandNames = {
IDENTIFY: 'identify',
SELECT_AREAS: 'selectAreas',
CHANGE_TO_MODE: 'changeToMode',
PAUSE: 'pause',
RESUME: 'resume',
GO_HOME: 'goHome',
STOP: 'stop',
};
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';
}
//# sourceMappingURL=BehaviorDeviceGeneric.js.map