-
-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vendor.dreame): DreameAutoEmptyDockAutoEmptyControlCapability
- Loading branch information
Showing
5 changed files
with
58 additions
and
2 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
50 changes: 50 additions & 0 deletions
50
backend/lib/robots/dreame/capabilities/DreameAutoEmptyDockAutoEmptyControlCapability.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,50 @@ | ||
const AutoEmptyDockAutoEmptyControlCapability = require("../../../core/capabilities/AutoEmptyDockAutoEmptyControlCapability.js"); | ||
const DreameMiotHelper = require("../DreameMiotHelper"); | ||
|
||
/** | ||
* @extends AutoEmptyDockAutoEmptyControlCapability<import("../DreameValetudoRobot")> | ||
*/ | ||
class DreameAutoEmptyDockAutoEmptyControlCapability extends AutoEmptyDockAutoEmptyControlCapability { | ||
|
||
/** | ||
* @param {object} options | ||
* @param {import("../DreameValetudoRobot")} options.robot | ||
* | ||
* @param {number} options.siid MIOT Service ID | ||
* @param {number} options.piid MIOT Property ID | ||
*/ | ||
constructor(options) { | ||
super(options); | ||
|
||
this.siid = options.siid; | ||
this.piid = options.piid; | ||
|
||
this.helper = new DreameMiotHelper({robot: this.robot}); | ||
} | ||
|
||
/** | ||
* | ||
* @returns {Promise<boolean>} | ||
*/ | ||
async isEnabled() { | ||
const res = await this.helper.readProperty(this.siid, this.piid); | ||
|
||
return res === 1; | ||
} | ||
|
||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async enable() { | ||
await this.helper.writeProperty(this.siid, this.piid, 1); | ||
} | ||
|
||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async disable() { | ||
await this.helper.writeProperty(this.siid, this.piid, 0); | ||
} | ||
} | ||
|
||
module.exports = DreameAutoEmptyDockAutoEmptyControlCapability; |
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