matterbridge-roborock-vacuum-plugin 1.0.8-rc01 → 1.0.8-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.
Files changed (115) hide show
  1. package/.github/workflows/build.yml +47 -0
  2. package/.github/workflows/coverage.yml +50 -0
  3. package/.github/workflows/publish.yml +4 -1
  4. package/README.md +8 -0
  5. package/README_SUPPORTED.md +54 -0
  6. package/dist/behaviorFactory.js +7 -1
  7. package/dist/behaviors/BehaviorDeviceGeneric.js +0 -9
  8. package/dist/behaviors/roborock.vacuum/QREVO_EDGE_5V1/a187.js +2 -9
  9. package/dist/behaviors/roborock.vacuum/S7_MAXV/a27.js +2 -9
  10. package/dist/behaviors/roborock.vacuum/S8_PRO_ULTRA/a51.js +132 -0
  11. package/dist/behaviors/roborock.vacuum/S8_PRO_ULTRA/initalData.js +76 -0
  12. package/dist/behaviors/roborock.vacuum/S8_PRO_ULTRA/runtimes.js +33 -0
  13. package/dist/behaviors/roborock.vacuum/default/default.js +88 -14
  14. package/dist/behaviors/roborock.vacuum/default/initalData.js +15 -5
  15. package/dist/behaviors/roborock.vacuum/default/runtimes.js +33 -0
  16. package/dist/initialData/getSupportedAreas.js +1 -1
  17. package/dist/initialData/getSupportedScenes.js +26 -0
  18. package/dist/initialData/index.js +1 -0
  19. package/dist/model/ExperimentalFeatureSetting.js +1 -0
  20. package/dist/platform.js +18 -32
  21. package/dist/platformRunner.js +33 -25
  22. package/dist/roborockCommunication/RESTAPI/roborockAuthenticateApi.js +1 -1
  23. package/dist/roborockCommunication/RESTAPI/roborockIoTApi.js +15 -4
  24. package/dist/roborockCommunication/Zmodel/batteryMessage.js +1 -0
  25. package/dist/roborockCommunication/Zmodel/deviceModel.js +1 -1
  26. package/dist/roborockCommunication/Zmodel/scene.js +16 -0
  27. package/dist/roborockCommunication/broadcast/abstractClient.js +1 -1
  28. package/dist/roborockCommunication/broadcast/client/MQTTClient.js +3 -2
  29. package/dist/roborockCommunication/broadcast/clientRouter.js +2 -2
  30. package/dist/roborockCommunication/broadcast/listener/implementation/syncMessageListener.js +2 -1
  31. package/dist/roborockCommunication/broadcast/model/messageContext.js +1 -1
  32. package/dist/roborockCommunication/broadcast/model/requestMessage.js +1 -1
  33. package/dist/roborockCommunication/helper/cryptoHelper.js +21 -25
  34. package/dist/roborockCommunication/helper/messageDeserializer.js +7 -5
  35. package/dist/roborockCommunication/helper/messageSerializer.js +3 -3
  36. package/dist/roborockCommunication/index.js +1 -0
  37. package/dist/roborockService.js +59 -19
  38. package/dist/rvc.js +3 -3
  39. package/dist/share/function.js +0 -2
  40. package/dist/share/runtimeHelper.js +14 -3
  41. package/eslint.config.js +65 -61
  42. package/jest.config.js +20 -18
  43. package/jest.setup.js +2 -0
  44. package/matterbridge-roborock-vacuum-plugin.config.json +27 -2
  45. package/matterbridge-roborock-vacuum-plugin.schema.json +186 -104
  46. package/package.json +4 -2
  47. package/prettier.config.js +18 -18
  48. package/src/behaviorFactory.ts +9 -2
  49. package/src/behaviors/BehaviorDeviceGeneric.ts +5 -13
  50. package/src/behaviors/roborock.vacuum/QREVO_EDGE_5V1/a187.ts +18 -20
  51. package/src/behaviors/roborock.vacuum/QREVO_EDGE_5V1/runtimes.ts +1 -1
  52. package/src/behaviors/roborock.vacuum/S7_MAXV/a27.ts +17 -19
  53. package/src/behaviors/roborock.vacuum/S7_MAXV/initalData.ts +0 -1
  54. package/src/behaviors/roborock.vacuum/S7_MAXV/runtimes.ts +1 -1
  55. package/src/behaviors/roborock.vacuum/S8_PRO_ULTRA/a51.ts +171 -0
  56. package/src/behaviors/roborock.vacuum/S8_PRO_ULTRA/initalData.ts +79 -0
  57. package/src/behaviors/roborock.vacuum/S8_PRO_ULTRA/runtimes.ts +26 -0
  58. package/src/behaviors/roborock.vacuum/default/default.ts +108 -15
  59. package/src/behaviors/roborock.vacuum/default/initalData.ts +15 -5
  60. package/src/behaviors/roborock.vacuum/default/runtimes.ts +26 -0
  61. package/src/clientManager.ts +1 -1
  62. package/src/initialData/getSupportedAreas.ts +1 -1
  63. package/src/initialData/getSupportedScenes.ts +32 -0
  64. package/src/initialData/index.ts +1 -0
  65. package/src/model/CloudMessageModel.ts +8 -8
  66. package/src/model/DockingStationStatus.ts +3 -3
  67. package/src/model/ExperimentalFeatureSetting.ts +27 -0
  68. package/src/platform.ts +24 -37
  69. package/src/platformRunner.ts +56 -43
  70. package/src/roborockCommunication/RESTAPI/roborockAuthenticateApi.ts +2 -2
  71. package/src/roborockCommunication/RESTAPI/roborockIoTApi.ts +21 -8
  72. package/src/roborockCommunication/Zenum/operationStatusCode.ts +1 -1
  73. package/src/roborockCommunication/Zmodel/batteryMessage.ts +14 -0
  74. package/src/roborockCommunication/Zmodel/device.ts +3 -0
  75. package/src/roborockCommunication/Zmodel/deviceModel.ts +1 -1
  76. package/src/roborockCommunication/Zmodel/deviceSchema.ts +1 -1
  77. package/src/roborockCommunication/Zmodel/messageResult.ts +1 -1
  78. package/src/roborockCommunication/Zmodel/room.ts +1 -1
  79. package/src/roborockCommunication/Zmodel/scene.ts +42 -0
  80. package/src/roborockCommunication/broadcast/abstractClient.ts +4 -3
  81. package/src/roborockCommunication/broadcast/client/LocalNetworkClient.ts +2 -2
  82. package/src/roborockCommunication/broadcast/client/MQTTClient.ts +6 -6
  83. package/src/roborockCommunication/broadcast/clientRouter.ts +2 -2
  84. package/src/roborockCommunication/broadcast/listener/implementation/simpleMessageListener.ts +3 -3
  85. package/src/roborockCommunication/broadcast/listener/implementation/syncMessageListener.ts +5 -4
  86. package/src/roborockCommunication/broadcast/listener/index.ts +2 -2
  87. package/src/roborockCommunication/broadcast/messageProcessor.ts +3 -3
  88. package/src/roborockCommunication/broadcast/model/dps.ts +2 -2
  89. package/src/roborockCommunication/broadcast/model/messageContext.ts +2 -2
  90. package/src/roborockCommunication/broadcast/model/protocol.ts +2 -2
  91. package/src/roborockCommunication/broadcast/model/requestMessage.ts +5 -5
  92. package/src/roborockCommunication/helper/cryptoHelper.ts +22 -26
  93. package/src/roborockCommunication/helper/messageDeserializer.ts +11 -8
  94. package/src/roborockCommunication/helper/messageSerializer.ts +3 -3
  95. package/src/roborockCommunication/helper/nameDecoder.ts +3 -3
  96. package/src/roborockCommunication/index.ts +11 -6
  97. package/src/roborockService.ts +96 -35
  98. package/src/rvc.ts +16 -16
  99. package/src/share/function.ts +0 -2
  100. package/src/share/runtimeHelper.ts +14 -3
  101. package/src/{behaviors → tests/behaviors}/roborock.vacuum/QREVO_EDGE_5V1/a187.test.ts +12 -11
  102. package/src/{behaviors → tests/behaviors}/roborock.vacuum/QREVO_EDGE_5V1/runtimes.test.ts +6 -2
  103. package/src/{behaviors → tests/behaviors}/roborock.vacuum/S7_MAXV/a27.test.ts +7 -7
  104. package/src/{initialData → tests/initialData}/getSupportedAreas.test.ts +2 -3
  105. package/src/tests/model/DockingStationStatus.test.ts +39 -0
  106. package/src/tests/platformRunner.test.ts +57 -0
  107. package/src/tests/roborockService.test.ts +155 -0
  108. package/src/tests/testData/mockHomeData-a187.json +286 -0
  109. package/tsconfig.jest.json +4 -1
  110. package/dist/extensions/AxiosStaticExtensions.js +0 -22
  111. package/dist/extensions/index.js +0 -1
  112. package/dist/model/CleanModeSettings.js +0 -5
  113. package/src/extensions/AxiosStaticExtensions.ts +0 -35
  114. package/src/extensions/index.ts +0 -1
  115. package/src/model/CleanModeSettings.ts +0 -17
@@ -0,0 +1,47 @@
1
+ name: Build, lint and test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ publish:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ node-version: [18.x, 20.x, 22.x, 24.x]
13
+ os: [ubuntu-latest, windows-latest, macos-latest]
14
+
15
+ steps:
16
+ - name: Checkout code
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Use Node.js ${{ matrix.node-version }}
20
+ uses: actions/setup-node@v4
21
+ with:
22
+ node-version: ${{ matrix.node-version }}
23
+ registry-url: 'https://registry.npmjs.org/'
24
+
25
+ - name: Clean cache
26
+ run: npm cache clean --force
27
+
28
+ - name: Verify Node.js version
29
+ run: node -v
30
+
31
+ - name: Verify Npm version
32
+ run: npm -v
33
+
34
+ - name: Install dependencies
35
+ run: npm ci
36
+
37
+ - name: Install dependencies
38
+ run: npm run precondition && npm run deepClean && npm install && npm link matterbridge
39
+
40
+ - name: Lint the project
41
+ run: npm run lint
42
+
43
+ - name: Test the project
44
+ run: npm run test
45
+
46
+ - name: Build (optional)
47
+ run: npm run build
@@ -0,0 +1,50 @@
1
+ name: Analyze code coverage
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ publish:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - name: Checkout code
11
+ uses: actions/checkout@v4
12
+
13
+ - name: Use Node.js
14
+ uses: actions/setup-node@v4
15
+ with:
16
+ node-version: '20'
17
+ registry-url: 'https://registry.npmjs.org/'
18
+
19
+ - name: Clean cache
20
+ run: npm cache clean --force
21
+
22
+ - name: Verify Node.js version
23
+ run: node -v
24
+
25
+ - name: Verify Npm version
26
+ run: npm -v
27
+
28
+ - name: Install dependencies
29
+ run: npm ci
30
+
31
+ - name: Install dependencies
32
+ run: npm run precondition && npm run deepClean && npm install && npm link matterbridge
33
+
34
+ - name: Lint the project
35
+ run: npm run lint
36
+
37
+ - name: Test the project
38
+ run: npm run test
39
+
40
+ - name: Test with coverage
41
+ run: npm run test -- --coverage
42
+
43
+ - name: Upload coverage reports to Codecov
44
+ uses: codecov/codecov-action@v5
45
+ with:
46
+ token: ${{ secrets.CODECOV_TOKEN }}
47
+ slug: RinDevJunior/matterbridge-roborock-vacuum-plugin
48
+
49
+ - name: Build (optional)
50
+ run: npm run build
@@ -28,7 +28,10 @@ jobs:
28
28
  - name: Build (optional)
29
29
  run: npm run build
30
30
 
31
+ - name: Run tests
32
+ run: npm run test
33
+
31
34
  - name: Publish to npm
32
35
  run: npm publish
33
36
  env:
34
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
37
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md CHANGED
@@ -11,6 +11,12 @@
11
11
  <a href="https://www.npmjs.com/package/matterbridge-roborock-vacuum-plugin">
12
12
  <img src="https://img.shields.io/npm/dt/matterbridge-roborock-vacuum-plugin.svg" alt="npm downloads" />
13
13
  </a>
14
+ <a href="https://github.com/RinDevJunior/matterbridge-roborock-vacuum-plugin/actions/workflows/publish.yml/badge.svg">
15
+ <img src="https://github.com/RinDevJunior/matterbridge-roborock-vacuum-plugin/actions/workflows/publish.yml/badge.svg" alt="nodejs ci" />
16
+ </a>
17
+ <a href="https://codecov.io/gh/RinDevJunior/matterbridge-roborock-vacuum-plugin">
18
+ <img src="https://codecov.io/gh/RinDevJunior/matterbridge-roborock-vacuum-plugin/branch/main/graph/badge.svg" alt="codecov" />
19
+ </a>
14
20
  <a href="https://www.npmjs.com/package/matterbridge">
15
21
  <img src="https://img.shields.io/badge/powered%20by-matterbridge-blue" alt="powered by Matterbridge" />
16
22
  </a>
@@ -68,6 +74,8 @@ To get the **DUID** for your devices, you have two options:
68
74
 
69
75
  ---
70
76
 
77
+ **➡️ [See Supported & Tested Roborock Devices](./README_SUPPORTED.md)**
78
+
71
79
  ### 📦 Prerequisites
72
80
 
73
81
  - A working installation of [Matterbridge](https://github.com/Luligu/matterbridge)
@@ -0,0 +1,54 @@
1
+ # Supported & Tested Roborock Device Models
2
+
3
+ ## ✅ Tested Devices
4
+
5
+ | Device Name | Model Enum Key | Model String | Thank |
6
+ |----------------------------|------------------------|-------------------------------|------------------|
7
+ | Roborock Qrevo Edge 5V1 | `QREVO_EDGE_5V1` | `roborock.vacuum.a187` | |
8
+ | Roborock S8 Pro Ultra | `S8_PRO_ULTRA` | `roborock.vacuum.a70` | |
9
+ | Roborock S7 MaxV | `S7_MAXV` | `roborock.vacuum.a27` | |
10
+
11
+ These devices have been fully tested and are confirmed to work as expected.
12
+
13
+ ---
14
+
15
+ ## ⚠️ Other Supported Devices
16
+
17
+ All other models listed in the code are supported, but **may have some limitations**.
18
+
19
+ **Reason:**
20
+ I do not own these devices for direct testing.
21
+
22
+ If you have one of these models, please try it out and let me know your results!
23
+
24
+ ---
25
+
26
+ ### List of Other Models that I know the mode string
27
+
28
+ - Q5 (`roborock.vacuum.a34`)
29
+ - Q5_PRO (`roborock.vacuum.a72`)
30
+ - S5 (`roborock.vacuum.s5`)
31
+ - S5_MAX (`roborock.vacuum.s5e`)
32
+ - S6 (`roborock.vacuum.s6`)
33
+ - S6_MAXV (`roborock.vacuum.a10`)
34
+ - S6_PURE (`roborock.vacuum.a08`)
35
+ - Q7 (`roborock.vacuum.a40`)
36
+ - Q7_MAX (`roborock.vacuum.a38`)
37
+ - Q7_PLUS (`roborock.vacuum.a40`)
38
+ - S7 (`roborock.vacuum.a15`)
39
+ - S7_MAXV_ULTRA (`roborock.vacuum.a65`)
40
+ - S7_PRO_ULTRA (`roborock.vacuum.a62`)
41
+ - Q8_MAX (`roborock.vacuum.a73`)
42
+ - S8 (`roborock.vacuum.a51`)
43
+ - S8_MAXV_ULTRA (`roborock.vacuum.a97`)
44
+ - QREVO_MASTER (`roborock.vacuum.a117`)
45
+ - QREVO_CURV (`roborock.vacuum.a135`)
46
+ - QREVO_S (`roborock.vacuum.a104`)
47
+ - QREVO_PRO (`roborock.vacuum.a101`)
48
+ - QREVO_MAXV (`roborock.vacuum.a87`)
49
+ - QREVO_EDGE_5AE (`roborock.vacuum.xxxx`)
50
+
51
+ ---
52
+
53
+ > **Note:**
54
+ > If you have a device not listed above, feel free to try it and report your experience!
@@ -3,6 +3,7 @@ import { setCommandHandlerA187 } from './behaviors/roborock.vacuum/QREVO_EDGE_5V
3
3
  import { setDefaultCommandHandler } from './behaviors/roborock.vacuum/default/default.js';
4
4
  import { DeviceModel } from './roborockCommunication/Zmodel/deviceModel.js';
5
5
  import { setCommandHandlerA27 } from './behaviors/roborock.vacuum/S7_MAXV/a27.js';
6
+ import { setCommandHandlerA51 } from './behaviors/roborock.vacuum/S8_PRO_ULTRA/a51.js';
6
7
  export function configurateBehavior(model, duid, roborockService, cleanModeSettings, logger) {
7
8
  switch (model) {
8
9
  case DeviceModel.QREVO_EDGE_5V1: {
@@ -15,9 +16,14 @@ export function configurateBehavior(model, duid, roborockService, cleanModeSetti
15
16
  setCommandHandlerA27(duid, deviceHandler, logger, roborockService, cleanModeSettings);
16
17
  return deviceHandler;
17
18
  }
19
+ case DeviceModel.S8_PRO_ULTRA: {
20
+ const deviceHandler = new BehaviorDeviceGeneric(logger);
21
+ setCommandHandlerA51(duid, deviceHandler, logger, roborockService, cleanModeSettings);
22
+ return deviceHandler;
23
+ }
18
24
  default: {
19
25
  const deviceHandler = new BehaviorDeviceGeneric(logger);
20
- setDefaultCommandHandler(duid, deviceHandler, logger, roborockService);
26
+ setDefaultCommandHandler(duid, deviceHandler, logger, roborockService, cleanModeSettings);
21
27
  return deviceHandler;
22
28
  }
23
29
  }
@@ -17,15 +17,6 @@ export class BehaviorDeviceGeneric {
17
17
  await handler(...args);
18
18
  }
19
19
  }
20
- export class BehaviorGeneric extends Behavior {
21
- static id;
22
- }
23
20
  export class BehaviorRoborock extends Behavior {
24
21
  static id = 'roborock.vacuum.axx';
25
22
  }
26
- (function (BehaviorRoborock) {
27
- class State {
28
- device;
29
- }
30
- BehaviorRoborock.State = State;
31
- })(BehaviorRoborock || (BehaviorRoborock = {}));
@@ -2,13 +2,6 @@ import { debugStringify } from 'matterbridge/logger';
2
2
  import { BehaviorRoborock } from '../../BehaviorDeviceGeneric.js';
3
3
  export class BehaviorA187 extends BehaviorRoborock {
4
4
  }
5
- export var BehaviorRoborockA187;
6
- (function (BehaviorRoborockA187) {
7
- class State {
8
- device;
9
- }
10
- BehaviorRoborockA187.State = State;
11
- })(BehaviorRoborockA187 || (BehaviorRoborockA187 = {}));
12
5
  export var VacuumSuctionPowerA187;
13
6
  (function (VacuumSuctionPowerA187) {
14
7
  VacuumSuctionPowerA187[VacuumSuctionPowerA187["Quiet"] = 101] = "Quiet";
@@ -142,8 +135,8 @@ export function setCommandHandlerA187(duid, handler, logger, roborockService, cl
142
135
  logger.notice('BehaviorA187-GoHome');
143
136
  await roborockService.stopAndGoHome(duid);
144
137
  });
145
- handler.setCommandHandler('PlaySoundToLocate', async (identifyTime) => {
146
- logger.notice('BehaviorA187-PlaySoundToLocate');
138
+ handler.setCommandHandler('playSoundToLocate', async () => {
139
+ logger.notice('BehaviorA187-playSoundToLocate');
147
140
  await roborockService.playSoundToLocate(duid);
148
141
  });
149
142
  }
@@ -2,13 +2,6 @@ import { debugStringify } from 'matterbridge/logger';
2
2
  import { BehaviorRoborock } from '../../BehaviorDeviceGeneric.js';
3
3
  export class BehaviorA27 extends BehaviorRoborock {
4
4
  }
5
- export var BehaviorRoborockA27;
6
- (function (BehaviorRoborockA27) {
7
- class State {
8
- device;
9
- }
10
- BehaviorRoborockA27.State = State;
11
- })(BehaviorRoborockA27 || (BehaviorRoborockA27 = {}));
12
5
  export var VacuumSuctionPowerA27;
13
6
  (function (VacuumSuctionPowerA27) {
14
7
  VacuumSuctionPowerA27[VacuumSuctionPowerA27["Quiet"] = 101] = "Quiet";
@@ -133,8 +126,8 @@ export function setCommandHandlerA27(duid, handler, logger, roborockService, cle
133
126
  logger.notice('BehaviorA27-GoHome');
134
127
  await roborockService.stopAndGoHome(duid);
135
128
  });
136
- handler.setCommandHandler('PlaySoundToLocate', async (identifyTime) => {
137
- logger.notice('BehaviorA27-PlaySoundToLocate');
129
+ handler.setCommandHandler('playSoundToLocate', async () => {
130
+ logger.notice('BehaviorA27-playSoundToLocate');
138
131
  await roborockService.playSoundToLocate(duid);
139
132
  });
140
133
  }
@@ -0,0 +1,132 @@
1
+ import { debugStringify } from 'matterbridge/logger';
2
+ import { BehaviorRoborock } from '../../BehaviorDeviceGeneric.js';
3
+ export class BehaviorA51 extends BehaviorRoborock {
4
+ }
5
+ export var VacuumSuctionPowerA51;
6
+ (function (VacuumSuctionPowerA51) {
7
+ VacuumSuctionPowerA51[VacuumSuctionPowerA51["Quiet"] = 101] = "Quiet";
8
+ VacuumSuctionPowerA51[VacuumSuctionPowerA51["Balanced"] = 102] = "Balanced";
9
+ VacuumSuctionPowerA51[VacuumSuctionPowerA51["Turbo"] = 103] = "Turbo";
10
+ VacuumSuctionPowerA51[VacuumSuctionPowerA51["Max"] = 104] = "Max";
11
+ VacuumSuctionPowerA51[VacuumSuctionPowerA51["Off"] = 105] = "Off";
12
+ VacuumSuctionPowerA51[VacuumSuctionPowerA51["Custom"] = 106] = "Custom";
13
+ VacuumSuctionPowerA51[VacuumSuctionPowerA51["MaxPlus"] = 108] = "MaxPlus";
14
+ })(VacuumSuctionPowerA51 || (VacuumSuctionPowerA51 = {}));
15
+ export var MopWaterFlowA51;
16
+ (function (MopWaterFlowA51) {
17
+ MopWaterFlowA51[MopWaterFlowA51["Off"] = 200] = "Off";
18
+ MopWaterFlowA51[MopWaterFlowA51["Low"] = 201] = "Low";
19
+ MopWaterFlowA51[MopWaterFlowA51["Medium"] = 202] = "Medium";
20
+ MopWaterFlowA51[MopWaterFlowA51["High"] = 203] = "High";
21
+ MopWaterFlowA51[MopWaterFlowA51["Custom"] = 204] = "Custom";
22
+ })(MopWaterFlowA51 || (MopWaterFlowA51 = {}));
23
+ export var MopRouteA51;
24
+ (function (MopRouteA51) {
25
+ MopRouteA51[MopRouteA51["Standard"] = 300] = "Standard";
26
+ MopRouteA51[MopRouteA51["Deep"] = 301] = "Deep";
27
+ MopRouteA51[MopRouteA51["Custom"] = 302] = "Custom";
28
+ MopRouteA51[MopRouteA51["DeepPlus"] = 303] = "DeepPlus";
29
+ MopRouteA51[MopRouteA51["Fast"] = 304] = "Fast";
30
+ })(MopRouteA51 || (MopRouteA51 = {}));
31
+ const RvcRunMode = {
32
+ [1]: 'Idle',
33
+ [2]: 'Cleaning',
34
+ [3]: 'Mapping',
35
+ };
36
+ const RvcCleanMode = {
37
+ [5]: 'Mop',
38
+ [6]: 'Vacuum',
39
+ [7]: 'Vac & Mop',
40
+ [8]: 'Custom',
41
+ };
42
+ const CleanSetting = {
43
+ [5]: { suctionPower: VacuumSuctionPowerA51.Off, waterFlow: MopWaterFlowA51.Medium, distance_off: 0, mopRoute: MopRouteA51.Standard },
44
+ [6]: { suctionPower: VacuumSuctionPowerA51.Balanced, waterFlow: MopWaterFlowA51.Off, distance_off: 0, mopRoute: MopRouteA51.Standard },
45
+ [7]: { suctionPower: VacuumSuctionPowerA51.Balanced, waterFlow: MopWaterFlowA51.Medium, distance_off: 0, mopRoute: MopRouteA51.Standard },
46
+ [8]: { suctionPower: VacuumSuctionPowerA51.Custom, waterFlow: MopWaterFlowA51.Custom, distance_off: 0, mopRoute: MopRouteA51.Custom },
47
+ };
48
+ export function setCommandHandlerA51(duid, handler, logger, roborockService, cleanModeSettings) {
49
+ handler.setCommandHandler('changeToMode', async (newMode) => {
50
+ const activity = RvcRunMode[newMode] || RvcCleanMode[newMode];
51
+ switch (activity) {
52
+ case 'Cleaning': {
53
+ await roborockService.startClean(duid);
54
+ return;
55
+ }
56
+ case 'Mop':
57
+ case 'Vacuum':
58
+ case 'Vac & Mop': {
59
+ const setting = cleanModeSettings ? getSettingFromCleanMode(activity, cleanModeSettings) : CleanSetting[newMode];
60
+ logger.notice(`BehaviorA51-ChangeCleanMode to: ${activity}, setting: ${debugStringify(setting ?? {})}`);
61
+ if (setting) {
62
+ await roborockService.changeCleanMode(duid, setting);
63
+ }
64
+ return;
65
+ }
66
+ case 'Custom': {
67
+ const setting = CleanSetting[newMode];
68
+ logger.notice(`BehaviorA51-ChangeCleanMode to: ${activity}, setting: ${debugStringify(setting)}`);
69
+ await roborockService.changeCleanMode(duid, setting);
70
+ return;
71
+ }
72
+ default:
73
+ logger.notice('BehaviorA51-changeToMode-Unknown: ', newMode);
74
+ return;
75
+ }
76
+ });
77
+ handler.setCommandHandler('selectAreas', async (newAreas) => {
78
+ logger.notice(`BehaviorA51-selectAreas: ${newAreas}`);
79
+ roborockService.setSelectedAreas(duid, newAreas ?? []);
80
+ });
81
+ handler.setCommandHandler('pause', async () => {
82
+ logger.notice('BehaviorA51-Pause');
83
+ await roborockService.pauseClean(duid);
84
+ });
85
+ handler.setCommandHandler('resume', async () => {
86
+ logger.notice('BehaviorA51-Resume');
87
+ await roborockService.resumeClean(duid);
88
+ });
89
+ handler.setCommandHandler('goHome', async () => {
90
+ logger.notice('BehaviorA51-GoHome');
91
+ await roborockService.stopAndGoHome(duid);
92
+ });
93
+ handler.setCommandHandler('playSoundToLocate', async () => {
94
+ logger.notice('BehaviorA51-playSoundToLocate');
95
+ await roborockService.playSoundToLocate(duid);
96
+ });
97
+ const getSettingFromCleanMode = (activity, cleanModeSettings) => {
98
+ switch (activity) {
99
+ case 'Mop': {
100
+ const mopSetting = cleanModeSettings?.mopping;
101
+ const waterFlow = MopWaterFlowA51[mopSetting?.waterFlowMode] ?? MopWaterFlowA51.Medium;
102
+ return {
103
+ suctionPower: VacuumSuctionPowerA51.Off,
104
+ waterFlow,
105
+ distance_off: 0,
106
+ mopRoute: MopRouteA51[mopSetting?.mopRouteMode] ?? MopRouteA51.Standard,
107
+ };
108
+ }
109
+ case 'Vacuum': {
110
+ const vacuumSetting = cleanModeSettings?.vacuuming;
111
+ return {
112
+ suctionPower: VacuumSuctionPowerA51[vacuumSetting?.fanMode] ?? VacuumSuctionPowerA51.Balanced,
113
+ waterFlow: MopWaterFlowA51.Off,
114
+ distance_off: 0,
115
+ mopRoute: MopRouteA51[vacuumSetting?.mopRouteMode] ?? MopRouteA51.Standard,
116
+ };
117
+ }
118
+ case 'Vac & Mop': {
119
+ const vacmopSetting = cleanModeSettings?.vacmop;
120
+ const waterFlow = MopWaterFlowA51[vacmopSetting?.waterFlowMode] ?? MopWaterFlowA51.Medium;
121
+ return {
122
+ suctionPower: VacuumSuctionPowerA51[vacmopSetting?.fanMode] ?? VacuumSuctionPowerA51.Balanced,
123
+ waterFlow,
124
+ distance_off: 0,
125
+ mopRoute: MopRouteA51[vacmopSetting?.mopRouteMode] ?? MopRouteA51.Standard,
126
+ };
127
+ }
128
+ default:
129
+ return undefined;
130
+ }
131
+ };
132
+ }
@@ -0,0 +1,76 @@
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: 'Mop',
25
+ mode: 5,
26
+ modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Auto }],
27
+ },
28
+ {
29
+ label: 'Vacuum',
30
+ mode: 6,
31
+ modeTags: [{ value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.Auto }],
32
+ },
33
+ {
34
+ label: 'Mop & Vacuum',
35
+ mode: 7,
36
+ modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.DeepClean }],
37
+ },
38
+ {
39
+ label: 'Custom',
40
+ mode: 8,
41
+ modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.Quick }],
42
+ },
43
+ ];
44
+ }
45
+ export function getDefaultOperationalStates() {
46
+ return [
47
+ {
48
+ operationalStateId: RvcOperationalState.OperationalState.Stopped,
49
+ operationalStateLabel: 'Stopped',
50
+ },
51
+ {
52
+ operationalStateId: RvcOperationalState.OperationalState.Running,
53
+ operationalStateLabel: 'Running',
54
+ },
55
+ {
56
+ operationalStateId: RvcOperationalState.OperationalState.Paused,
57
+ operationalStateLabel: 'Paused',
58
+ },
59
+ {
60
+ operationalStateId: RvcOperationalState.OperationalState.Error,
61
+ operationalStateLabel: 'Error',
62
+ },
63
+ {
64
+ operationalStateId: RvcOperationalState.OperationalState.SeekingCharger,
65
+ operationalStateLabel: 'SeekingCharger',
66
+ },
67
+ {
68
+ operationalStateId: RvcOperationalState.OperationalState.Charging,
69
+ operationalStateLabel: 'Charging',
70
+ },
71
+ {
72
+ operationalStateId: RvcOperationalState.OperationalState.Docked,
73
+ operationalStateLabel: 'Docked',
74
+ },
75
+ ];
76
+ }
@@ -0,0 +1,33 @@
1
+ import { MopWaterFlowA51, VacuumSuctionPowerA51 } from './a51.js';
2
+ export function getCurrentCleanModeA51(fan_power, water_box_mode) {
3
+ if (!fan_power || !water_box_mode)
4
+ return undefined;
5
+ if (fan_power == VacuumSuctionPowerA51.Custom || water_box_mode == MopWaterFlowA51.Custom)
6
+ return 8;
7
+ if (fan_power == VacuumSuctionPowerA51.Off)
8
+ return 5;
9
+ if (water_box_mode == MopWaterFlowA51.Off)
10
+ return 6;
11
+ else
12
+ return 7;
13
+ }
14
+ export function getCurrentCleanModeFromFanPowerA51(fan_power) {
15
+ if (!fan_power)
16
+ return undefined;
17
+ if (fan_power == VacuumSuctionPowerA51.Custom)
18
+ return 8;
19
+ if (fan_power == VacuumSuctionPowerA51.Off)
20
+ return 5;
21
+ else
22
+ return undefined;
23
+ }
24
+ export function getCurrentCleanModeFromWaterBoxModeA51(water_box_mode) {
25
+ if (!water_box_mode)
26
+ return undefined;
27
+ if (water_box_mode == MopWaterFlowA51.Custom)
28
+ return 8;
29
+ if (water_box_mode == MopWaterFlowA51.Off)
30
+ return 6;
31
+ else
32
+ return undefined;
33
+ }
@@ -1,23 +1,51 @@
1
+ import { debugStringify } from 'matterbridge/logger';
1
2
  import { BehaviorRoborock } from '../../BehaviorDeviceGeneric.js';
2
3
  export class DefaultBehavior extends BehaviorRoborock {
3
4
  }
4
- export var DefaultBehaviorRoborock;
5
- (function (DefaultBehaviorRoborock) {
6
- class State {
7
- device;
8
- }
9
- DefaultBehaviorRoborock.State = State;
10
- })(DefaultBehaviorRoborock || (DefaultBehaviorRoborock = {}));
5
+ export var VacuumSuctionPower;
6
+ (function (VacuumSuctionPower) {
7
+ VacuumSuctionPower[VacuumSuctionPower["Quiet"] = 101] = "Quiet";
8
+ VacuumSuctionPower[VacuumSuctionPower["Balanced"] = 102] = "Balanced";
9
+ VacuumSuctionPower[VacuumSuctionPower["Turbo"] = 103] = "Turbo";
10
+ VacuumSuctionPower[VacuumSuctionPower["Max"] = 104] = "Max";
11
+ VacuumSuctionPower[VacuumSuctionPower["Off"] = 105] = "Off";
12
+ VacuumSuctionPower[VacuumSuctionPower["Custom"] = 106] = "Custom";
13
+ VacuumSuctionPower[VacuumSuctionPower["MaxPlus"] = 108] = "MaxPlus";
14
+ })(VacuumSuctionPower || (VacuumSuctionPower = {}));
15
+ export var MopWaterFlow;
16
+ (function (MopWaterFlow) {
17
+ MopWaterFlow[MopWaterFlow["Off"] = 200] = "Off";
18
+ MopWaterFlow[MopWaterFlow["Low"] = 201] = "Low";
19
+ MopWaterFlow[MopWaterFlow["Medium"] = 202] = "Medium";
20
+ MopWaterFlow[MopWaterFlow["High"] = 203] = "High";
21
+ MopWaterFlow[MopWaterFlow["Custom"] = 204] = "Custom";
22
+ })(MopWaterFlow || (MopWaterFlow = {}));
23
+ export var MopRoute;
24
+ (function (MopRoute) {
25
+ MopRoute[MopRoute["Standard"] = 300] = "Standard";
26
+ MopRoute[MopRoute["Deep"] = 301] = "Deep";
27
+ MopRoute[MopRoute["Custom"] = 302] = "Custom";
28
+ MopRoute[MopRoute["DeepPlus"] = 303] = "DeepPlus";
29
+ MopRoute[MopRoute["Fast"] = 304] = "Fast";
30
+ })(MopRoute || (MopRoute = {}));
11
31
  const RvcRunMode = {
12
32
  [1]: 'Idle',
13
33
  [2]: 'Cleaning',
14
34
  [3]: 'Mapping',
15
35
  };
16
36
  const RvcCleanMode = {
17
- [4]: 'Mop',
18
- [5]: 'Vacuum',
37
+ [5]: 'Mop',
38
+ [6]: 'Vacuum',
39
+ [7]: 'Vac & Mop',
40
+ [8]: 'Custom',
19
41
  };
20
- export function setDefaultCommandHandler(duid, handler, logger, roborockService) {
42
+ const CleanSetting = {
43
+ [5]: { suctionPower: VacuumSuctionPower.Off, waterFlow: MopWaterFlow.Medium, distance_off: 0, mopRoute: MopRoute.Standard },
44
+ [6]: { suctionPower: VacuumSuctionPower.Balanced, waterFlow: MopWaterFlow.Off, distance_off: 0, mopRoute: MopRoute.Standard },
45
+ [7]: { suctionPower: VacuumSuctionPower.Balanced, waterFlow: MopWaterFlow.Medium, distance_off: 0, mopRoute: MopRoute.Standard },
46
+ [8]: { suctionPower: VacuumSuctionPower.Custom, waterFlow: MopWaterFlow.Custom, distance_off: 0, mopRoute: MopRoute.Custom },
47
+ };
48
+ export function setDefaultCommandHandler(duid, handler, logger, roborockService, cleanModeSettings) {
21
49
  handler.setCommandHandler('changeToMode', async (newMode) => {
22
50
  const activity = RvcRunMode[newMode] || RvcCleanMode[newMode];
23
51
  switch (activity) {
@@ -26,8 +54,19 @@ export function setDefaultCommandHandler(duid, handler, logger, roborockService)
26
54
  return;
27
55
  }
28
56
  case 'Mop':
29
- case 'Vacuum': {
30
- logger.notice('DefaultBehavior-ChangeCleanMode to: ', activity);
57
+ case 'Vacuum':
58
+ case 'Vac & Mop': {
59
+ const setting = cleanModeSettings ? getSettingFromCleanMode(activity, cleanModeSettings) : CleanSetting[newMode];
60
+ logger.notice(`DefaultBehavior-ChangeCleanMode to: ${activity}, setting: ${debugStringify(setting ?? {})}`);
61
+ if (setting) {
62
+ await roborockService.changeCleanMode(duid, setting);
63
+ }
64
+ return;
65
+ }
66
+ case 'Custom': {
67
+ const setting = CleanSetting[newMode];
68
+ logger.notice(`DefaultBehavior-ChangeCleanMode to: ${activity}, setting: ${debugStringify(setting)}`);
69
+ await roborockService.changeCleanMode(duid, setting);
31
70
  return;
32
71
  }
33
72
  default:
@@ -51,8 +90,43 @@ export function setDefaultCommandHandler(duid, handler, logger, roborockService)
51
90
  logger.notice('DefaultBehavior-GoHome');
52
91
  await roborockService.stopAndGoHome(duid);
53
92
  });
54
- handler.setCommandHandler('PlaySoundToLocate', async (identifyTime) => {
55
- logger.notice('DefaultBehavior-PlaySoundToLocate');
93
+ handler.setCommandHandler('playSoundToLocate', async () => {
94
+ logger.notice('DefaultBehavior-playSoundToLocate');
56
95
  await roborockService.playSoundToLocate(duid);
57
96
  });
97
+ const getSettingFromCleanMode = (activity, cleanModeSettings) => {
98
+ switch (activity) {
99
+ case 'Mop': {
100
+ const mopSetting = cleanModeSettings?.mopping;
101
+ const waterFlow = MopWaterFlow[mopSetting?.waterFlowMode] ?? MopWaterFlow.Medium;
102
+ return {
103
+ suctionPower: VacuumSuctionPower.Off,
104
+ waterFlow,
105
+ distance_off: 0,
106
+ mopRoute: MopRoute[mopSetting?.mopRouteMode] ?? MopRoute.Standard,
107
+ };
108
+ }
109
+ case 'Vacuum': {
110
+ const vacuumSetting = cleanModeSettings?.vacuuming;
111
+ return {
112
+ suctionPower: VacuumSuctionPower[vacuumSetting?.fanMode] ?? VacuumSuctionPower.Balanced,
113
+ waterFlow: MopWaterFlow.Off,
114
+ distance_off: 0,
115
+ mopRoute: MopRoute[vacuumSetting?.mopRouteMode] ?? MopRoute.Standard,
116
+ };
117
+ }
118
+ case 'Vac & Mop': {
119
+ const vacmopSetting = cleanModeSettings?.vacmop;
120
+ const waterFlow = MopWaterFlow[vacmopSetting?.waterFlowMode] ?? MopWaterFlow.Medium;
121
+ return {
122
+ suctionPower: VacuumSuctionPower[vacmopSetting?.fanMode] ?? VacuumSuctionPower.Balanced,
123
+ waterFlow,
124
+ distance_off: 0,
125
+ mopRoute: MopRoute[vacmopSetting?.mopRouteMode] ?? MopRoute.Standard,
126
+ };
127
+ }
128
+ default:
129
+ return undefined;
130
+ }
131
+ };
58
132
  }