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.
- package/.github/workflows/publish.yml +34 -0
- package/.tarignore +5 -0
- package/LICENSE +202 -0
- package/README.md +34 -0
- package/README_DEV.md +69 -0
- package/bmc-button.svg +22 -0
- package/dist/appliances.js +6 -0
- package/dist/behaviorFactory.js +18 -0
- package/dist/behaviors/BehaviorDeviceGeneric.js +31 -0
- package/dist/behaviors/roborock.vacuum/QREVO_EDGE_5V1/a187.js +94 -0
- package/dist/behaviors/roborock.vacuum/QREVO_EDGE_5V1/initalData.js +81 -0
- package/dist/behaviors/roborock.vacuum/QREVO_EDGE_5V1/runtimes.js +39 -0
- package/dist/behaviors/roborock.vacuum/default/default.js +58 -0
- package/dist/behaviors/roborock.vacuum/default/initalData.js +66 -0
- package/dist/clientManager.js +17 -0
- package/dist/extensions/AxiosStaticExtensions.js +22 -0
- package/dist/extensions/index.js +1 -0
- package/dist/helper.js +16 -0
- package/dist/index.js +4 -0
- package/dist/initialData/getBatteryStatus.js +24 -0
- package/dist/initialData/getOperationalStates.js +22 -0
- package/dist/initialData/getSupportedAreas.js +69 -0
- package/dist/initialData/getSupportedCleanModes.js +11 -0
- package/dist/initialData/getSupportedRunModes.js +18 -0
- package/dist/initialData/index.js +5 -0
- package/dist/model/CloudMessageModel.js +1 -0
- package/dist/model/DockingStationStatus.js +24 -0
- package/dist/model/RoomMap.js +18 -0
- package/dist/notifyMessageTypes.js +9 -0
- package/dist/platform.js +146 -0
- package/dist/platformRunner.js +249 -0
- package/dist/roborockCommunication/RESTAPI/roborockAuthenticateApi.js +73 -0
- package/dist/roborockCommunication/RESTAPI/roborockIoTApi.js +61 -0
- package/dist/roborockCommunication/Zenum/dockType.js +4 -0
- package/dist/roborockCommunication/Zenum/operationStatusCode.js +44 -0
- package/dist/roborockCommunication/Zenum/vacuumAndDockErrorCode.js +68 -0
- package/dist/roborockCommunication/Zmodel/apiResponse.js +1 -0
- package/dist/roborockCommunication/Zmodel/authenticateResponse.js +1 -0
- package/dist/roborockCommunication/Zmodel/baseURL.js +1 -0
- package/dist/roborockCommunication/Zmodel/device.js +1 -0
- package/dist/roborockCommunication/Zmodel/deviceModel.js +28 -0
- package/dist/roborockCommunication/Zmodel/deviceSchema.js +1 -0
- package/dist/roborockCommunication/Zmodel/deviceStatus.js +22 -0
- package/dist/roborockCommunication/Zmodel/dockInfo.js +6 -0
- package/dist/roborockCommunication/Zmodel/home.js +1 -0
- package/dist/roborockCommunication/Zmodel/homeInfo.js +1 -0
- package/dist/roborockCommunication/Zmodel/messageResult.js +7 -0
- package/dist/roborockCommunication/Zmodel/networkInfo.js +1 -0
- package/dist/roborockCommunication/Zmodel/product.js +1 -0
- package/dist/roborockCommunication/Zmodel/room.js +1 -0
- package/dist/roborockCommunication/Zmodel/roomInfo.js +22 -0
- package/dist/roborockCommunication/Zmodel/userData.js +1 -0
- package/dist/roborockCommunication/Zmodel/vacuumError.js +27 -0
- package/dist/roborockCommunication/broadcast/abstractClient.js +41 -0
- package/dist/roborockCommunication/broadcast/client/LocalNetworkClient.js +148 -0
- package/dist/roborockCommunication/broadcast/client/MQTTClient.js +101 -0
- package/dist/roborockCommunication/broadcast/client.js +1 -0
- package/dist/roborockCommunication/broadcast/clientRouter.js +79 -0
- package/dist/roborockCommunication/broadcast/listener/abstractConnectionListener.js +1 -0
- package/dist/roborockCommunication/broadcast/listener/abstractMessageHandler.js +1 -0
- package/dist/roborockCommunication/broadcast/listener/abstractMessageListener.js +1 -0
- package/dist/roborockCommunication/broadcast/listener/implementation/chainedConnectionListener.js +21 -0
- package/dist/roborockCommunication/broadcast/listener/implementation/chainedMessageListener.js +11 -0
- package/dist/roborockCommunication/broadcast/listener/implementation/simpleMessageListener.js +27 -0
- package/dist/roborockCommunication/broadcast/listener/implementation/syncMessageListener.js +35 -0
- package/dist/roborockCommunication/broadcast/listener/index.js +1 -0
- package/dist/roborockCommunication/broadcast/messageProcessor.js +79 -0
- package/dist/roborockCommunication/broadcast/model/dps.js +1 -0
- package/dist/roborockCommunication/broadcast/model/messageContext.js +26 -0
- package/dist/roborockCommunication/broadcast/model/protocol.js +19 -0
- package/dist/roborockCommunication/broadcast/model/requestMessage.js +33 -0
- package/dist/roborockCommunication/broadcast/model/responseMessage.js +14 -0
- package/dist/roborockCommunication/helper/chunkBuffer.js +17 -0
- package/dist/roborockCommunication/helper/cryptoHelper.js +27 -0
- package/dist/roborockCommunication/helper/messageDeserializer.js +74 -0
- package/dist/roborockCommunication/helper/messageSerializer.js +70 -0
- package/dist/roborockCommunication/helper/nameDecoder.js +66 -0
- package/dist/roborockCommunication/helper/sequence.js +16 -0
- package/dist/roborockCommunication/index.js +9 -0
- package/dist/roborockService.js +300 -0
- package/dist/rvc.js +39 -0
- package/dist/settings.js +1 -0
- package/dist/share/function.js +96 -0
- package/dist/share/runtimeHelper.js +29 -0
- package/eslint.config.js +76 -0
- package/matterbridge-roborock-vacuum-plugin.config.json +11 -0
- package/matterbridge-roborock-vacuum-plugin.schema.json +57 -0
- package/package.json +43 -0
- package/prettier.config.js +49 -0
- package/src/appliances.ts +15 -0
- package/src/behaviorFactory.ts +24 -0
- package/src/behaviors/BehaviorDeviceGeneric.ts +39 -0
- package/src/behaviors/roborock.vacuum/QREVO_EDGE_5V1/a187.ts +117 -0
- package/src/behaviors/roborock.vacuum/QREVO_EDGE_5V1/initalData.ts +85 -0
- package/src/behaviors/roborock.vacuum/QREVO_EDGE_5V1/runtimes.ts +29 -0
- package/src/behaviors/roborock.vacuum/default/default.ts +78 -0
- package/src/behaviors/roborock.vacuum/default/initalData.ts +69 -0
- package/src/clientManager.ts +23 -0
- package/src/extensions/AxiosStaticExtensions.ts +35 -0
- package/src/extensions/index.ts +1 -0
- package/src/helper.ts +22 -0
- package/src/index.ts +16 -0
- package/src/initialData/getBatteryStatus.ts +26 -0
- package/src/initialData/getOperationalStates.ts +24 -0
- package/src/initialData/getSupportedAreas.ts +95 -0
- package/src/initialData/getSupportedCleanModes.ts +13 -0
- package/src/initialData/getSupportedRunModes.ts +21 -0
- package/src/initialData/index.ts +5 -0
- package/src/model/CloudMessageModel.ts +13 -0
- package/src/model/DockingStationStatus.ts +37 -0
- package/src/model/RoomMap.ts +44 -0
- package/src/notifyMessageTypes.ts +8 -0
- package/src/platform.ts +192 -0
- package/src/platformRunner.ts +292 -0
- package/src/roborockCommunication/RESTAPI/roborockAuthenticateApi.ts +98 -0
- package/src/roborockCommunication/RESTAPI/roborockIoTApi.ts +70 -0
- package/src/roborockCommunication/Zenum/dockType.ts +3 -0
- package/src/roborockCommunication/Zenum/operationStatusCode.ts +43 -0
- package/src/roborockCommunication/Zenum/vacuumAndDockErrorCode.ts +68 -0
- package/src/roborockCommunication/Zmodel/apiResponse.ts +3 -0
- package/src/roborockCommunication/Zmodel/authenticateResponse.ts +5 -0
- package/src/roborockCommunication/Zmodel/baseURL.ts +5 -0
- package/src/roborockCommunication/Zmodel/device.ts +39 -0
- package/src/roborockCommunication/Zmodel/deviceModel.ts +27 -0
- package/src/roborockCommunication/Zmodel/deviceSchema.ts +8 -0
- package/src/roborockCommunication/Zmodel/deviceStatus.ts +30 -0
- package/src/roborockCommunication/Zmodel/dockInfo.ts +9 -0
- package/src/roborockCommunication/Zmodel/home.ts +13 -0
- package/src/roborockCommunication/Zmodel/homeInfo.ts +5 -0
- package/src/roborockCommunication/Zmodel/messageResult.ts +72 -0
- package/src/roborockCommunication/Zmodel/networkInfo.ts +7 -0
- package/src/roborockCommunication/Zmodel/product.ts +9 -0
- package/src/roborockCommunication/Zmodel/room.ts +4 -0
- package/src/roborockCommunication/Zmodel/roomInfo.ts +25 -0
- package/src/roborockCommunication/Zmodel/userData.ts +23 -0
- package/src/roborockCommunication/Zmodel/vacuumError.ts +35 -0
- package/src/roborockCommunication/broadcast/abstractClient.ts +61 -0
- package/src/roborockCommunication/broadcast/client/LocalNetworkClient.ts +177 -0
- package/src/roborockCommunication/broadcast/client/MQTTClient.ts +129 -0
- package/src/roborockCommunication/broadcast/client.ts +19 -0
- package/src/roborockCommunication/broadcast/clientRouter.ts +100 -0
- package/src/roborockCommunication/broadcast/listener/abstractConnectionListener.ts +5 -0
- package/src/roborockCommunication/broadcast/listener/abstractMessageHandler.ts +11 -0
- package/src/roborockCommunication/broadcast/listener/abstractMessageListener.ts +5 -0
- package/src/roborockCommunication/broadcast/listener/implementation/chainedConnectionListener.ts +26 -0
- package/src/roborockCommunication/broadcast/listener/implementation/chainedMessageListener.ts +16 -0
- package/src/roborockCommunication/broadcast/listener/implementation/simpleMessageListener.ts +37 -0
- package/src/roborockCommunication/broadcast/listener/implementation/syncMessageListener.ts +48 -0
- package/src/roborockCommunication/broadcast/listener/index.ts +3 -0
- package/src/roborockCommunication/broadcast/messageProcessor.ts +110 -0
- package/src/roborockCommunication/broadcast/model/dps.ts +17 -0
- package/src/roborockCommunication/broadcast/model/messageContext.ts +34 -0
- package/src/roborockCommunication/broadcast/model/protocol.ts +19 -0
- package/src/roborockCommunication/broadcast/model/requestMessage.ts +44 -0
- package/src/roborockCommunication/broadcast/model/responseMessage.ts +19 -0
- package/src/roborockCommunication/helper/chunkBuffer.ts +18 -0
- package/src/roborockCommunication/helper/cryptoHelper.ts +34 -0
- package/src/roborockCommunication/helper/messageDeserializer.ts +99 -0
- package/src/roborockCommunication/helper/messageSerializer.ts +82 -0
- package/src/roborockCommunication/helper/nameDecoder.ts +78 -0
- package/src/roborockCommunication/helper/sequence.ts +18 -0
- package/src/roborockCommunication/index.ts +15 -0
- package/src/roborockService.ts +379 -0
- package/src/rvc.ts +66 -0
- package/src/settings.ts +1 -0
- package/src/share/function.ts +106 -0
- package/src/share/runtimeHelper.ts +35 -0
- package/tsconfig.json +37 -0
- package/tsconfig.production.json +19 -0
- package/tslint.json +9 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/*
|
|
3
|
+
|
|
4
|
+
prettier.config.js
|
|
5
|
+
|
|
6
|
+
Prettier:
|
|
7
|
+
|
|
8
|
+
How to install:
|
|
9
|
+
npm install --save-dev prettier eslint-config-prettier eslint-plugin-prettier
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Add package.json scripts:
|
|
13
|
+
*/
|
|
14
|
+
// "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
|
|
15
|
+
// "format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
|
|
19
|
+
Add .prettierignore
|
|
20
|
+
|
|
21
|
+
# Ignore artifacts:
|
|
22
|
+
dist
|
|
23
|
+
node_modules
|
|
24
|
+
build
|
|
25
|
+
coverage
|
|
26
|
+
|
|
27
|
+
# Ignore all HTML files:
|
|
28
|
+
*/
|
|
29
|
+
// **/*.html
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
printWidth: 180, // default 80
|
|
33
|
+
tabWidth: 2,
|
|
34
|
+
useTabs: false,
|
|
35
|
+
semi: true,
|
|
36
|
+
singleQuote: true, // default false
|
|
37
|
+
quoteProps: 'preserve', // default 'as-needed'
|
|
38
|
+
jsxSingleQuote: false,
|
|
39
|
+
trailingComma: 'all',
|
|
40
|
+
bracketSpacing: true,
|
|
41
|
+
bracketSameLine: false,
|
|
42
|
+
arrowParens: 'always',
|
|
43
|
+
requirePragma: false,
|
|
44
|
+
insertPragma: false,
|
|
45
|
+
proseWrap: 'preserve',
|
|
46
|
+
endOfLine: 'lf',
|
|
47
|
+
embeddedLanguageFormatting: 'off', // default 'auto'
|
|
48
|
+
singleAttributePerLine: false,
|
|
49
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeviceTypeDefinition,
|
|
3
|
+
MatterbridgeEndpoint,
|
|
4
|
+
powerSource,
|
|
5
|
+
} from "matterbridge";
|
|
6
|
+
|
|
7
|
+
export class Appliances extends MatterbridgeEndpoint {
|
|
8
|
+
constructor(deviceType: DeviceTypeDefinition, name: string, serial: string) {
|
|
9
|
+
super(
|
|
10
|
+
[deviceType, powerSource],
|
|
11
|
+
{ uniqueStorageKey: `${name}-${serial}` },
|
|
12
|
+
true,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AnsiLogger } from 'matterbridge/logger';
|
|
2
|
+
import { BehaviorDeviceGeneric } from './behaviors/BehaviorDeviceGeneric.js';
|
|
3
|
+
import { EndpointCommandsA187, setCommandHandlerA187 } from './behaviors/roborock.vacuum/QREVO_EDGE_5V1/a187.js';
|
|
4
|
+
import RoborockService from './roborockService.js';
|
|
5
|
+
import { DefaultEndpointCommands, setDefaultCommandHandler } from './behaviors/roborock.vacuum/default/default.js';
|
|
6
|
+
import { DeviceModel } from './roborockCommunication/Zmodel/deviceModel.js';
|
|
7
|
+
|
|
8
|
+
export type BehaviorFactoryResult = BehaviorDeviceGeneric<DefaultEndpointCommands> | BehaviorDeviceGeneric<EndpointCommandsA187>;
|
|
9
|
+
|
|
10
|
+
export function configurateBehavior(model: string, duid: string, roborockService: RoborockService, logger: AnsiLogger): BehaviorFactoryResult {
|
|
11
|
+
switch (model) {
|
|
12
|
+
case DeviceModel.QREVO_EDGE_5V1: {
|
|
13
|
+
const deviceHandler = new BehaviorDeviceGeneric<EndpointCommandsA187>(logger);
|
|
14
|
+
setCommandHandlerA187(duid, deviceHandler, logger, roborockService);
|
|
15
|
+
return deviceHandler;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
default: {
|
|
19
|
+
const deviceHandler = new BehaviorDeviceGeneric<DefaultEndpointCommands>(logger);
|
|
20
|
+
setDefaultCommandHandler(duid, deviceHandler, logger, roborockService);
|
|
21
|
+
return deviceHandler;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AnsiLogger } from 'matterbridge/logger';
|
|
2
|
+
import { Behavior, MaybePromise } from 'matterbridge/matter';
|
|
3
|
+
|
|
4
|
+
export type DeviceCommandHandler = (...args: any[]) => MaybePromise;
|
|
5
|
+
|
|
6
|
+
export interface DeviceCommands {
|
|
7
|
+
[command: string]: DeviceCommandHandler;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class BehaviorDeviceGeneric<Commands extends DeviceCommands> {
|
|
11
|
+
readonly commands: Partial<Commands> = {};
|
|
12
|
+
constructor(readonly log: AnsiLogger) {}
|
|
13
|
+
|
|
14
|
+
setCommandHandler<Command extends keyof Commands>(command: Command, handler: Commands[Command]): void {
|
|
15
|
+
if (this.commands[command]) throw new Error(`Handler already registered for command ${String(command)}`);
|
|
16
|
+
this.commands[command] = handler;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async executeCommand<Command extends keyof Commands>(command: Command, ...args: Parameters<Commands[Command]>): Promise<void> {
|
|
20
|
+
const handler = this.commands[command];
|
|
21
|
+
if (!handler) throw new Error(`${String(command)} not implemented`);
|
|
22
|
+
await (handler as DeviceCommandHandler)(...args);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class BehaviorGeneric<StateType extends {}> extends Behavior {
|
|
27
|
+
static override readonly id: string;
|
|
28
|
+
declare state: StateType;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class BehaviorRoborock extends Behavior {
|
|
32
|
+
static override readonly id = 'roborock.vacuum.axx';
|
|
33
|
+
declare state: BehaviorRoborock.State;
|
|
34
|
+
}
|
|
35
|
+
export namespace BehaviorRoborock {
|
|
36
|
+
export class State {
|
|
37
|
+
device!: BehaviorDeviceGeneric<DeviceCommands>;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { MaybePromise } from 'matterbridge/matter';
|
|
2
|
+
import { AnsiLogger } from 'matterbridge/logger';
|
|
3
|
+
import { BehaviorDeviceGeneric, BehaviorRoborock, DeviceCommands } from '../../BehaviorDeviceGeneric.js';
|
|
4
|
+
import RoborockService from '../../../roborockService.js';
|
|
5
|
+
|
|
6
|
+
export interface EndpointCommandsA187 extends DeviceCommands {
|
|
7
|
+
selectAreas: (newAreas: any) => MaybePromise;
|
|
8
|
+
changeToMode: (newMode: number) => MaybePromise;
|
|
9
|
+
pause: () => MaybePromise;
|
|
10
|
+
resume: () => MaybePromise;
|
|
11
|
+
goHome: () => MaybePromise;
|
|
12
|
+
PlaySoundToLocate: (identifyTime: number) => MaybePromise;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class BehaviorA187 extends BehaviorRoborock {
|
|
16
|
+
declare state: BehaviorRoborockA187.State;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export namespace BehaviorRoborockA187 {
|
|
20
|
+
export class State {
|
|
21
|
+
device!: BehaviorDeviceGeneric<EndpointCommandsA187>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//suction_power
|
|
26
|
+
export enum VacuumSuctionPowerA187 {
|
|
27
|
+
Quiet = 101,
|
|
28
|
+
Balanced = 102,
|
|
29
|
+
Turbo = 103,
|
|
30
|
+
Max = 104,
|
|
31
|
+
Off = 105,
|
|
32
|
+
Custom = 106,
|
|
33
|
+
MaxPlus = 108,
|
|
34
|
+
Smart = 110,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//water_box_mode
|
|
38
|
+
export enum MopWaterFlowA187 {
|
|
39
|
+
Off = 200,
|
|
40
|
+
Low = 201,
|
|
41
|
+
Medium = 202,
|
|
42
|
+
High = 203,
|
|
43
|
+
Custom = 204,
|
|
44
|
+
Smart = 209,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const RvcRunMode: Record<number, string> = {
|
|
48
|
+
[1]: 'Idle', //DO NOT HANDLE HERE,
|
|
49
|
+
[2]: 'Cleaning',
|
|
50
|
+
[3]: 'Mapping',
|
|
51
|
+
};
|
|
52
|
+
const RvcCleanMode: Record<number, string> = {
|
|
53
|
+
[4]: 'Smart Plan',
|
|
54
|
+
[5]: 'Mop',
|
|
55
|
+
[6]: 'Vacuum',
|
|
56
|
+
[7]: 'Vac & Mop',
|
|
57
|
+
[8]: 'Custom',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const CleanSetting: Record<number, { suctionPower: VacuumSuctionPowerA187; waterFlow: MopWaterFlowA187 }> = {
|
|
61
|
+
[4]: { suctionPower: VacuumSuctionPowerA187.Smart, waterFlow: MopWaterFlowA187.Smart },
|
|
62
|
+
[5]: { suctionPower: VacuumSuctionPowerA187.Off, waterFlow: MopWaterFlowA187.Medium },
|
|
63
|
+
[6]: { suctionPower: VacuumSuctionPowerA187.Balanced, waterFlow: MopWaterFlowA187.Off },
|
|
64
|
+
[7]: { suctionPower: VacuumSuctionPowerA187.Balanced, waterFlow: MopWaterFlowA187.Medium },
|
|
65
|
+
[8]: { suctionPower: VacuumSuctionPowerA187.Custom, waterFlow: MopWaterFlowA187.Custom },
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export function setCommandHandlerA187(duid: string, handler: BehaviorDeviceGeneric<DeviceCommands>, logger: AnsiLogger, roborockService: RoborockService): void {
|
|
69
|
+
handler.setCommandHandler('changeToMode', async (newMode: number) => {
|
|
70
|
+
const activity = RvcRunMode[newMode] || RvcCleanMode[newMode];
|
|
71
|
+
switch (activity) {
|
|
72
|
+
case 'Cleaning': {
|
|
73
|
+
logger.notice('BehaviorA187-ChangeRunMode to: ', activity);
|
|
74
|
+
await roborockService.startClean(duid);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
case 'Smart Plan':
|
|
78
|
+
case 'Mop':
|
|
79
|
+
case 'Vacuum':
|
|
80
|
+
case 'Mop & Vacuum':
|
|
81
|
+
case 'Custom': {
|
|
82
|
+
const setting = CleanSetting[newMode];
|
|
83
|
+
logger.notice(`BehaviorA187-ChangeCleanMode to: ${activity}, code: ${JSON.stringify(setting)}`);
|
|
84
|
+
await roborockService.changeCleanMode(duid, setting);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
default:
|
|
88
|
+
logger.notice('BehaviorA187-changeToMode-Unknown: ', newMode);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
handler.setCommandHandler('selectAreas', async (newAreas: number[]) => {
|
|
94
|
+
logger.notice(`BehaviorA187-selectAreas: ${newAreas}`);
|
|
95
|
+
roborockService.setSelectedAreas(duid, newAreas ?? []);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
handler.setCommandHandler('pause', async () => {
|
|
99
|
+
logger.notice('BehaviorA187-Pause');
|
|
100
|
+
await roborockService.pauseClean(duid);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
handler.setCommandHandler('resume', async () => {
|
|
104
|
+
logger.notice('BehaviorA187-Resume');
|
|
105
|
+
await roborockService.resumeClean(duid);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
handler.setCommandHandler('goHome', async () => {
|
|
109
|
+
logger.notice('BehaviorA187-GoHome');
|
|
110
|
+
await roborockService.stopAndGoHome(duid);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
handler.setCommandHandler('PlaySoundToLocate', async (identifyTime: number) => {
|
|
114
|
+
logger.notice('BehaviorA187-PlaySoundToLocate');
|
|
115
|
+
await roborockService.playSoundToLocate(duid);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { RvcCleanMode, RvcOperationalState, RvcRunMode } from 'matterbridge/matter/clusters';
|
|
2
|
+
|
|
3
|
+
export function getSupportedRunModesA187(): RvcRunMode.ModeOption[] {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
label: 'Idle',
|
|
7
|
+
mode: 1,
|
|
8
|
+
modeTags: [{ value: RvcRunMode.ModeTag.Idle }],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
label: 'Cleaning',
|
|
12
|
+
mode: 2,
|
|
13
|
+
modeTags: [{ value: RvcRunMode.ModeTag.Cleaning }],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: 'Mapping',
|
|
17
|
+
mode: 3,
|
|
18
|
+
modeTags: [{ value: RvcRunMode.ModeTag.Mapping }],
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getSupportedCleanModesA187(): RvcCleanMode.ModeOption[] {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
label: 'Smart Plan',
|
|
27
|
+
mode: 4,
|
|
28
|
+
modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.Auto }],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: 'Mop',
|
|
32
|
+
mode: 5,
|
|
33
|
+
modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Auto }],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: 'Vacuum',
|
|
37
|
+
mode: 6,
|
|
38
|
+
modeTags: [{ value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.Auto }],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'Mop & Vacuum',
|
|
42
|
+
mode: 7,
|
|
43
|
+
modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.DeepClean }],
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
{
|
|
47
|
+
label: 'Custom',
|
|
48
|
+
mode: 8,
|
|
49
|
+
modeTags: [{ value: RvcCleanMode.ModeTag.Mop }, { value: RvcCleanMode.ModeTag.Vacuum }, { value: RvcCleanMode.ModeTag.Quick }],
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function getOperationalStatesA187(): RvcOperationalState.OperationalStateStruct[] {
|
|
55
|
+
return [
|
|
56
|
+
{
|
|
57
|
+
operationalStateId: RvcOperationalState.OperationalState.Stopped,
|
|
58
|
+
operationalStateLabel: 'Stopped',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
operationalStateId: RvcOperationalState.OperationalState.Running,
|
|
62
|
+
operationalStateLabel: 'Running',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
operationalStateId: RvcOperationalState.OperationalState.Paused,
|
|
66
|
+
operationalStateLabel: 'Paused',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
operationalStateId: RvcOperationalState.OperationalState.Error,
|
|
70
|
+
operationalStateLabel: 'Error',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
operationalStateId: RvcOperationalState.OperationalState.SeekingCharger,
|
|
74
|
+
operationalStateLabel: 'SeekingCharger',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
operationalStateId: RvcOperationalState.OperationalState.Charging,
|
|
78
|
+
operationalStateLabel: 'Charging',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
operationalStateId: RvcOperationalState.OperationalState.Docked,
|
|
82
|
+
operationalStateLabel: 'Docked',
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MopWaterFlowA187, VacuumSuctionPowerA187 } from './a187.js';
|
|
2
|
+
|
|
3
|
+
export function getCurrentCleanModeA187(fan_power: number | undefined, water_box_mode: number | undefined): number | undefined {
|
|
4
|
+
if (!fan_power || !water_box_mode) return undefined;
|
|
5
|
+
if (fan_power == VacuumSuctionPowerA187.Smart || water_box_mode == MopWaterFlowA187.Smart) return 4; // 'Smart Plan',
|
|
6
|
+
if (fan_power == VacuumSuctionPowerA187.Custom || water_box_mode == MopWaterFlowA187.Custom) return 8; // 'Custom',
|
|
7
|
+
if (fan_power == VacuumSuctionPowerA187.Off) return 5; // 'Mop',
|
|
8
|
+
if (water_box_mode == MopWaterFlowA187.Off)
|
|
9
|
+
return 6; // 'Vacuum',
|
|
10
|
+
else return 7; //Vac & Mop
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getCurrentCleanModeFromFanPowerA187(fan_power: number | undefined): number | undefined {
|
|
14
|
+
if (!fan_power) return undefined;
|
|
15
|
+
if (fan_power == VacuumSuctionPowerA187.Smart) return 4; // 'Smart Plan',
|
|
16
|
+
if (fan_power == VacuumSuctionPowerA187.Custom) return 8; // 'Custom',
|
|
17
|
+
if (fan_power == VacuumSuctionPowerA187.Off)
|
|
18
|
+
return 5; // 'Mop',
|
|
19
|
+
else return undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getCurrentCleanModeFromWaterBoxModeA187(water_box_mode: number | undefined): number | undefined {
|
|
23
|
+
if (!water_box_mode) return undefined;
|
|
24
|
+
if (water_box_mode == MopWaterFlowA187.Smart) return 4; // 'Smart Plan',
|
|
25
|
+
if (water_box_mode == MopWaterFlowA187.Custom) return 8; // 'Custom',
|
|
26
|
+
if (water_box_mode == MopWaterFlowA187.Off)
|
|
27
|
+
return 6; // 'Vacuum',
|
|
28
|
+
else return undefined;
|
|
29
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { MaybePromise } from 'matterbridge/matter';
|
|
2
|
+
import { AnsiLogger } from 'matterbridge/logger';
|
|
3
|
+
import { BehaviorDeviceGeneric, BehaviorRoborock, DeviceCommands } from '../../BehaviorDeviceGeneric.js';
|
|
4
|
+
import RoborockService from '../../../roborockService.js';
|
|
5
|
+
|
|
6
|
+
export interface DefaultEndpointCommands extends DeviceCommands {
|
|
7
|
+
selectAreas: (newAreas: number[]) => MaybePromise;
|
|
8
|
+
changeToMode: (newMode: number) => MaybePromise;
|
|
9
|
+
pause: () => MaybePromise;
|
|
10
|
+
resume: () => MaybePromise;
|
|
11
|
+
goHome: () => MaybePromise;
|
|
12
|
+
PlaySoundToLocate: (identifyTime: number) => MaybePromise;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class DefaultBehavior extends BehaviorRoborock {
|
|
16
|
+
declare state: DefaultBehaviorRoborock.State;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export namespace DefaultBehaviorRoborock {
|
|
20
|
+
export class State {
|
|
21
|
+
device!: BehaviorDeviceGeneric<DefaultEndpointCommands>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const RvcRunMode: Record<number, string> = {
|
|
26
|
+
[1]: 'Idle', //DO NOT HANDLE HERE,
|
|
27
|
+
[2]: 'Cleaning',
|
|
28
|
+
[3]: 'Mapping',
|
|
29
|
+
};
|
|
30
|
+
const RvcCleanMode: Record<number, string> = {
|
|
31
|
+
[4]: 'Mop',
|
|
32
|
+
[5]: 'Vacuum',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function setDefaultCommandHandler(duid: string, handler: BehaviorDeviceGeneric<DeviceCommands>, logger: AnsiLogger, roborockService: RoborockService): void {
|
|
36
|
+
handler.setCommandHandler('changeToMode', async (newMode: number) => {
|
|
37
|
+
const activity = RvcRunMode[newMode] || RvcCleanMode[newMode];
|
|
38
|
+
switch (activity) {
|
|
39
|
+
case 'Cleaning': {
|
|
40
|
+
await roborockService.startClean(duid);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
case 'Mop':
|
|
44
|
+
case 'Vacuum': {
|
|
45
|
+
logger.notice('DefaultBehavior-ChangeCleanMode to: ', activity);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
default:
|
|
49
|
+
logger.notice('DefaultBehavior-changeToMode-Unknown: ', newMode);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
handler.setCommandHandler('selectAreas', async (newAreas: number[]) => {
|
|
55
|
+
logger.notice(`DefaultBehavior-selectAreas: ${newAreas}`);
|
|
56
|
+
roborockService.setSelectedAreas(duid, newAreas ?? []);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
handler.setCommandHandler('pause', async () => {
|
|
60
|
+
logger.notice('DefaultBehavior-Pause');
|
|
61
|
+
await roborockService.pauseClean(duid);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
handler.setCommandHandler('resume', async () => {
|
|
65
|
+
logger.notice('DefaultBehavior-Resume');
|
|
66
|
+
await roborockService.resumeClean(duid);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
handler.setCommandHandler('goHome', async () => {
|
|
70
|
+
logger.notice('DefaultBehavior-GoHome');
|
|
71
|
+
await roborockService.stopAndGoHome(duid);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
handler.setCommandHandler('PlaySoundToLocate', async (identifyTime: number) => {
|
|
75
|
+
logger.notice('DefaultBehavior-PlaySoundToLocate');
|
|
76
|
+
await roborockService.playSoundToLocate(duid);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { RvcCleanMode, RvcOperationalState, RvcRunMode } from 'matterbridge/matter/clusters';
|
|
2
|
+
|
|
3
|
+
export function getDefaultSupportedRunModes(): RvcRunMode.ModeOption[] {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
label: 'Idle',
|
|
7
|
+
mode: 1,
|
|
8
|
+
modeTags: [{ value: RvcRunMode.ModeTag.Idle }],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
label: 'Cleaning',
|
|
12
|
+
mode: 2,
|
|
13
|
+
modeTags: [{ value: RvcRunMode.ModeTag.Cleaning }],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: 'Mapping',
|
|
17
|
+
mode: 3,
|
|
18
|
+
modeTags: [{ value: RvcRunMode.ModeTag.Mapping }],
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getDefaultSupportedCleanModes(): RvcCleanMode.ModeOption[] {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
label: 'Vacuum',
|
|
27
|
+
mode: 4,
|
|
28
|
+
modeTags: [{ value: RvcCleanMode.ModeTag.Vacuum }],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: 'Mop',
|
|
32
|
+
mode: 5,
|
|
33
|
+
modeTags: [{ value: RvcCleanMode.ModeTag.Mop }],
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function getDefaultOperationalStates(): RvcOperationalState.OperationalStateStruct[] {
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
operationalStateId: RvcOperationalState.OperationalState.Stopped,
|
|
42
|
+
operationalStateLabel: 'Stopped',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
operationalStateId: RvcOperationalState.OperationalState.Running,
|
|
46
|
+
operationalStateLabel: 'Running',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
operationalStateId: RvcOperationalState.OperationalState.Paused,
|
|
50
|
+
operationalStateLabel: 'Paused',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
operationalStateId: RvcOperationalState.OperationalState.Error,
|
|
54
|
+
operationalStateLabel: 'Error',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
operationalStateId: RvcOperationalState.OperationalState.SeekingCharger,
|
|
58
|
+
operationalStateLabel: 'SeekingCharger',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
operationalStateId: RvcOperationalState.OperationalState.Charging,
|
|
62
|
+
operationalStateLabel: 'Charging',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
operationalStateId: RvcOperationalState.OperationalState.Docked,
|
|
66
|
+
operationalStateLabel: 'Docked',
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ClientRouter } from './roborockCommunication/broadcast/clientRouter.js';
|
|
2
|
+
import { UserData } from './roborockCommunication/index.js';
|
|
3
|
+
import { AnsiLogger } from 'matterbridge/logger';
|
|
4
|
+
|
|
5
|
+
export default class ClientManager {
|
|
6
|
+
private readonly clients = new Map<string, ClientRouter>();
|
|
7
|
+
private logger: AnsiLogger;
|
|
8
|
+
|
|
9
|
+
public constructor(logger: AnsiLogger) {
|
|
10
|
+
this.logger = logger;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public get(username: string, userdata: UserData): ClientRouter {
|
|
14
|
+
if (!this.clients.has(username)) {
|
|
15
|
+
this.clients.set(username, new ClientRouter(this.logger, userdata));
|
|
16
|
+
}
|
|
17
|
+
return <ClientRouter>this.clients.get(username);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public destroy(username: string): void {
|
|
21
|
+
this.clients.delete(username);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AxiosStatic } from 'axios';
|
|
2
|
+
import { AnsiLogger } from 'matterbridge/logger';
|
|
3
|
+
|
|
4
|
+
declare module 'axios' {
|
|
5
|
+
interface AxiosStatic {
|
|
6
|
+
interceptRequestAndResponse(logger: AnsiLogger): this;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Add the method to the actual axios object
|
|
11
|
+
import axios from 'axios';
|
|
12
|
+
|
|
13
|
+
(axios as any).interceptRequestAndResponse = function (logger: AnsiLogger): AxiosStatic {
|
|
14
|
+
this.interceptors.request.use((request: any) => {
|
|
15
|
+
logger.debug('Axios Request:', {
|
|
16
|
+
method: request.method,
|
|
17
|
+
url: request.url,
|
|
18
|
+
data: request.data,
|
|
19
|
+
headers: request.headers,
|
|
20
|
+
});
|
|
21
|
+
return request;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
this.interceptors.response.use((response: any) => {
|
|
25
|
+
logger.debug('Axios Response:', {
|
|
26
|
+
status: response.status,
|
|
27
|
+
data: response.data,
|
|
28
|
+
headers: response.headers,
|
|
29
|
+
url: response.config.url,
|
|
30
|
+
});
|
|
31
|
+
return response;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return this;
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './AxiosStaticExtensions.js';
|
package/src/helper.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Device } from './roborockCommunication/index.js';
|
|
2
|
+
|
|
3
|
+
export function getVacuumProperty(device: Device, property: string): number | undefined {
|
|
4
|
+
if (device) {
|
|
5
|
+
const schemas = device.schema;
|
|
6
|
+
const schema = schemas.find((sch) => sch.code == property);
|
|
7
|
+
|
|
8
|
+
if (schema && device.deviceStatus && device.deviceStatus[schema.id] != undefined) {
|
|
9
|
+
return Number(device.deviceStatus[schema.id]);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (device.deviceStatus && device.deviceStatus[property] != undefined) {
|
|
13
|
+
return Number(device.deviceStatus[property]);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function isSupportedDevice(model: string): boolean {
|
|
21
|
+
return model.startsWith('roborock.vacuum.');
|
|
22
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Matterbridge, PlatformConfig } from 'matterbridge';
|
|
2
|
+
import { AnsiLogger } from 'matterbridge/logger';
|
|
3
|
+
import { RoborockMatterbridgePlatform } from './platform.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This is the standard interface for Matterbridge plugins.
|
|
7
|
+
* Each plugin should export a default function that follows this signature.
|
|
8
|
+
*
|
|
9
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
10
|
+
* @param {AnsiLogger} log - The logger instance.
|
|
11
|
+
* @param {PlatformConfig} config - The platform configuration.
|
|
12
|
+
* @returns {RoborockMatterbridgePlatform} The initialized platform.
|
|
13
|
+
*/
|
|
14
|
+
export default function initializePlugin(matterbridge: Matterbridge, log: AnsiLogger, config: PlatformConfig): RoborockMatterbridgePlatform {
|
|
15
|
+
return new RoborockMatterbridgePlatform(matterbridge, log, config);
|
|
16
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PowerSource } from 'matterbridge/matter/clusters';
|
|
2
|
+
import { OperationStatusCode } from '../roborockCommunication/Zenum/operationStatusCode.js';
|
|
3
|
+
|
|
4
|
+
export function getBatteryStatus(batteryLevel?: number): PowerSource.BatChargeLevel {
|
|
5
|
+
if (batteryLevel === undefined) return PowerSource.BatChargeLevel.Ok;
|
|
6
|
+
|
|
7
|
+
if (batteryLevel >= 70) {
|
|
8
|
+
return PowerSource.BatChargeLevel.Ok;
|
|
9
|
+
} else if (batteryLevel >= 40) {
|
|
10
|
+
return PowerSource.BatChargeLevel.Warning;
|
|
11
|
+
} else {
|
|
12
|
+
return PowerSource.BatChargeLevel.Critical;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getBatteryState(deviceState: number, batRemaining: number): PowerSource.BatChargeState {
|
|
17
|
+
if (deviceState == OperationStatusCode.Charging) {
|
|
18
|
+
return batRemaining < 100 ? PowerSource.BatChargeState.IsCharging : PowerSource.BatChargeState.IsAtFullCharge;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (deviceState == OperationStatusCode.ChargingError) {
|
|
22
|
+
return PowerSource.BatChargeState.IsNotCharging;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return PowerSource.BatChargeState.IsAtFullCharge;
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
|
|
7
|
+
export function getOperationalStates(model: string): RvcOperationalState.OperationalStateStruct[] {
|
|
8
|
+
switch (model) {
|
|
9
|
+
case DeviceModel.QREVO_EDGE_5V1:
|
|
10
|
+
return getOperationalStatesA187();
|
|
11
|
+
default:
|
|
12
|
+
return getDefaultOperationalStates();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getOperationalErrorState(errorCode: VacuumErrorCode): RvcOperationalState.OperationalState | undefined {
|
|
17
|
+
switch (errorCode) {
|
|
18
|
+
case VacuumErrorCode.None:
|
|
19
|
+
return undefined;
|
|
20
|
+
default: {
|
|
21
|
+
return RvcOperationalState.OperationalState.Error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|