matterbridge-roborock-vacuum-plugin 1.1.1-rc02 → 1.1.1-rc05
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/.github/workflows/build.yml +1 -1
- package/dist/platform.js +2 -2
- package/dist/roborockCommunication/broadcast/listener/implementation/generalSyncMessageListener.js +28 -0
- package/matterbridge-roborock-vacuum-plugin.config.json +1 -1
- package/matterbridge-roborock-vacuum-plugin.schema.json +1 -1
- package/package.json +2 -2
- package/src/platform.ts +2 -2
- package/src/roborockCommunication/broadcast/listener/implementation/generalSyncMessageListener.ts +38 -0
- package/src/tests/platformRunner3.test.ts +0 -8
- package/src/tests/roborockCommunication/broadcast/client/LocalNetworkClient.test.ts +5 -0
package/dist/platform.js
CHANGED
|
@@ -26,8 +26,8 @@ export class RoborockMatterbridgePlatform extends MatterbridgeDynamicPlatform {
|
|
|
26
26
|
rrHomeId;
|
|
27
27
|
constructor(matterbridge, log, config) {
|
|
28
28
|
super(matterbridge, log, config);
|
|
29
|
-
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('3.2.
|
|
30
|
-
throw new Error(`This plugin requires Matterbridge version >= "3.2.
|
|
29
|
+
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('3.2.2')) {
|
|
30
|
+
throw new Error(`This plugin requires Matterbridge version >= "3.2.2". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend.`);
|
|
31
31
|
}
|
|
32
32
|
this.log.info('Initializing platform:', this.config.name);
|
|
33
33
|
if (config.whiteList === undefined)
|
package/dist/roborockCommunication/broadcast/listener/implementation/generalSyncMessageListener.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Protocol } from '../../model/protocol.js';
|
|
2
|
+
export class GeneralSyncMessageListener {
|
|
3
|
+
duid;
|
|
4
|
+
handler;
|
|
5
|
+
timer;
|
|
6
|
+
constructor(duid) {
|
|
7
|
+
this.duid = duid;
|
|
8
|
+
}
|
|
9
|
+
waitFor() {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
this.handler = resolve;
|
|
12
|
+
this.timer = setTimeout(() => {
|
|
13
|
+
reject('no ping response received for ' + this.duid + ' within ' + 30 + 'second');
|
|
14
|
+
}, 30 * 1000);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async onMessage(message) {
|
|
18
|
+
if (message.contain(Protocol.hello_response)) {
|
|
19
|
+
if (this.handler) {
|
|
20
|
+
this.handler(message);
|
|
21
|
+
}
|
|
22
|
+
if (this.timer) {
|
|
23
|
+
clearTimeout(this.timer);
|
|
24
|
+
this.timer.unref();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"title": "Matterbridge Roborock Vacuum Plugin",
|
|
3
|
-
"description": "matterbridge-roborock-vacuum-plugin v. 1.1.1-
|
|
3
|
+
"description": "matterbridge-roborock-vacuum-plugin v. 1.1.1-rc05 by https://github.com/RinDevJunior",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"required": ["username", "password"],
|
|
6
6
|
"properties": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matterbridge-roborock-vacuum-plugin",
|
|
3
|
-
"version": "1.1.1-
|
|
3
|
+
"version": "1.1.1-rc05",
|
|
4
4
|
"description": "Matterbridge Roborock Vacuum Plugin",
|
|
5
5
|
"author": "https://github.com/RinDevJunior",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"apple home"
|
|
32
32
|
],
|
|
33
33
|
"engines": {
|
|
34
|
-
"node": ">=22.0.0"
|
|
34
|
+
"node": ">=20.0.0 <21.0.0 || >=22.0.0 <23.0.0 || >=24.0.0 <25.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@log4js-node/log4js-api": "^1.0.2",
|
package/src/platform.ts
CHANGED
|
@@ -33,9 +33,9 @@ export class RoborockMatterbridgePlatform extends MatterbridgeDynamicPlatform {
|
|
|
33
33
|
super(matterbridge, log, config);
|
|
34
34
|
|
|
35
35
|
// Verify that Matterbridge is the correct version
|
|
36
|
-
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('3.2.
|
|
36
|
+
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('3.2.2')) {
|
|
37
37
|
throw new Error(
|
|
38
|
-
`This plugin requires Matterbridge version >= "3.2.
|
|
38
|
+
`This plugin requires Matterbridge version >= "3.2.2". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend.`,
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
this.log.info('Initializing platform:', this.config.name);
|
package/src/roborockCommunication/broadcast/listener/implementation/generalSyncMessageListener.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Protocol } from '../../model/protocol.js';
|
|
2
|
+
import { ResponseMessage } from '../../model/responseMessage.js';
|
|
3
|
+
import { AbstractMessageListener } from '../abstractMessageListener.js';
|
|
4
|
+
|
|
5
|
+
export class GeneralSyncMessageListener implements AbstractMessageListener {
|
|
6
|
+
private readonly duid: string;
|
|
7
|
+
|
|
8
|
+
private handler?: (data: ResponseMessage) => void;
|
|
9
|
+
private timer?: NodeJS.Timeout;
|
|
10
|
+
|
|
11
|
+
constructor(duid: string) {
|
|
12
|
+
this.duid = duid;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public waitFor(): Promise<ResponseMessage> {
|
|
16
|
+
return new Promise<ResponseMessage>((resolve, reject) => {
|
|
17
|
+
this.handler = resolve;
|
|
18
|
+
this.timer = setTimeout(() => {
|
|
19
|
+
reject('no ping response received for ' + this.duid + ' within ' + 30 + 'second');
|
|
20
|
+
}, 30 * 1000);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public async onMessage(message: ResponseMessage): Promise<void> {
|
|
25
|
+
if (message.contain(Protocol.hello_response)) {
|
|
26
|
+
// trigger our waiters that we have received the response.
|
|
27
|
+
if (this.handler) {
|
|
28
|
+
this.handler(message);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// cleanup the timer
|
|
32
|
+
if (this.timer) {
|
|
33
|
+
clearTimeout(this.timer);
|
|
34
|
+
this.timer.unref();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -2,14 +2,6 @@ import { PlatformRunner } from '../platformRunner';
|
|
|
2
2
|
import { NotifyMessageTypes } from '../notifyMessageTypes';
|
|
3
3
|
import { RoborockMatterbridgePlatform } from '../platform';
|
|
4
4
|
import { RoborockVacuumCleaner } from '../rvc';
|
|
5
|
-
import * as initialDataIndex from '../initialData/index';
|
|
6
|
-
|
|
7
|
-
const getOperationalErrorState = jest.fn().mockReturnValue(2);
|
|
8
|
-
|
|
9
|
-
jest.mock('./src/initialData/index', () => ({
|
|
10
|
-
...initialDataIndex,
|
|
11
|
-
getOperationalErrorState,
|
|
12
|
-
}));
|
|
13
5
|
|
|
14
6
|
describe('PlatformRunner.updateRobot', () => {
|
|
15
7
|
let platform: RoborockMatterbridgePlatform;
|
|
@@ -52,6 +52,11 @@ describe('LocalNetworkClient', () => {
|
|
|
52
52
|
afterEach(() => {
|
|
53
53
|
jest.clearAllMocks();
|
|
54
54
|
jest.useRealTimers();
|
|
55
|
+
// Clear keepConnectionAliveInterval to prevent open handle leaks
|
|
56
|
+
if (client['keepConnectionAliveInterval']) {
|
|
57
|
+
clearInterval(client['keepConnectionAliveInterval']);
|
|
58
|
+
client['keepConnectionAliveInterval'] = undefined;
|
|
59
|
+
}
|
|
55
60
|
});
|
|
56
61
|
|
|
57
62
|
it('should initialize fields in constructor', () => {
|