matterbridge-roborock-vacuum-plugin
Version:
Matterbridge Roborock Vacuum Plugin
22 lines (21 loc) • 577 B
JavaScript
export class RoomIndexMap {
indexMap;
roomMap;
constructor(roomMap) {
this.indexMap = roomMap;
this.roomMap = new Map();
for (const [areaId, { roomId, mapId }] of roomMap.entries()) {
this.roomMap.set(`${roomId}:${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;
}
}