matterbridge-roborock-vacuum-plugin 1.1.0-rc02 → 1.1.0-rc03
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/initialData/getSupportedAreas.js +2 -1
- package/dist/platform.js +4 -3
- package/dist/rvc.js +1 -0
- package/matterbridge-roborock-vacuum-plugin.config.json +1 -1
- package/matterbridge-roborock-vacuum-plugin.schema.json +1 -1
- package/package.json +1 -1
- package/src/initialData/getSupportedAreas.ts +2 -1
- package/src/platform.ts +13 -3
- package/src/rvc.ts +1 -0
- package/src/tests/initialData/getSupportedAreas.test.ts +27 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { debugStringify } from 'matterbridge/logger';
|
|
2
|
+
import { randomInt } from 'node:crypto';
|
|
2
3
|
export function getSupportedAreas(rooms, roomMap, log) {
|
|
3
4
|
log?.debug('getSupportedAreas', debugStringify(rooms));
|
|
4
5
|
log?.debug('getSupportedAreas', roomMap ? debugStringify(roomMap) : 'undefined');
|
|
@@ -25,7 +26,7 @@ export function getSupportedAreas(rooms, roomMap, log) {
|
|
|
25
26
|
mapId: null,
|
|
26
27
|
areaInfo: {
|
|
27
28
|
locationInfo: {
|
|
28
|
-
locationName: room.displayName ?? rooms.find((r) => r.id == room.globalId)?.name ??
|
|
29
|
+
locationName: room.displayName ?? rooms.find((r) => r.id == room.globalId)?.name ?? `Unknown Room ${randomInt(1000, 9999)}`,
|
|
29
30
|
floorNumber: null,
|
|
30
31
|
areaType: null,
|
|
31
32
|
},
|
package/dist/platform.js
CHANGED
|
@@ -68,8 +68,8 @@ export class RoborockMatterbridgePlatform extends MatterbridgeDynamicPlatform {
|
|
|
68
68
|
if (this.config.whiteList.length > 0) {
|
|
69
69
|
const whiteList = (this.config.whiteList ?? []);
|
|
70
70
|
for (const item of whiteList) {
|
|
71
|
-
const duid = item.split('-')[1];
|
|
72
|
-
const vacuum = devices.find((d) => d.duid
|
|
71
|
+
const duid = item.split('-')[1].trim();
|
|
72
|
+
const vacuum = devices.find((d) => d.duid === duid);
|
|
73
73
|
if (vacuum) {
|
|
74
74
|
vacuums.push(vacuum);
|
|
75
75
|
}
|
|
@@ -134,7 +134,8 @@ export class RoborockMatterbridgePlatform extends MatterbridgeDynamicPlatform {
|
|
|
134
134
|
const roomMap = await this.platformRunner.getRoomMapFromDevice(vacuum);
|
|
135
135
|
this.log.debug('Initializing - roomMap: ', debugStringify(roomMap));
|
|
136
136
|
const behaviorHandler = configurateBehavior(vacuum.data.model, vacuum.duid, this.roborockService, this.cleanModeSettings, this.enableExperimentalFeature?.advancedFeature?.forceRunAtDefault ?? false, this.log);
|
|
137
|
-
|
|
137
|
+
const supportedAreas = getSupportedAreas(vacuum.rooms, roomMap, this.log);
|
|
138
|
+
this.roborockService.setSupportedAreas(vacuum.duid, supportedAreas);
|
|
138
139
|
let routineAsRoom = [];
|
|
139
140
|
if (this.enableExperimentalFeature?.enableExperimentalFeature && this.enableExperimentalFeature.advancedFeature?.showRoutinesAsRoom) {
|
|
140
141
|
routineAsRoom = getSupportedScenes(vacuum.scenes, this.log);
|
package/dist/rvc.js
CHANGED
|
@@ -14,6 +14,7 @@ export class RoborockVacuumCleaner extends RoboticVacuumCleaner {
|
|
|
14
14
|
log.debug(`Creating RoborockVacuumCleaner for device: ${deviceName}, model: ${device.data.model}, forceRunAtDefault: ${enableExperimentalFeature?.advancedFeature?.forceRunAtDefault}`);
|
|
15
15
|
log.debug(`Supported Clean Modes: ${JSON.stringify(cleanModes)}`);
|
|
16
16
|
log.debug(`Supported Run Modes: ${JSON.stringify(supportedRunModes)}`);
|
|
17
|
+
log.debug(`Supported Areas: ${JSON.stringify(supportedAreas)}`);
|
|
17
18
|
const bridgeMode = enableExperimentalFeature?.advancedFeature.enableServerMode ? 'server' : undefined;
|
|
18
19
|
super(deviceName, device.duid, bridgeMode, supportedRunModes[0].mode, supportedRunModes, cleanModes[0].mode, cleanModes, undefined, undefined, RvcOperationalState.OperationalState.Docked, getOperationalStates(), supportedAreas, undefined, supportedAreas[0].areaId);
|
|
19
20
|
this.username = username;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"title": "Matterbridge Roborock Vacuum Plugin",
|
|
3
|
-
"description": "matterbridge-roborock-vacuum-plugin v. 1.1.0-
|
|
3
|
+
"description": "matterbridge-roborock-vacuum-plugin v. 1.1.0-rc03 by https://github.com/RinDevJunior",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"required": [
|
|
6
6
|
"username",
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { AnsiLogger, debugStringify } from 'matterbridge/logger';
|
|
|
2
2
|
import { ServiceArea } from 'matterbridge/matter/clusters';
|
|
3
3
|
import RoomMap from '../model/RoomMap.js';
|
|
4
4
|
import { Room } from '../roborockCommunication/Zmodel/room.js';
|
|
5
|
+
import { randomInt } from 'node:crypto';
|
|
5
6
|
|
|
6
7
|
export function getSupportedAreas(rooms: Room[], roomMap: RoomMap | undefined, log?: AnsiLogger): ServiceArea.Area[] {
|
|
7
8
|
log?.debug('getSupportedAreas', debugStringify(rooms));
|
|
@@ -31,7 +32,7 @@ export function getSupportedAreas(rooms: Room[], roomMap: RoomMap | undefined, l
|
|
|
31
32
|
mapId: null,
|
|
32
33
|
areaInfo: {
|
|
33
34
|
locationInfo: {
|
|
34
|
-
locationName: room.displayName ?? rooms.find((r) => r.id == room.globalId)?.name ??
|
|
35
|
+
locationName: room.displayName ?? rooms.find((r) => r.id == room.globalId)?.name ?? `Unknown Room ${randomInt(1000, 9999)}`,
|
|
35
36
|
floorNumber: null,
|
|
36
37
|
areaType: null,
|
|
37
38
|
},
|
package/src/platform.ts
CHANGED
|
@@ -96,8 +96,8 @@ export class RoborockMatterbridgePlatform extends MatterbridgeDynamicPlatform {
|
|
|
96
96
|
if ((this.config.whiteList as string[]).length > 0) {
|
|
97
97
|
const whiteList = (this.config.whiteList ?? []) as string[];
|
|
98
98
|
for (const item of whiteList) {
|
|
99
|
-
const duid = item.split('-')[1];
|
|
100
|
-
const vacuum = devices.find((d) => d.duid
|
|
99
|
+
const duid = item.split('-')[1].trim();
|
|
100
|
+
const vacuum = devices.find((d) => d.duid === duid);
|
|
101
101
|
if (vacuum) {
|
|
102
102
|
vacuums.push(vacuum);
|
|
103
103
|
}
|
|
@@ -114,6 +114,15 @@ export class RoborockMatterbridgePlatform extends MatterbridgeDynamicPlatform {
|
|
|
114
114
|
if (!this.enableExperimentalFeature || !this.enableExperimentalFeature.advancedFeature.enableServerMode) {
|
|
115
115
|
vacuums = [vacuums[0]]; // If server mode is not enabled, only use the first vacuum
|
|
116
116
|
}
|
|
117
|
+
// else {
|
|
118
|
+
// const cloned = JSON.parse(JSON.stringify(vacuums[0])) as Device;
|
|
119
|
+
// cloned.name = `${cloned.name} Clone`;
|
|
120
|
+
// cloned.serialNumber = `${cloned.serialNumber}-clone`;
|
|
121
|
+
|
|
122
|
+
// vacuums = [...vacuums, cloned]; // If server mode is enabled, add the first vacuum again to ensure it is always included
|
|
123
|
+
// }
|
|
124
|
+
|
|
125
|
+
// this.log.error('Initializing - vacuums: ', debugStringify(vacuums));
|
|
117
126
|
|
|
118
127
|
for (const vacuum of vacuums) {
|
|
119
128
|
await this.roborockService.initializeMessageClient(username, vacuum, userData);
|
|
@@ -192,7 +201,8 @@ export class RoborockMatterbridgePlatform extends MatterbridgeDynamicPlatform {
|
|
|
192
201
|
this.log,
|
|
193
202
|
);
|
|
194
203
|
|
|
195
|
-
|
|
204
|
+
const supportedAreas = getSupportedAreas(vacuum.rooms, roomMap, this.log);
|
|
205
|
+
this.roborockService.setSupportedAreas(vacuum.duid, supportedAreas);
|
|
196
206
|
|
|
197
207
|
let routineAsRoom: ServiceArea.Area[] = [];
|
|
198
208
|
if (this.enableExperimentalFeature?.enableExperimentalFeature && this.enableExperimentalFeature.advancedFeature?.showRoutinesAsRoom) {
|
package/src/rvc.ts
CHANGED
|
@@ -32,6 +32,7 @@ export class RoborockVacuumCleaner extends RoboticVacuumCleaner {
|
|
|
32
32
|
);
|
|
33
33
|
log.debug(`Supported Clean Modes: ${JSON.stringify(cleanModes)}`);
|
|
34
34
|
log.debug(`Supported Run Modes: ${JSON.stringify(supportedRunModes)}`);
|
|
35
|
+
log.debug(`Supported Areas: ${JSON.stringify(supportedAreas)}`);
|
|
35
36
|
|
|
36
37
|
const bridgeMode = enableExperimentalFeature?.advancedFeature.enableServerMode ? 'server' : undefined;
|
|
37
38
|
super(
|
|
@@ -51,4 +51,31 @@ describe('getSupportedAreas', () => {
|
|
|
51
51
|
|
|
52
52
|
expect(result.length).toEqual(8);
|
|
53
53
|
});
|
|
54
|
+
|
|
55
|
+
it('returns default area when rooms and roomMap are empty', () => {
|
|
56
|
+
const result = getSupportedAreas(
|
|
57
|
+
[
|
|
58
|
+
{ id: 11453731, name: 'Living room' },
|
|
59
|
+
{ id: 11453727, name: 'Kitchen' },
|
|
60
|
+
{ id: 11453415, name: 'Bathroom' },
|
|
61
|
+
{ id: 11453409, name: 'Emile’s Room' },
|
|
62
|
+
{ id: 11453404, name: 'Nadia’s Room' },
|
|
63
|
+
{ id: 11453398, name: 'Hallway' },
|
|
64
|
+
{ id: 11453391, name: 'Dining room' },
|
|
65
|
+
{ id: 11453384, name: 'Outside' },
|
|
66
|
+
],
|
|
67
|
+
{
|
|
68
|
+
rooms: [
|
|
69
|
+
{ id: 16, globalId: 2775739, displayName: undefined },
|
|
70
|
+
{ id: 17, globalId: 991195, displayName: undefined },
|
|
71
|
+
{ id: 18, globalId: 991187, displayName: undefined },
|
|
72
|
+
{ id: 19, globalId: 991185, displayName: undefined },
|
|
73
|
+
{ id: 20, globalId: 991190, displayName: undefined },
|
|
74
|
+
],
|
|
75
|
+
} as RoomMap,
|
|
76
|
+
mockLogger as any,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect(result.length).toEqual(5);
|
|
80
|
+
});
|
|
54
81
|
});
|