Skip to content

Commit

Permalink
feat(vendor.roborock): dryer module support for S8 Pro and G10s (#2037)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xuefer H authored Mar 31, 2024
1 parent 53453f9 commit 37f386a
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 1 deletion.
3 changes: 3 additions & 0 deletions backend/lib/robots/roborock/RoborockG10SValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class RoborockG10SValetudoRobot extends RoborockGen4ValetudoRobot {
capabilities.RoborockAutoEmptyDockAutoEmptyControlCapability,
capabilities.RoborockAutoEmptyDockManualTriggerCapability,
capabilities.RoborockMopDockCleanManualTriggerCapability,
capabilities.RoborockMopDockDryManualTriggerCapability,
capabilities.RoborockKeyLockCapability,
capabilities.RoborockMappingPassCapability,
capabilities.RoborockObstacleAvoidanceControlCapability,
Expand All @@ -75,6 +76,8 @@ class RoborockG10SValetudoRobot extends RoborockGen4ValetudoRobot {
quirkFactory.getQuirk(RoborockQuirkFactory.KNOWN_QUIRKS.MOP_DOCK_MOP_CLEANING_FREQUENCY),
quirkFactory.getQuirk(RoborockQuirkFactory.KNOWN_QUIRKS.BUTTON_LEDS),
quirkFactory.getQuirk(RoborockQuirkFactory.KNOWN_QUIRKS.MOP_PATTERN),
quirkFactory.getQuirk(RoborockQuirkFactory.KNOWN_QUIRKS.MOP_DOCK_AUTO_DRYING),
quirkFactory.getQuirk(RoborockQuirkFactory.KNOWN_QUIRKS.MOP_DOCK_AUTO_DRYING_TIME),
]
}));
}
Expand Down
87 changes: 86 additions & 1 deletion backend/lib/robots/roborock/RoborockQuirkFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,89 @@ class RoborockQuirkFactory {
}
}
});
case RoborockQuirkFactory.KNOWN_QUIRKS.MOP_DOCK_AUTO_DRYING:
return new Quirk({
id: id,
title: "Mop Auto Drying",
description: "Select if the dock should automatically dry the mop after a cleanup",
options: ["on", "off"],
getter: async () => {
const res = await this.robot.sendCommand("app_get_dryer_setting", [], {});

switch (res?.status) {
case 1:
return "on";
case 0:
return "off";
default:
throw new Error(`Received invalid value ${res?.status}`);
}
},
setter: async (value) => {
let val;

switch (value) {
case "on":
val = 1;
break;
case "off":
val = 0;
break;
default:
throw new Error(`Received invalid value ${value}`);
}

/*
const config = {
"status": val,
"on": { "cliff_on": 1000, "cliff_off": 1000 },
"off": { "cliff_on": 500, "cliff_off": 500 },
};
return this.robot.sendCommand("app_set_dryer_setting", config, {});
*/
return this.robot.sendCommand("app_set_dryer_setting", { "status": val }, {});
}
});
case RoborockQuirkFactory.KNOWN_QUIRKS.MOP_DOCK_AUTO_DRYING_TIME:
return new Quirk({
id: id,
title: "Mop Auto Drying Time",
description: "Define how long the mop should be dried after a cleanup",
options: ["2h", "3h", "4h"],
getter: async () => {
const res = await this.robot.sendCommand("app_get_dryer_setting", [], {});

switch (res?.on.dry_time) {
case 2 * 60 * 60:
return "2h";
case 3 * 60 * 60:
return "3h";
case 4 * 60 * 60:
return "4h";
default:
return String(res.on.dry_time);
}
},
setter: async (value) => {
let val;

switch (value) {
case "2h":
val = 2 * 60 * 60;
break;
case "3h":
val = 3 * 60 * 60;
break;
case "4h":
val = 4 * 60 * 60;
break;
default:
val = Number(value);
}

return this.robot.sendCommand("app_set_dryer_setting", {"on": { "dry_time": val } }, {});
}
});
default:
throw new Error(`There's no quirk with id ${id}`);
}
Expand All @@ -319,7 +402,9 @@ RoborockQuirkFactory.KNOWN_QUIRKS = {
MOP_PATTERN: "767fc859-3383-4485-bfdf-7aa800cf487e",
MANUAL_MAP_SEGMENT_TRIGGER: "3e467ac1-7d14-4e66-b09b-8d0554a3194e",
MOP_DOCK_MOP_CLEANING_FREQUENCY: "c50d98fb-7e29-4d09-a577-70c95ac33239",
MOP_DOCK_MOP_CLEANING_MODE: "b4ca6500-a461-49cb-966a-4726a33ad3df"
MOP_DOCK_MOP_CLEANING_MODE: "b4ca6500-a461-49cb-966a-4726a33ad3df",
MOP_DOCK_AUTO_DRYING: "308bd55a-9c94-480e-a7bb-d6c706526203",
MOP_DOCK_AUTO_DRYING_TIME: "b6ad439c-6665-4ffd-a038-cc72821e5fb1"
};

module.exports = RoborockQuirkFactory;
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class RoborockS8ProUltraValetudoRobot extends RoborockGen4ValetudoRobot {
[
capabilities.RoborockAutoEmptyDockAutoEmptyControlCapability,
capabilities.RoborockAutoEmptyDockManualTriggerCapability,
capabilities.RoborockMopDockDryManualTriggerCapability,
capabilities.RoborockKeyLockCapability,
capabilities.RoborockMappingPassCapability,
capabilities.RoborockObstacleAvoidanceControlCapability,
Expand All @@ -74,6 +75,8 @@ class RoborockS8ProUltraValetudoRobot extends RoborockGen4ValetudoRobot {
quirkFactory.getQuirk(RoborockQuirkFactory.KNOWN_QUIRKS.MOP_DOCK_MOP_CLEANING_FREQUENCY),
quirkFactory.getQuirk(RoborockQuirkFactory.KNOWN_QUIRKS.BUTTON_LEDS),
quirkFactory.getQuirk(RoborockQuirkFactory.KNOWN_QUIRKS.MOP_PATTERN),
quirkFactory.getQuirk(RoborockQuirkFactory.KNOWN_QUIRKS.MOP_DOCK_AUTO_DRYING),
quirkFactory.getQuirk(RoborockQuirkFactory.KNOWN_QUIRKS.MOP_DOCK_AUTO_DRYING_TIME),
]
}));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const MopDockDryManualTriggerCapability = require("../../../core/capabilities/MopDockDryManualTriggerCapability");

/**
* @extends MopDockDryManualTriggerCapability<import("../RoborockValetudoRobot")>
*/
class RoborockMopDockDryManualTriggerCapability extends MopDockDryManualTriggerCapability {
/**
* @abstract
* @returns {Promise<void>}
*/
async startDrying() {
return await this.robot.sendCommand("app_set_dryer_status", { "status": 1 }, {});
}

/**
* @abstract
* @returns {Promise<void>}
*/
async stopDrying() {
return await this.robot.sendCommand("app_set_dryer_status", { "status": 0 }, {});
}
}

module.exports = RoborockMopDockDryManualTriggerCapability;
1 change: 1 addition & 0 deletions backend/lib/robots/roborock/capabilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
RoborockMapSnapshotCapability: require("./RoborockMapSnapshotCapability"),
RoborockMappingPassCapability: require("./RoborockMappingPassCapability"),
RoborockMopDockCleanManualTriggerCapability: require("./RoborockMopDockCleanManualTriggerCapability"),
RoborockMopDockDryManualTriggerCapability: require("./RoborockMopDockDryManualTriggerCapability"),
RoborockMultiMapMapResetCapability: require("./RoborockMultiMapMapResetCapability"),
RoborockMultiMapPersistentMapControlCapability: require("./RoborockMultiMapPersistentMapControlCapability"),
RoborockObstacleAvoidanceControlCapability: require("./RoborockObstacleAvoidanceControlCapability"),
Expand Down

0 comments on commit 37f386a

Please sign in to comment.