matterbridge-roborock-vacuum-plugin
Version:
Matterbridge Roborock Vacuum Plugin
22 lines (21 loc) • 565 B
JavaScript
export class RoomIndexMap {
indexMap;
roomMap;
constructor(roomMap) {
this.indexMap = roomMap;
this.roomMap = new Map();
for (const [areaId, r] of roomMap.entries()) {
this.roomMap.set(`${r.roomId}:${r.mapId}`, areaId);
}
}
getAreaId(roomId, mapId) {
const areaId = this.roomMap.get(`${roomId}:${mapId}`);
if (areaId === undefined) {
return undefined;
}
return areaId;
}
getRoomId(areaId) {
return this.indexMap.get(areaId)?.roomId;
}
}