mirror of https://github.com/Hypfer/Valetudo.git
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
const CollisionAvoidantNavigationControlCapability = require("../../../core/capabilities/CollisionAvoidantNavigationControlCapability");
|
|
const DreameMiotHelper = require("../DreameMiotHelper");
|
|
const DreameMiotServices = require("../DreameMiotServices");
|
|
const DreameUtils = require("../DreameUtils");
|
|
|
|
/**
|
|
* @extends CollisionAvoidantNavigationControlCapability<import("../DreameValetudoRobot")>
|
|
*/
|
|
class DreameCollisionAvoidantNavigationControlCapability extends CollisionAvoidantNavigationControlCapability {
|
|
|
|
/**
|
|
* @param {object} options
|
|
* @param {import("../DreameValetudoRobot")} options.robot
|
|
*/
|
|
constructor(options) {
|
|
super(options);
|
|
|
|
this.siid = DreameMiotServices["GEN2"].VACUUM_2.SIID;
|
|
this.piid = DreameMiotServices["GEN2"].VACUUM_2.PROPERTIES.MISC_TUNABLES.PIID;
|
|
|
|
this.helper = new DreameMiotHelper({robot: this.robot});
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @returns {Promise<boolean>}
|
|
*/
|
|
async isEnabled() {
|
|
const res = await this.helper.readProperty(this.siid, this.piid);
|
|
const deserializedResponse = DreameUtils.DESERIALIZE_MISC_TUNABLES(res);
|
|
|
|
return deserializedResponse.LessColl === 1;
|
|
}
|
|
|
|
/**
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async enable() {
|
|
await this.helper.writeProperty(
|
|
this.siid,
|
|
this.piid,
|
|
DreameUtils.SERIALIZE_MISC_TUNABLES_SINGLE_TUNABLE({
|
|
LessColl: 1
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async disable() {
|
|
await this.helper.writeProperty(
|
|
this.siid,
|
|
this.piid,
|
|
DreameUtils.SERIALIZE_MISC_TUNABLES_SINGLE_TUNABLE({
|
|
LessColl: 0
|
|
})
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = DreameCollisionAvoidantNavigationControlCapability;
|