Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vendor.viomi): Introduce ViomiOperationModeControlCapability
- Loading branch information
Showing
6 changed files
with
79 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
backend/lib/robots/viomi/capabilities/ViomiOperationModeControlCapability.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const OperationModeControlCapability = require("../../../core/capabilities/OperationModeControlCapability"); | ||
|
||
/** | ||
* @extends OperationModeControlCapability<import("../ViomiValetudoRobot")> | ||
*/ | ||
class ViomiOperationModeControlCapability extends OperationModeControlCapability { | ||
/** | ||
* @param {string} preset | ||
* @returns {Promise<void>} | ||
*/ | ||
async selectPreset(preset) { | ||
const matchedPreset = this.presets.find(p => { | ||
return p.name === preset; | ||
}); | ||
|
||
if (matchedPreset) { | ||
await this.robot.sendCommand("set_mop", [matchedPreset.value]); | ||
} else { | ||
throw new Error("Invalid Preset"); | ||
} | ||
} | ||
|
||
} | ||
|
||
module.exports = ViomiOperationModeControlCapability; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters