UNPKG

matterbridge-roborock-vacuum-plugin

Version:
31 lines 1.12 kB
import { randomInt } from 'node:crypto'; import { debugStringify } from 'matterbridge/logger'; import { SCENE_AREA_ID_MAX, SCENE_AREA_ID_MIN } from '../constants/index.js'; /** * Convert Roborock routines to Matter ServiceArea areas. */ export function getSupportedRoutines(routines, log) { log?.debug('getSupportedRoutines', debugStringify(routines)); if (!routines || routines.length === 0) { log?.debug('No routine found'); return []; } const supportedRoutines = routines .filter((s) => s.enabled && s.name) .map((routine, index) => { return { areaId: routine.id != null ? SCENE_AREA_ID_MIN + routine.id : randomInt(SCENE_AREA_ID_MIN, SCENE_AREA_ID_MAX), mapId: null, areaInfo: { locationInfo: { locationName: routine.name ?? `Routine ${index}`, floorNumber: null, areaType: null, }, landmarkInfo: null, }, }; }); return supportedRoutines; } //# sourceMappingURL=getSupportedRoutines.js.map