matterbridge-roborock-vacuum-plugin 1.0.5

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 (170) hide show
  1. package/.github/workflows/publish.yml +34 -0
  2. package/.tarignore +5 -0
  3. package/LICENSE +202 -0
  4. package/README.md +34 -0
  5. package/README_DEV.md +69 -0
  6. package/bmc-button.svg +22 -0
  7. package/dist/appliances.js +6 -0
  8. package/dist/behaviorFactory.js +18 -0
  9. package/dist/behaviors/BehaviorDeviceGeneric.js +31 -0
  10. package/dist/behaviors/roborock.vacuum/QREVO_EDGE_5V1/a187.js +94 -0
  11. package/dist/behaviors/roborock.vacuum/QREVO_EDGE_5V1/initalData.js +81 -0
  12. package/dist/behaviors/roborock.vacuum/QREVO_EDGE_5V1/runtimes.js +39 -0
  13. package/dist/behaviors/roborock.vacuum/default/default.js +58 -0
  14. package/dist/behaviors/roborock.vacuum/default/initalData.js +66 -0
  15. package/dist/clientManager.js +17 -0
  16. package/dist/extensions/AxiosStaticExtensions.js +22 -0
  17. package/dist/extensions/index.js +1 -0
  18. package/dist/helper.js +16 -0
  19. package/dist/index.js +4 -0
  20. package/dist/initialData/getBatteryStatus.js +24 -0
  21. package/dist/initialData/getOperationalStates.js +22 -0
  22. package/dist/initialData/getSupportedAreas.js +69 -0
  23. package/dist/initialData/getSupportedCleanModes.js +11 -0
  24. package/dist/initialData/getSupportedRunModes.js +18 -0
  25. package/dist/initialData/index.js +5 -0
  26. package/dist/model/CloudMessageModel.js +1 -0
  27. package/dist/model/DockingStationStatus.js +24 -0
  28. package/dist/model/RoomMap.js +18 -0
  29. package/dist/notifyMessageTypes.js +9 -0
  30. package/dist/platform.js +146 -0
  31. package/dist/platformRunner.js +249 -0
  32. package/dist/roborockCommunication/RESTAPI/roborockAuthenticateApi.js +73 -0
  33. package/dist/roborockCommunication/RESTAPI/roborockIoTApi.js +61 -0
  34. package/dist/roborockCommunication/Zenum/dockType.js +4 -0
  35. package/dist/roborockCommunication/Zenum/operationStatusCode.js +44 -0
  36. package/dist/roborockCommunication/Zenum/vacuumAndDockErrorCode.js +68 -0
  37. package/dist/roborockCommunication/Zmodel/apiResponse.js +1 -0
  38. package/dist/roborockCommunication/Zmodel/authenticateResponse.js +1 -0
  39. package/dist/roborockCommunication/Zmodel/baseURL.js +1 -0
  40. package/dist/roborockCommunication/Zmodel/device.js +1 -0
  41. package/dist/roborockCommunication/Zmodel/deviceModel.js +28 -0
  42. package/dist/roborockCommunication/Zmodel/deviceSchema.js +1 -0
  43. package/dist/roborockCommunication/Zmodel/deviceStatus.js +22 -0
  44. package/dist/roborockCommunication/Zmodel/dockInfo.js +6 -0
  45. package/dist/roborockCommunication/Zmodel/home.js +1 -0
  46. package/dist/roborockCommunication/Zmodel/homeInfo.js +1 -0
  47. package/dist/roborockCommunication/Zmodel/messageResult.js +7 -0
  48. package/dist/roborockCommunication/Zmodel/networkInfo.js +1 -0
  49. package/dist/roborockCommunication/Zmodel/product.js +1 -0
  50. package/dist/roborockCommunication/Zmodel/room.js +1 -0
  51. package/dist/roborockCommunication/Zmodel/roomInfo.js +22 -0
  52. package/dist/roborockCommunication/Zmodel/userData.js +1 -0
  53. package/dist/roborockCommunication/Zmodel/vacuumError.js +27 -0
  54. package/dist/roborockCommunication/broadcast/abstractClient.js +41 -0
  55. package/dist/roborockCommunication/broadcast/client/LocalNetworkClient.js +148 -0
  56. package/dist/roborockCommunication/broadcast/client/MQTTClient.js +101 -0
  57. package/dist/roborockCommunication/broadcast/client.js +1 -0
  58. package/dist/roborockCommunication/broadcast/clientRouter.js +79 -0
  59. package/dist/roborockCommunication/broadcast/listener/abstractConnectionListener.js +1 -0
  60. package/dist/roborockCommunication/broadcast/listener/abstractMessageHandler.js +1 -0
  61. package/dist/roborockCommunication/broadcast/listener/abstractMessageListener.js +1 -0
  62. package/dist/roborockCommunication/broadcast/listener/implementation/chainedConnectionListener.js +21 -0
  63. package/dist/roborockCommunication/broadcast/listener/implementation/chainedMessageListener.js +11 -0
  64. package/dist/roborockCommunication/broadcast/listener/implementation/simpleMessageListener.js +27 -0
  65. package/dist/roborockCommunication/broadcast/listener/implementation/syncMessageListener.js +35 -0
  66. package/dist/roborockCommunication/broadcast/listener/index.js +1 -0
  67. package/dist/roborockCommunication/broadcast/messageProcessor.js +79 -0
  68. package/dist/roborockCommunication/broadcast/model/dps.js +1 -0
  69. package/dist/roborockCommunication/broadcast/model/messageContext.js +26 -0
  70. package/dist/roborockCommunication/broadcast/model/protocol.js +19 -0
  71. package/dist/roborockCommunication/broadcast/model/requestMessage.js +33 -0
  72. package/dist/roborockCommunication/broadcast/model/responseMessage.js +14 -0
  73. package/dist/roborockCommunication/helper/chunkBuffer.js +17 -0
  74. package/dist/roborockCommunication/helper/cryptoHelper.js +27 -0
  75. package/dist/roborockCommunication/helper/messageDeserializer.js +74 -0
  76. package/dist/roborockCommunication/helper/messageSerializer.js +70 -0
  77. package/dist/roborockCommunication/helper/nameDecoder.js +66 -0
  78. package/dist/roborockCommunication/helper/sequence.js +16 -0
  79. package/dist/roborockCommunication/index.js +9 -0
  80. package/dist/roborockService.js +300 -0
  81. package/dist/rvc.js +39 -0
  82. package/dist/settings.js +1 -0
  83. package/dist/share/function.js +96 -0
  84. package/dist/share/runtimeHelper.js +29 -0
  85. package/eslint.config.js +76 -0
  86. package/matterbridge-roborock-vacuum-plugin.config.json +11 -0
  87. package/matterbridge-roborock-vacuum-plugin.schema.json +57 -0
  88. package/package.json +43 -0
  89. package/prettier.config.js +49 -0
  90. package/src/appliances.ts +15 -0
  91. package/src/behaviorFactory.ts +24 -0
  92. package/src/behaviors/BehaviorDeviceGeneric.ts +39 -0
  93. package/src/behaviors/roborock.vacuum/QREVO_EDGE_5V1/a187.ts +117 -0
  94. package/src/behaviors/roborock.vacuum/QREVO_EDGE_5V1/initalData.ts +85 -0
  95. package/src/behaviors/roborock.vacuum/QREVO_EDGE_5V1/runtimes.ts +29 -0
  96. package/src/behaviors/roborock.vacuum/default/default.ts +78 -0
  97. package/src/behaviors/roborock.vacuum/default/initalData.ts +69 -0
  98. package/src/clientManager.ts +23 -0
  99. package/src/extensions/AxiosStaticExtensions.ts +35 -0
  100. package/src/extensions/index.ts +1 -0
  101. package/src/helper.ts +22 -0
  102. package/src/index.ts +16 -0
  103. package/src/initialData/getBatteryStatus.ts +26 -0
  104. package/src/initialData/getOperationalStates.ts +24 -0
  105. package/src/initialData/getSupportedAreas.ts +95 -0
  106. package/src/initialData/getSupportedCleanModes.ts +13 -0
  107. package/src/initialData/getSupportedRunModes.ts +21 -0
  108. package/src/initialData/index.ts +5 -0
  109. package/src/model/CloudMessageModel.ts +13 -0
  110. package/src/model/DockingStationStatus.ts +37 -0
  111. package/src/model/RoomMap.ts +44 -0
  112. package/src/notifyMessageTypes.ts +8 -0
  113. package/src/platform.ts +192 -0
  114. package/src/platformRunner.ts +292 -0
  115. package/src/roborockCommunication/RESTAPI/roborockAuthenticateApi.ts +98 -0
  116. package/src/roborockCommunication/RESTAPI/roborockIoTApi.ts +70 -0
  117. package/src/roborockCommunication/Zenum/dockType.ts +3 -0
  118. package/src/roborockCommunication/Zenum/operationStatusCode.ts +43 -0
  119. package/src/roborockCommunication/Zenum/vacuumAndDockErrorCode.ts +68 -0
  120. package/src/roborockCommunication/Zmodel/apiResponse.ts +3 -0
  121. package/src/roborockCommunication/Zmodel/authenticateResponse.ts +5 -0
  122. package/src/roborockCommunication/Zmodel/baseURL.ts +5 -0
  123. package/src/roborockCommunication/Zmodel/device.ts +39 -0
  124. package/src/roborockCommunication/Zmodel/deviceModel.ts +27 -0
  125. package/src/roborockCommunication/Zmodel/deviceSchema.ts +8 -0
  126. package/src/roborockCommunication/Zmodel/deviceStatus.ts +30 -0
  127. package/src/roborockCommunication/Zmodel/dockInfo.ts +9 -0
  128. package/src/roborockCommunication/Zmodel/home.ts +13 -0
  129. package/src/roborockCommunication/Zmodel/homeInfo.ts +5 -0
  130. package/src/roborockCommunication/Zmodel/messageResult.ts +72 -0
  131. package/src/roborockCommunication/Zmodel/networkInfo.ts +7 -0
  132. package/src/roborockCommunication/Zmodel/product.ts +9 -0
  133. package/src/roborockCommunication/Zmodel/room.ts +4 -0
  134. package/src/roborockCommunication/Zmodel/roomInfo.ts +25 -0
  135. package/src/roborockCommunication/Zmodel/userData.ts +23 -0
  136. package/src/roborockCommunication/Zmodel/vacuumError.ts +35 -0
  137. package/src/roborockCommunication/broadcast/abstractClient.ts +61 -0
  138. package/src/roborockCommunication/broadcast/client/LocalNetworkClient.ts +177 -0
  139. package/src/roborockCommunication/broadcast/client/MQTTClient.ts +129 -0
  140. package/src/roborockCommunication/broadcast/client.ts +19 -0
  141. package/src/roborockCommunication/broadcast/clientRouter.ts +100 -0
  142. package/src/roborockCommunication/broadcast/listener/abstractConnectionListener.ts +5 -0
  143. package/src/roborockCommunication/broadcast/listener/abstractMessageHandler.ts +11 -0
  144. package/src/roborockCommunication/broadcast/listener/abstractMessageListener.ts +5 -0
  145. package/src/roborockCommunication/broadcast/listener/implementation/chainedConnectionListener.ts +26 -0
  146. package/src/roborockCommunication/broadcast/listener/implementation/chainedMessageListener.ts +16 -0
  147. package/src/roborockCommunication/broadcast/listener/implementation/simpleMessageListener.ts +37 -0
  148. package/src/roborockCommunication/broadcast/listener/implementation/syncMessageListener.ts +48 -0
  149. package/src/roborockCommunication/broadcast/listener/index.ts +3 -0
  150. package/src/roborockCommunication/broadcast/messageProcessor.ts +110 -0
  151. package/src/roborockCommunication/broadcast/model/dps.ts +17 -0
  152. package/src/roborockCommunication/broadcast/model/messageContext.ts +34 -0
  153. package/src/roborockCommunication/broadcast/model/protocol.ts +19 -0
  154. package/src/roborockCommunication/broadcast/model/requestMessage.ts +44 -0
  155. package/src/roborockCommunication/broadcast/model/responseMessage.ts +19 -0
  156. package/src/roborockCommunication/helper/chunkBuffer.ts +18 -0
  157. package/src/roborockCommunication/helper/cryptoHelper.ts +34 -0
  158. package/src/roborockCommunication/helper/messageDeserializer.ts +99 -0
  159. package/src/roborockCommunication/helper/messageSerializer.ts +82 -0
  160. package/src/roborockCommunication/helper/nameDecoder.ts +78 -0
  161. package/src/roborockCommunication/helper/sequence.ts +18 -0
  162. package/src/roborockCommunication/index.ts +15 -0
  163. package/src/roborockService.ts +379 -0
  164. package/src/rvc.ts +66 -0
  165. package/src/settings.ts +1 -0
  166. package/src/share/function.ts +106 -0
  167. package/src/share/runtimeHelper.ts +35 -0
  168. package/tsconfig.json +37 -0
  169. package/tsconfig.production.json +19 -0
  170. package/tslint.json +9 -0
@@ -0,0 +1,81 @@
1
+ import { RvcCleanMode, RvcOperationalState, RvcRunMode } from 'matterbridge/matter/clusters';
2
+ export function getSupportedRunModesA187() {
3
+ return [
4
+ {
5
+ label: 'Idle',
6
+ mode: 1,
7
+ modeTags: [{ value: RvcRunMode.ModeTag.Idle }],
8
+ },
9
+ {
10
+ label: 'Cleaning',
11
+ mode: 2,
12
+ modeTags: [{ value: RvcRunMode.ModeTag.Cleaning }],
13
+ },
14
+ {
15
+ label: 'Mapping',
16
+ mode: 3,
17
+ modeTags: [{ value: RvcRunMode.ModeTag.Mapping }],
18
+ },
19
+ ];
20
+ }
21
+ export function getSupportedCleanModesA187() {
22
+ return [
23
+ {
24
+ label: 'Smart Plan',
25
+ mode: 4,
26
+ modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.Auto }],
27
+ },
28
+ {
29
+ label: 'Mop',
30
+ mode: 5,
31
+ modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Auto }],
32
+ },
33
+ {
34
+ label: 'Vacuum',
35
+ mode: 6,
36
+ modeTags: [{ value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.Auto }],
37
+ },
38
+ {
39
+ label: 'Mop & Vacuum',
40
+ mode: 7,
41
+ modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.DeepClean }],
42
+ },
43
+ {
44
+ label: 'Custom',
45
+ mode: 8,
46
+ modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.Quick }],
47
+ },
48
+ ];
49
+ }
50
+ export function getOperationalStatesA187() {
51
+ return [
52
+ {
53
+ operationalStateId: RvcOperationalState.OperationalState.Stopped,
54
+ operationalStateLabel: 'Stopped',
55
+ },
56
+ {
57
+ operationalStateId: RvcOperationalState.OperationalState.Running,
58
+ operationalStateLabel: 'Running',
59
+ },
60
+ {
61
+ operationalStateId: RvcOperationalState.OperationalState.Paused,
62
+ operationalStateLabel: 'Paused',
63
+ },
64
+ {
65
+ operationalStateId: RvcOperationalState.OperationalState.Error,
66
+ operationalStateLabel: 'Error',
67
+ },
68
+ {
69
+ operationalStateId: RvcOperationalState.OperationalState.SeekingCharger,
70
+ operationalStateLabel: 'SeekingCharger',
71
+ },
72
+ {
73
+ operationalStateId: RvcOperationalState.OperationalState.Charging,
74
+ operationalStateLabel: 'Charging',
75
+ },
76
+ {
77
+ operationalStateId: RvcOperationalState.OperationalState.Docked,
78
+ operationalStateLabel: 'Docked',
79
+ },
80
+ ];
81
+ }
@@ -0,0 +1,39 @@
1
+ import { MopWaterFlowA187, VacuumSuctionPowerA187 } from './a187.js';
2
+ export function getCurrentCleanModeA187(fan_power, water_box_mode) {
3
+ if (!fan_power || !water_box_mode)
4
+ return undefined;
5
+ if (fan_power == VacuumSuctionPowerA187.Smart || water_box_mode == MopWaterFlowA187.Smart)
6
+ return 4;
7
+ if (fan_power == VacuumSuctionPowerA187.Custom || water_box_mode == MopWaterFlowA187.Custom)
8
+ return 8;
9
+ if (fan_power == VacuumSuctionPowerA187.Off)
10
+ return 5;
11
+ if (water_box_mode == MopWaterFlowA187.Off)
12
+ return 6;
13
+ else
14
+ return 7;
15
+ }
16
+ export function getCurrentCleanModeFromFanPowerA187(fan_power) {
17
+ if (!fan_power)
18
+ return undefined;
19
+ if (fan_power == VacuumSuctionPowerA187.Smart)
20
+ return 4;
21
+ if (fan_power == VacuumSuctionPowerA187.Custom)
22
+ return 8;
23
+ if (fan_power == VacuumSuctionPowerA187.Off)
24
+ return 5;
25
+ else
26
+ return undefined;
27
+ }
28
+ export function getCurrentCleanModeFromWaterBoxModeA187(water_box_mode) {
29
+ if (!water_box_mode)
30
+ return undefined;
31
+ if (water_box_mode == MopWaterFlowA187.Smart)
32
+ return 4;
33
+ if (water_box_mode == MopWaterFlowA187.Custom)
34
+ return 8;
35
+ if (water_box_mode == MopWaterFlowA187.Off)
36
+ return 6;
37
+ else
38
+ return undefined;
39
+ }
@@ -0,0 +1,58 @@
1
+ import { BehaviorRoborock } from '../../BehaviorDeviceGeneric.js';
2
+ export class DefaultBehavior extends BehaviorRoborock {
3
+ }
4
+ export var DefaultBehaviorRoborock;
5
+ (function (DefaultBehaviorRoborock) {
6
+ class State {
7
+ device;
8
+ }
9
+ DefaultBehaviorRoborock.State = State;
10
+ })(DefaultBehaviorRoborock || (DefaultBehaviorRoborock = {}));
11
+ const RvcRunMode = {
12
+ [1]: 'Idle',
13
+ [2]: 'Cleaning',
14
+ [3]: 'Mapping',
15
+ };
16
+ const RvcCleanMode = {
17
+ [4]: 'Mop',
18
+ [5]: 'Vacuum',
19
+ };
20
+ export function setDefaultCommandHandler(duid, handler, logger, roborockService) {
21
+ handler.setCommandHandler('changeToMode', async (newMode) => {
22
+ const activity = RvcRunMode[newMode] || RvcCleanMode[newMode];
23
+ switch (activity) {
24
+ case 'Cleaning': {
25
+ await roborockService.startClean(duid);
26
+ return;
27
+ }
28
+ case 'Mop':
29
+ case 'Vacuum': {
30
+ logger.notice('DefaultBehavior-ChangeCleanMode to: ', activity);
31
+ return;
32
+ }
33
+ default:
34
+ logger.notice('DefaultBehavior-changeToMode-Unknown: ', newMode);
35
+ return;
36
+ }
37
+ });
38
+ handler.setCommandHandler('selectAreas', async (newAreas) => {
39
+ logger.notice(`DefaultBehavior-selectAreas: ${newAreas}`);
40
+ roborockService.setSelectedAreas(duid, newAreas ?? []);
41
+ });
42
+ handler.setCommandHandler('pause', async () => {
43
+ logger.notice('DefaultBehavior-Pause');
44
+ await roborockService.pauseClean(duid);
45
+ });
46
+ handler.setCommandHandler('resume', async () => {
47
+ logger.notice('DefaultBehavior-Resume');
48
+ await roborockService.resumeClean(duid);
49
+ });
50
+ handler.setCommandHandler('goHome', async () => {
51
+ logger.notice('DefaultBehavior-GoHome');
52
+ await roborockService.stopAndGoHome(duid);
53
+ });
54
+ handler.setCommandHandler('PlaySoundToLocate', async (identifyTime) => {
55
+ logger.notice('DefaultBehavior-PlaySoundToLocate');
56
+ await roborockService.playSoundToLocate(duid);
57
+ });
58
+ }
@@ -0,0 +1,66 @@
1
+ import { RvcCleanMode, RvcOperationalState, RvcRunMode } from 'matterbridge/matter/clusters';
2
+ export function getDefaultSupportedRunModes() {
3
+ return [
4
+ {
5
+ label: 'Idle',
6
+ mode: 1,
7
+ modeTags: [{ value: RvcRunMode.ModeTag.Idle }],
8
+ },
9
+ {
10
+ label: 'Cleaning',
11
+ mode: 2,
12
+ modeTags: [{ value: RvcRunMode.ModeTag.Cleaning }],
13
+ },
14
+ {
15
+ label: 'Mapping',
16
+ mode: 3,
17
+ modeTags: [{ value: RvcRunMode.ModeTag.Mapping }],
18
+ },
19
+ ];
20
+ }
21
+ export function getDefaultSupportedCleanModes() {
22
+ return [
23
+ {
24
+ label: 'Vacuum',
25
+ mode: 4,
26
+ modeTags: [{ value: RvcCleanMode.ModeTag.Vacuum }],
27
+ },
28
+ {
29
+ label: 'Mop',
30
+ mode: 5,
31
+ modeTags: [{ value: RvcCleanMode.ModeTag.Mop }],
32
+ },
33
+ ];
34
+ }
35
+ export function getDefaultOperationalStates() {
36
+ return [
37
+ {
38
+ operationalStateId: RvcOperationalState.OperationalState.Stopped,
39
+ operationalStateLabel: 'Stopped',
40
+ },
41
+ {
42
+ operationalStateId: RvcOperationalState.OperationalState.Running,
43
+ operationalStateLabel: 'Running',
44
+ },
45
+ {
46
+ operationalStateId: RvcOperationalState.OperationalState.Paused,
47
+ operationalStateLabel: 'Paused',
48
+ },
49
+ {
50
+ operationalStateId: RvcOperationalState.OperationalState.Error,
51
+ operationalStateLabel: 'Error',
52
+ },
53
+ {
54
+ operationalStateId: RvcOperationalState.OperationalState.SeekingCharger,
55
+ operationalStateLabel: 'SeekingCharger',
56
+ },
57
+ {
58
+ operationalStateId: RvcOperationalState.OperationalState.Charging,
59
+ operationalStateLabel: 'Charging',
60
+ },
61
+ {
62
+ operationalStateId: RvcOperationalState.OperationalState.Docked,
63
+ operationalStateLabel: 'Docked',
64
+ },
65
+ ];
66
+ }
@@ -0,0 +1,17 @@
1
+ import { ClientRouter } from './roborockCommunication/broadcast/clientRouter.js';
2
+ export default class ClientManager {
3
+ clients = new Map();
4
+ logger;
5
+ constructor(logger) {
6
+ this.logger = logger;
7
+ }
8
+ get(username, userdata) {
9
+ if (!this.clients.has(username)) {
10
+ this.clients.set(username, new ClientRouter(this.logger, userdata));
11
+ }
12
+ return this.clients.get(username);
13
+ }
14
+ destroy(username) {
15
+ this.clients.delete(username);
16
+ }
17
+ }
@@ -0,0 +1,22 @@
1
+ import axios from 'axios';
2
+ axios.interceptRequestAndResponse = function (logger) {
3
+ this.interceptors.request.use((request) => {
4
+ logger.debug('Axios Request:', {
5
+ method: request.method,
6
+ url: request.url,
7
+ data: request.data,
8
+ headers: request.headers,
9
+ });
10
+ return request;
11
+ });
12
+ this.interceptors.response.use((response) => {
13
+ logger.debug('Axios Response:', {
14
+ status: response.status,
15
+ data: response.data,
16
+ headers: response.headers,
17
+ url: response.config.url,
18
+ });
19
+ return response;
20
+ });
21
+ return this;
22
+ };
@@ -0,0 +1 @@
1
+ import './AxiosStaticExtensions.js';
package/dist/helper.js ADDED
@@ -0,0 +1,16 @@
1
+ export function getVacuumProperty(device, property) {
2
+ if (device) {
3
+ const schemas = device.schema;
4
+ const schema = schemas.find((sch) => sch.code == property);
5
+ if (schema && device.deviceStatus && device.deviceStatus[schema.id] != undefined) {
6
+ return Number(device.deviceStatus[schema.id]);
7
+ }
8
+ if (device.deviceStatus && device.deviceStatus[property] != undefined) {
9
+ return Number(device.deviceStatus[property]);
10
+ }
11
+ }
12
+ return undefined;
13
+ }
14
+ export function isSupportedDevice(model) {
15
+ return model.startsWith('roborock.vacuum.');
16
+ }
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { RoborockMatterbridgePlatform } from './platform.js';
2
+ export default function initializePlugin(matterbridge, log, config) {
3
+ return new RoborockMatterbridgePlatform(matterbridge, log, config);
4
+ }
@@ -0,0 +1,24 @@
1
+ import { PowerSource } from 'matterbridge/matter/clusters';
2
+ import { OperationStatusCode } from '../roborockCommunication/Zenum/operationStatusCode.js';
3
+ export function getBatteryStatus(batteryLevel) {
4
+ if (batteryLevel === undefined)
5
+ return PowerSource.BatChargeLevel.Ok;
6
+ if (batteryLevel >= 70) {
7
+ return PowerSource.BatChargeLevel.Ok;
8
+ }
9
+ else if (batteryLevel >= 40) {
10
+ return PowerSource.BatChargeLevel.Warning;
11
+ }
12
+ else {
13
+ return PowerSource.BatChargeLevel.Critical;
14
+ }
15
+ }
16
+ export function getBatteryState(deviceState, batRemaining) {
17
+ if (deviceState == OperationStatusCode.Charging) {
18
+ return batRemaining < 100 ? PowerSource.BatChargeState.IsCharging : PowerSource.BatChargeState.IsAtFullCharge;
19
+ }
20
+ if (deviceState == OperationStatusCode.ChargingError) {
21
+ return PowerSource.BatChargeState.IsNotCharging;
22
+ }
23
+ return PowerSource.BatChargeState.IsAtFullCharge;
24
+ }
@@ -0,0 +1,22 @@
1
+ import { RvcOperationalState } from 'matterbridge/matter/clusters';
2
+ import { getOperationalStatesA187 } from '../behaviors/roborock.vacuum/QREVO_EDGE_5V1/initalData.js';
3
+ import { getDefaultOperationalStates } from '../behaviors/roborock.vacuum/default/initalData.js';
4
+ import { DeviceModel } from '../roborockCommunication/Zmodel/deviceModel.js';
5
+ import { VacuumErrorCode } from '../roborockCommunication/Zenum/vacuumAndDockErrorCode.js';
6
+ export function getOperationalStates(model) {
7
+ switch (model) {
8
+ case DeviceModel.QREVO_EDGE_5V1:
9
+ return getOperationalStatesA187();
10
+ default:
11
+ return getDefaultOperationalStates();
12
+ }
13
+ }
14
+ export function getOperationalErrorState(errorCode) {
15
+ switch (errorCode) {
16
+ case VacuumErrorCode.None:
17
+ return undefined;
18
+ default: {
19
+ return RvcOperationalState.OperationalState.Error;
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,69 @@
1
+ export function getSupportedAreas(rooms, roomMap, log) {
2
+ log?.debug('getSupportedAreas', JSON.stringify(rooms));
3
+ log?.debug('getSupportedAreas', JSON.stringify(roomMap));
4
+ if (!rooms || rooms.length === 0 || !roomMap?.rooms || roomMap.rooms.length == 0) {
5
+ log?.error('No rooms found');
6
+ return [
7
+ {
8
+ areaId: 1,
9
+ mapId: null,
10
+ areaInfo: {
11
+ locationInfo: {
12
+ locationName: 'Unknown',
13
+ floorNumber: null,
14
+ areaType: null,
15
+ },
16
+ landmarkInfo: null,
17
+ },
18
+ },
19
+ ];
20
+ }
21
+ const supportedAreas = rooms.map((room, index) => {
22
+ return {
23
+ areaId: roomMap.getRoomId(room.id) ?? index + 1,
24
+ mapId: null,
25
+ areaInfo: {
26
+ locationInfo: {
27
+ locationName: room.name,
28
+ floorNumber: null,
29
+ areaType: null,
30
+ },
31
+ landmarkInfo: null,
32
+ },
33
+ };
34
+ });
35
+ const duplicated = findDuplicatedAreaIds(supportedAreas, log);
36
+ return duplicated
37
+ ? [
38
+ {
39
+ areaId: 1,
40
+ mapId: null,
41
+ areaInfo: {
42
+ locationInfo: {
43
+ locationName: 'Unknown',
44
+ floorNumber: null,
45
+ areaType: null,
46
+ },
47
+ landmarkInfo: null,
48
+ },
49
+ },
50
+ ]
51
+ : supportedAreas;
52
+ }
53
+ function findDuplicatedAreaIds(areas, log) {
54
+ const seen = new Set();
55
+ const duplicates = [];
56
+ for (const area of areas) {
57
+ if (seen.has(area.areaId)) {
58
+ duplicates.push(area.areaId);
59
+ }
60
+ else {
61
+ seen.add(area.areaId);
62
+ }
63
+ }
64
+ if (duplicates.length > 0 && log) {
65
+ const duplicated = areas.filter((x) => duplicates.includes(x.areaId));
66
+ log.error(`Duplicated areaId(s) found: ${JSON.stringify(duplicated)}`);
67
+ }
68
+ return duplicates.length > 0;
69
+ }
@@ -0,0 +1,11 @@
1
+ import { getSupportedCleanModesA187 } from '../behaviors/roborock.vacuum/QREVO_EDGE_5V1/initalData.js';
2
+ import { getDefaultSupportedCleanModes } from '../behaviors/roborock.vacuum/default/initalData.js';
3
+ import { DeviceModel } from '../roborockCommunication/Zmodel/deviceModel.js';
4
+ export function getSupportedCleanModes(model) {
5
+ switch (model) {
6
+ case DeviceModel.QREVO_EDGE_5V1:
7
+ return getSupportedCleanModesA187();
8
+ default:
9
+ return getDefaultSupportedCleanModes();
10
+ }
11
+ }
@@ -0,0 +1,18 @@
1
+ import { getSupportedRunModesA187 } from '../behaviors/roborock.vacuum/QREVO_EDGE_5V1/initalData.js';
2
+ import { getDefaultSupportedRunModes } from '../behaviors/roborock.vacuum/default/initalData.js';
3
+ import { DeviceModel } from '../roborockCommunication/Zmodel/deviceModel.js';
4
+ export function getRunningMode(model, modeTag) {
5
+ if (!model || !modeTag)
6
+ return null;
7
+ const supportedMode = getSupportedRunModes(model);
8
+ const runningMode = supportedMode.find((s) => s.modeTags.some((mt) => mt.value === modeTag));
9
+ return runningMode?.mode ?? null;
10
+ }
11
+ export function getSupportedRunModes(model) {
12
+ switch (model) {
13
+ case DeviceModel.QREVO_EDGE_5V1:
14
+ return getSupportedRunModesA187();
15
+ default:
16
+ return getDefaultSupportedRunModes();
17
+ }
18
+ }
@@ -0,0 +1,5 @@
1
+ export { getSupportedRunModes } from './getSupportedRunModes.js';
2
+ export { getOperationalStates, getOperationalErrorState } from './getOperationalStates.js';
3
+ export { getSupportedCleanModes } from './getSupportedCleanModes.js';
4
+ export { getSupportedAreas } from './getSupportedAreas.js';
5
+ export { getBatteryStatus, getBatteryState } from './getBatteryStatus.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ export var DockingStationStatusType;
2
+ (function (DockingStationStatusType) {
3
+ DockingStationStatusType[DockingStationStatusType["Unknown"] = 0] = "Unknown";
4
+ DockingStationStatusType[DockingStationStatusType["Error"] = 1] = "Error";
5
+ DockingStationStatusType[DockingStationStatusType["OK"] = 2] = "OK";
6
+ })(DockingStationStatusType || (DockingStationStatusType = {}));
7
+ export function parseDockingStationStatus(dss) {
8
+ return {
9
+ cleanFluidStatus: (dss >> 10) & 0b11,
10
+ waterBoxFilterStatus: (dss >> 8) & 0b11,
11
+ dustBagStatus: (dss >> 6) & 0b11,
12
+ dirtyWaterBoxStatus: (dss >> 4) & 0b11,
13
+ clearWaterBoxStatus: (dss >> 2) & 0b11,
14
+ isUpdownWaterReady: dss & 0b11,
15
+ };
16
+ }
17
+ export function hasDockingStationError(status) {
18
+ return (status.cleanFluidStatus === DockingStationStatusType.Error ||
19
+ status.waterBoxFilterStatus === DockingStationStatusType.Error ||
20
+ status.dustBagStatus === DockingStationStatusType.Error ||
21
+ status.dirtyWaterBoxStatus === DockingStationStatusType.Error ||
22
+ status.clearWaterBoxStatus === DockingStationStatusType.Error ||
23
+ status.isUpdownWaterReady === DockingStationStatusType.Error);
24
+ }
@@ -0,0 +1,18 @@
1
+ export default class RoomMap {
2
+ rooms = [];
3
+ constructor(roomData, rooms) {
4
+ this.rooms = roomData.map((entry) => {
5
+ return {
6
+ id: entry[0],
7
+ globalId: Number(entry[1]),
8
+ displayName: rooms.find((r) => Number(r.id) == Number(entry[1]))?.name,
9
+ };
10
+ });
11
+ }
12
+ getGlobalId(id) {
13
+ return this.rooms.find((r) => Number(r.id) == Number(id))?.globalId;
14
+ }
15
+ getRoomId(globalId) {
16
+ return this.rooms.find((r) => Number(r.globalId) == Number(globalId))?.id;
17
+ }
18
+ }
@@ -0,0 +1,9 @@
1
+ export var NotifyMessageTypes;
2
+ (function (NotifyMessageTypes) {
3
+ NotifyMessageTypes["LocalMessage"] = "LocalMessage";
4
+ NotifyMessageTypes["CloudMessage"] = "CloudMessage";
5
+ NotifyMessageTypes["BatteryUpdate"] = "BatteryUpdate";
6
+ NotifyMessageTypes["ErrorOccurred"] = "ErrorOccurred";
7
+ NotifyMessageTypes["HomeData"] = "HomeData";
8
+ NotifyMessageTypes["DeviceStatus"] = "DeviceStatus";
9
+ })(NotifyMessageTypes || (NotifyMessageTypes = {}));