matterbridge-roborock-vacuum-plugin 1.1.0-rc17 → 1.1.1-rc01

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.
Files changed (34) hide show
  1. package/dist/helper.js +2 -7
  2. package/dist/initialData/getSupportedAreas.js +1 -1
  3. package/dist/model/RoomMap.js +1 -1
  4. package/dist/model/roomIndexMap.js +8 -4
  5. package/dist/platform.js +4 -3
  6. package/dist/platformRunner.js +10 -266
  7. package/dist/runtimes/handleCloudMessage.js +110 -0
  8. package/dist/runtimes/handleHomeDataMessage.js +57 -0
  9. package/dist/runtimes/handleLocalMessage.js +169 -0
  10. package/dist/tests/testData/mockData.js +359 -0
  11. package/matterbridge-roborock-vacuum-plugin.config.json +2 -2
  12. package/matterbridge-roborock-vacuum-plugin.schema.json +10 -37
  13. package/package.json +2 -2
  14. package/src/behaviors/roborock.vacuum/default/runtimes.ts +1 -1
  15. package/src/behaviors/roborock.vacuum/smart/runtimes.ts +1 -1
  16. package/src/helper.ts +2 -12
  17. package/src/initialData/getSupportedAreas.ts +2 -10
  18. package/src/model/RoomMap.ts +4 -30
  19. package/src/model/roomIndexMap.ts +10 -6
  20. package/src/platform.ts +6 -3
  21. package/src/platformRunner.ts +12 -349
  22. package/src/roborockCommunication/Zmodel/device.ts +13 -1
  23. package/src/roborockCommunication/Zmodel/messageResult.ts +28 -27
  24. package/src/roborockCommunication/Zmodel/userData.ts +2 -1
  25. package/src/runtimes/handleCloudMessage.ts +134 -0
  26. package/src/runtimes/handleHomeDataMessage.ts +67 -0
  27. package/src/runtimes/handleLocalMessage.ts +209 -0
  28. package/src/share/runtimeHelper.ts +1 -1
  29. package/src/tests/helper.test.ts +59 -10
  30. package/src/tests/roborockService.setSelectedAreas.test.ts +61 -0
  31. package/src/tests/runtimes/handleCloudMessage.test.ts +200 -0
  32. package/src/tests/runtimes/handleHomeDataMessage.test.ts +53 -0
  33. package/src/tests/runtimes/handleLocalMessage.test.ts +222 -0
  34. package/src/tests/testData/mockData.ts +370 -0
@@ -0,0 +1,370 @@
1
+ import { ServiceArea } from 'matterbridge/matter/clusters';
2
+ import { Home, MapInfo } from '../../roborockCommunication/index.js';
3
+ import { CloudMessageResult } from '../../roborockCommunication/Zmodel/messageResult.js';
4
+
5
+ export const supportedAreas: ServiceArea.Area[] = [
6
+ { areaId: 100, mapId: 0, areaInfo: { locationInfo: { locationName: 'Kitchen', floorNumber: 0, areaType: null }, landmarkInfo: null } },
7
+ { areaId: 101, mapId: 0, areaInfo: { locationInfo: { locationName: 'Study', floorNumber: 0, areaType: null }, landmarkInfo: null } },
8
+ { areaId: 102, mapId: 0, areaInfo: { locationInfo: { locationName: 'Living room', floorNumber: 0, areaType: null }, landmarkInfo: null } },
9
+ { areaId: 103, mapId: 0, areaInfo: { locationInfo: { locationName: 'Bedroom', floorNumber: 0, areaType: null }, landmarkInfo: null } },
10
+ { areaId: 104, mapId: 1, areaInfo: { locationInfo: { locationName: 'Living room', floorNumber: 1, areaType: null }, landmarkInfo: null } },
11
+ { areaId: 105, mapId: 1, areaInfo: { locationInfo: { locationName: 'Guest bedroom', floorNumber: 1, areaType: null }, landmarkInfo: null } },
12
+ { areaId: 106, mapId: 1, areaInfo: { locationInfo: { locationName: 'Master bedroom', floorNumber: 1, areaType: null }, landmarkInfo: null } },
13
+ { areaId: 107, mapId: 1, areaInfo: { locationInfo: { locationName: 'Balcony', floorNumber: 1, areaType: null }, landmarkInfo: null } },
14
+ ];
15
+
16
+ export const supportedMaps: ServiceArea.Map[] = [
17
+ { mapId: 0, name: 'First Map' },
18
+ { mapId: 1, name: 'Second Map' },
19
+ ];
20
+
21
+ export const roomIndexMap = {
22
+ indexMap: new Map([
23
+ [100, { roomId: 1, mapId: 0 }],
24
+ [101, { roomId: 2, mapId: 0 }],
25
+ [102, { roomId: 3, mapId: 0 }],
26
+ [103, { roomId: 4, mapId: 0 }],
27
+ [104, { roomId: 1, mapId: 1 }],
28
+ [105, { roomId: 2, mapId: 1 }],
29
+ [106, { roomId: 3, mapId: 1 }],
30
+ [107, { roomId: 4, mapId: 1 }],
31
+ ]),
32
+ roomMap: new Map([
33
+ [1, 104],
34
+ [2, 105],
35
+ [3, 106],
36
+ [4, 107],
37
+ ]),
38
+ };
39
+
40
+ export const mapInfo = new MapInfo({
41
+ max_multi_map: 1,
42
+ max_bak_map: 1,
43
+ multi_map_count: 1,
44
+ map_info: [
45
+ {
46
+ mapFlag: 0,
47
+ add_time: 1753511673,
48
+ length: 9,
49
+ name: 'First Map',
50
+ bak_maps: [{ mapFlag: 4, add_time: 1753578164 }],
51
+ rooms: [
52
+ { id: 1, tag: 14, iot_name_id: '11100845', iot_name: 'Kitchen' },
53
+ { id: 2, tag: 9, iot_name_id: '11100849', iot_name: 'Study' },
54
+ {
55
+ id: 3,
56
+ tag: 6,
57
+ iot_name_id: '11100842',
58
+ iot_name: 'Living room',
59
+ },
60
+ { id: 4, tag: 1, iot_name_id: '11100847', iot_name: 'Bedroom' },
61
+ ],
62
+ },
63
+ {
64
+ mapFlag: 1,
65
+ add_time: 1753579596,
66
+ length: 10,
67
+ name: 'Second Map',
68
+ bak_maps: [{ mapFlag: 5, add_time: 1753578579 }],
69
+ rooms: [
70
+ {
71
+ id: 1,
72
+ tag: 6,
73
+ iot_name_id: '11100842',
74
+ iot_name: 'Living room',
75
+ },
76
+ {
77
+ id: 2,
78
+ tag: 3,
79
+ iot_name_id: '12461114',
80
+ iot_name: 'Guest bedroom',
81
+ },
82
+ {
83
+ id: 3,
84
+ tag: 2,
85
+ iot_name_id: '12461109',
86
+ iot_name: 'Master bedroom',
87
+ },
88
+ { id: 4, tag: 7, iot_name_id: '12461111', iot_name: 'Balcony' },
89
+ ],
90
+ },
91
+ ],
92
+ });
93
+
94
+ export const roomData = [
95
+ [1, '11100845', 14],
96
+ [2, '11100849', 9],
97
+ [3, '11100842', 6],
98
+ [4, '11100847', 1],
99
+ ];
100
+
101
+ export const cloudMessageResult1: CloudMessageResult = {
102
+ msg_ver: 2,
103
+ msg_seq: 424,
104
+ state: 5,
105
+ battery: 100,
106
+ clean_time: 2823,
107
+ clean_area: 36002500,
108
+ error_code: 0,
109
+ map_present: 1,
110
+ in_cleaning: 0,
111
+ in_returning: 0,
112
+ in_fresh_state: 1,
113
+ lab_status: 3,
114
+ water_box_status: 1,
115
+ back_type: -1,
116
+ wash_phase: 0,
117
+ wash_ready: 1,
118
+ wash_status: 0,
119
+ fan_power: 110,
120
+ dnd_enabled: 0,
121
+ map_status: 3,
122
+ is_locating: 0,
123
+ lock_status: 0,
124
+ water_box_mode: 209,
125
+ distance_off: 155,
126
+ water_box_carriage_status: 1,
127
+ mop_forbidden_enable: 1,
128
+ camera_status: 1,
129
+ is_exploring: 0,
130
+ adbumper_status: [0, 0, 0],
131
+ water_shortage_status: 0,
132
+ dock_type: 14,
133
+ dust_collection_status: 0,
134
+ auto_dust_collection: 1,
135
+ avoid_count: 209,
136
+ mop_mode: 306,
137
+ debug_mode: 0,
138
+ in_warmup: 0,
139
+ collision_avoid_status: 1,
140
+ switch_map_mode: 1,
141
+ dock_error_status: 0,
142
+ charge_status: 1,
143
+ unsave_map_reason: 0,
144
+ unsave_map_flag: -1,
145
+ dry_status: 0,
146
+ rdt: 0,
147
+ clean_percent: 0,
148
+ extra_time: 860,
149
+ rss: 2,
150
+ dss: 168,
151
+ common_status: 2,
152
+ last_clean_t: 1754063701,
153
+ replenish_mode: 0,
154
+ repeat: 1,
155
+ kct: 0,
156
+ subdivision_sets: 0,
157
+ cleaning_info: { target_segment_id: -1, segment_id: 3, fan_power: 102, water_box_status: 202, mop_mode: 306 },
158
+ exit_dock: 0,
159
+ seq_type: 0,
160
+ };
161
+
162
+ export const cloudMessageResult2: CloudMessageResult = {
163
+ msg_ver: 2,
164
+ msg_seq: 424,
165
+ state: 5,
166
+ battery: 100,
167
+ clean_time: 2823,
168
+ clean_area: 36002500,
169
+ error_code: 0,
170
+ map_present: 1,
171
+ in_cleaning: 0,
172
+ in_returning: 0,
173
+ in_fresh_state: 1,
174
+ lab_status: 3,
175
+ water_box_status: 1,
176
+ back_type: -1,
177
+ wash_phase: 0,
178
+ wash_ready: 1,
179
+ wash_status: 0,
180
+ fan_power: 110,
181
+ dnd_enabled: 0,
182
+ map_status: 3,
183
+ is_locating: 0,
184
+ lock_status: 0,
185
+ water_box_mode: 209,
186
+ distance_off: 155,
187
+ water_box_carriage_status: 1,
188
+ mop_forbidden_enable: 1,
189
+ camera_status: 1,
190
+ is_exploring: 0,
191
+ adbumper_status: [0, 0, 0],
192
+ water_shortage_status: 0,
193
+ dock_type: 14,
194
+ dust_collection_status: 0,
195
+ auto_dust_collection: 1,
196
+ avoid_count: 209,
197
+ mop_mode: 306,
198
+ debug_mode: 0,
199
+ in_warmup: 0,
200
+ collision_avoid_status: 1,
201
+ switch_map_mode: 1,
202
+ dock_error_status: 0,
203
+ charge_status: 1,
204
+ unsave_map_reason: 0,
205
+ unsave_map_flag: -1,
206
+ dry_status: 0,
207
+ rdt: 0,
208
+ clean_percent: 0,
209
+ extra_time: 860,
210
+ rss: 2,
211
+ dss: 168,
212
+ common_status: 2,
213
+ last_clean_t: 1754063701,
214
+ replenish_mode: 0,
215
+ repeat: 1,
216
+ kct: 0,
217
+ subdivision_sets: 0,
218
+ cleaning_info: { target_segment_id: 4, segment_id: -1, fan_power: 102, water_box_status: 202, mop_mode: 306 },
219
+ exit_dock: 0,
220
+ seq_type: 0,
221
+ };
222
+
223
+ export const cloudMessageResult3: CloudMessageResult = {
224
+ msg_ver: 2,
225
+ msg_seq: 1579,
226
+ state: 5,
227
+ battery: 94,
228
+ clean_time: 567,
229
+ clean_area: 36002500,
230
+ error_code: 0,
231
+ map_present: 1,
232
+ in_cleaning: 0,
233
+ in_returning: 0,
234
+ in_fresh_state: 1,
235
+ lab_status: 3,
236
+ water_box_status: 1,
237
+ fan_power: 104,
238
+ dnd_enabled: 0,
239
+ map_status: 3,
240
+ is_locating: 0,
241
+ lock_status: 0,
242
+ water_box_mode: 202,
243
+ distance_off: 60,
244
+ water_box_carriage_status: 0,
245
+ mop_forbidden_enable: 0,
246
+ adbumper_status: [0, 0, 0],
247
+ dock_type: 5,
248
+ dust_collection_status: 0,
249
+ auto_dust_collection: 1,
250
+ debug_mode: 0,
251
+ switch_map_mode: 0,
252
+ dock_error_status: 0,
253
+ charge_status: 1,
254
+ };
255
+
256
+ export const homeData: Home = {
257
+ id: 3645093,
258
+ name: 'My Home',
259
+ products: [
260
+ {
261
+ id: '2CjvhDFL7Q9NdJQmhE86zn',
262
+ name: 'Roborock Qrevo Edge Series',
263
+ model: 'test-model',
264
+ category: 'robot.vacuum.cleaner',
265
+ schema: [
266
+ { id: 101, name: 'rpc_request', code: 'rpc_request', mode: 'rw', type: 'RAW', property: null },
267
+ { id: 102, name: 'rpc_response', code: 'rpc_response', mode: 'rw', type: 'RAW', property: null },
268
+ { id: 120, name: '错误代码', code: 'error_code', mode: 'ro', type: 'ENUM', property: '{"range": [""]}' },
269
+ { id: 121, name: '设备状态', code: 'state', mode: 'ro', type: 'ENUM', property: '{"range": [""]}' },
270
+ { id: 122, name: '设备电量', code: 'battery', mode: 'ro', type: 'ENUM', property: '{"range": [""]}' },
271
+ { id: 123, name: '清扫模式', code: 'fan_power', mode: 'rw', type: 'ENUM', property: '{"range": [""]}' },
272
+ { id: 124, name: '拖地模式', code: 'water_box_mode', mode: 'rw', type: 'ENUM', property: '{"range": [""]}' },
273
+ { id: 125, name: '主刷寿命', code: 'main_brush_life', mode: 'rw', type: 'VALUE', property: '{"max": 100, "min": 0, "step": 1, "unit": "null", "scale": 1}' },
274
+ { id: 126, name: '边刷寿命', code: 'side_brush_life', mode: 'rw', type: 'VALUE', property: '{"max": 100, "min": 0, "step": 1, "unit": "null", "scale": 1}' },
275
+ { id: 127, name: '滤网寿命', code: 'filter_life', mode: 'rw', type: 'VALUE', property: '{"max": 100, "min": 0, "step": 1, "unit": "null", "scale": 1}' },
276
+ { id: 128, name: '额外状态', code: 'additional_props', mode: 'ro', type: 'RAW', property: null },
277
+ { id: 130, name: '完成事件', code: 'task_complete', mode: 'ro', type: 'RAW', property: null },
278
+ { id: 131, name: '电量不足任务取消', code: 'task_cancel_low_power', mode: 'ro', type: 'RAW', property: null },
279
+ { id: 132, name: '运动中任务取消', code: 'task_cancel_in_motion', mode: 'ro', type: 'RAW', property: null },
280
+ { id: 133, name: '充电状态', code: 'charge_status', mode: 'ro', type: 'RAW', property: null },
281
+ { id: 134, name: '烘干状态', code: 'drying_status', mode: 'ro', type: 'RAW', property: null },
282
+ { id: 135, name: '离线原因细分', code: 'offline_status', mode: 'ro', type: 'RAW', property: null },
283
+ { id: 139, name: '回基站目的', code: 'back_type', mode: 'ro', type: 'RAW', property: null },
284
+ ],
285
+ },
286
+ ],
287
+ devices: [
288
+ {
289
+ duid: 'test-duid',
290
+ name: 'Roborock Qrevo Edge 5V1',
291
+ activeTime: 1749443275,
292
+ createTime: 1746940587,
293
+ localKey: 'v0OKpWXwBmiCk4ku',
294
+ productId: '2CjvhDFL7Q9NdJQmhE86zn',
295
+ online: true,
296
+ fv: '02.28.34',
297
+ pv: '1.0',
298
+ sn: 'RCIEBS50900224',
299
+ featureSet: '2247397454282751',
300
+ newFeatureSet: '00040040282834C9C2FA8F5C7EDEFFFE',
301
+ deviceStatus: { 120: 0, 121: 8, 122: 100, 123: 110, 124: 209, 125: 93, 126: 69, 127: 86, 128: 0, 133: 1, 134: 0, 135: 0, 139: 0 },
302
+ silentOtaSwitch: true,
303
+ rrHomeId: 3645093,
304
+ rooms: [
305
+ { id: 11100849, name: 'Study' },
306
+ { id: 11100847, name: 'Bedroom' },
307
+ { id: 11100845, name: 'Kitchen' },
308
+ { id: 11100842, name: 'Living room' },
309
+ ],
310
+ serialNumber: 'RCIEBS50900224',
311
+ data: {
312
+ id: 'test-duid',
313
+ firmwareVersion: '02.28.34',
314
+ serialNumber: 'RCIEBS50900224',
315
+ model: 'test-model',
316
+ category: 'robot.vacuum.cleaner',
317
+ batteryLevel: 100,
318
+ },
319
+ store: {
320
+ userData: {
321
+ uid: 3635748,
322
+ tokentype: '',
323
+ token: 'rr65af7107da5840:txP8ZF7dj8v7xUMkoFMzZA==:01981b12f83a7723a1cbef8c8e89a7e1',
324
+ rruid: 'rr65af7107da5840',
325
+ region: 'us',
326
+ countrycode: '84',
327
+ country: 'VN',
328
+ nickname: 'Ryan',
329
+ rriot: {
330
+ u: '6BtaRwE14spvanEazqX0kQ',
331
+ s: 'OsErWk',
332
+ h: '195Xn4u3fe',
333
+ k: 'ofKw7nJc',
334
+ r: { r: 'US', a: 'https://api-us.roborock.com', m: 'ssl://mqtt-us-2.roborock.com:8883', l: 'https://wood-us.roborock.com' },
335
+ },
336
+ },
337
+ localKey: 'v0OKpWXwBmiCk4ku',
338
+ pv: '1.0',
339
+ model: 'test-model',
340
+ },
341
+ schema: [
342
+ { id: 101, name: 'rpc_request', code: 'rpc_request', mode: 'rw', type: 'RAW', property: null },
343
+ { id: 102, name: 'rpc_response', code: 'rpc_response', mode: 'rw', type: 'RAW', property: null },
344
+ { id: 120, name: '错误代码', code: 'error_code', mode: 'ro', type: 'ENUM', property: '{"range": [""]}' },
345
+ { id: 121, name: '设备状态', code: 'state', mode: 'ro', type: 'ENUM', property: '{"range": [""]}' },
346
+ { id: 122, name: '设备电量', code: 'battery', mode: 'ro', type: 'ENUM', property: '{"range": [""]}' },
347
+ { id: 123, name: '清扫模式', code: 'fan_power', mode: 'rw', type: 'ENUM', property: '{"range": [""]}' },
348
+ { id: 124, name: '拖地模式', code: 'water_box_mode', mode: 'rw', type: 'ENUM', property: '{"range": [""]}' },
349
+ { id: 125, name: '主刷寿命', code: 'main_brush_life', mode: 'rw', type: 'VALUE', property: '{"max": 100, "min": 0, "step": 1, "unit": "null", "scale": 1}' },
350
+ { id: 126, name: '边刷寿命', code: 'side_brush_life', mode: 'rw', type: 'VALUE', property: '{"max": 100, "min": 0, "step": 1, "unit": "null", "scale": 1}' },
351
+ { id: 127, name: '滤网寿命', code: 'filter_life', mode: 'rw', type: 'VALUE', property: '{"max": 100, "min": 0, "step": 1, "unit": "null", "scale": 1}' },
352
+ { id: 128, name: '额外状态', code: 'additional_props', mode: 'ro', type: 'RAW', property: null },
353
+ { id: 130, name: '完成事件', code: 'task_complete', mode: 'ro', type: 'RAW', property: null },
354
+ { id: 131, name: '电量不足任务取消', code: 'task_cancel_low_power', mode: 'ro', type: 'RAW', property: null },
355
+ { id: 132, name: '运动中任务取消', code: 'task_cancel_in_motion', mode: 'ro', type: 'RAW', property: null },
356
+ { id: 133, name: '充电状态', code: 'charge_status', mode: 'ro', type: 'RAW', property: null },
357
+ { id: 134, name: '烘干状态', code: 'drying_status', mode: 'ro', type: 'RAW', property: null },
358
+ { id: 135, name: '离线原因细分', code: 'offline_status', mode: 'ro', type: 'RAW', property: null },
359
+ { id: 139, name: '回基站目的', code: 'back_type', mode: 'ro', type: 'RAW', property: null },
360
+ ],
361
+ },
362
+ ],
363
+ receivedDevices: [],
364
+ rooms: [
365
+ { id: 11100849, name: 'Study' },
366
+ { id: 11100847, name: 'Bedroom' },
367
+ { id: 11100845, name: 'Kitchen' },
368
+ { id: 11100842, name: 'Living room' },
369
+ ],
370
+ };