Skip to content

Commit

Permalink
feat(vendor.dreame): D10S Pro
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed Nov 28, 2022
1 parent 111f91b commit 0939cbd
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 1 deletion.
181 changes: 181 additions & 0 deletions backend/lib/robots/dreame/DreameD10SProValetudoRobot.js
@@ -0,0 +1,181 @@
const capabilities = require("./capabilities");
const DreameGen2LidarValetudoRobot = require("./DreameGen2LidarValetudoRobot");
const DreameGen2ValetudoRobot = require("./DreameGen2ValetudoRobot");
const DreameQuirkFactory = require("./DreameQuirkFactory");
const DreameValetudoRobot = require("./DreameValetudoRobot");
const entities = require("../../entities");
const fs = require("fs");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const QuirksCapability = require("../../core/capabilities/QuirksCapability");
const ValetudoSelectionPreset = require("../../entities/core/ValetudoSelectionPreset");

const stateAttrs = entities.state.attributes;

class DreameD10SProValetudoRobot extends DreameGen2LidarValetudoRobot {

/**
*
* @param {object} options
* @param {import("../../Configuration")} options.config
* @param {import("../../ValetudoEventStore")} options.valetudoEventStore
*/
constructor(options) {
super(options);

const QuirkFactory = new DreameQuirkFactory({
robot: this
});

this.registerCapability(new capabilities.DreameCarpetModeControlCapability({
robot: this,
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.SIID,
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.PROPERTIES.CARPET_MODE.PIID
}));

this.registerCapability(new capabilities.DreameWaterUsageControlCapability({
robot: this,
presets: Object.keys(DreameValetudoRobot.WATER_GRADES).map(k => {
return new ValetudoSelectionPreset({name: k, value: DreameValetudoRobot.WATER_GRADES[k]});
}),
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.SIID,
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.PROPERTIES.WATER_USAGE.PIID
}));

this.registerCapability(new capabilities.DreameZoneCleaningCapability({
robot: this,
miot_actions: {
start: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.SIID,
aiid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.ACTIONS.START.AIID
}
},
miot_properties: {
mode: {
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.PROPERTIES.MODE.PIID
},
additionalCleanupParameters: {
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.PROPERTIES.ADDITIONAL_CLEANUP_PROPERTIES.PIID
}
},
zoneCleaningModeId: 19,
maxZoneCount: 4
}));

this.registerCapability(new capabilities.DreameConsumableMonitoringCapability({
robot: this,
miot_properties: {
main_brush: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.MAIN_BRUSH.SIID,
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.MAIN_BRUSH.PROPERTIES.TIME_LEFT.PIID
},
side_brush: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.SIDE_BRUSH.SIID,
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.SIDE_BRUSH.PROPERTIES.TIME_LEFT.PIID
},
filter: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.FILTER.SIID,
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.FILTER.PROPERTIES.TIME_LEFT.PIID
},
sensor: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.SENSOR.SIID,
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.SENSOR.PROPERTIES.TIME_LEFT.PIID
},
mop: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.MOP.SIID,
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.MOP.PROPERTIES.TIME_LEFT.PIID
}
},
miot_actions: {
reset_main_brush: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.MAIN_BRUSH.SIID,
aiid: DreameGen2ValetudoRobot.MIOT_SERVICES.MAIN_BRUSH.ACTIONS.RESET.AIID
},
reset_side_brush: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.SIDE_BRUSH.SIID,
aiid: DreameGen2ValetudoRobot.MIOT_SERVICES.SIDE_BRUSH.ACTIONS.RESET.AIID
},
reset_filter: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.FILTER.SIID,
aiid: DreameGen2ValetudoRobot.MIOT_SERVICES.FILTER.ACTIONS.RESET.AIID
},
reset_sensor: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.SENSOR.SIID,
aiid: DreameGen2ValetudoRobot.MIOT_SERVICES.SENSOR.ACTIONS.RESET.AIID
},
reset_mop: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.MOP.SIID,
aiid: DreameGen2ValetudoRobot.MIOT_SERVICES.MOP.ACTIONS.RESET.AIID
}
},
}));

this.registerCapability(new capabilities.DreameKeyLockCapability({
robot: this,
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.SIID,
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.PROPERTIES.KEY_LOCK.PIID
}));

this.registerCapability(new capabilities.DreameAICameraGoToLocationCapability({
robot: this,
miot_actions: {
start: {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.SIID,
aiid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.ACTIONS.START.AIID
}
},
miot_properties: {
mode: {
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.PROPERTIES.MODE.PIID
},
additionalCleanupParameters: {
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.PROPERTIES.ADDITIONAL_CLEANUP_PROPERTIES.PIID
}
},
goToModeId: 23
}));

this.registerCapability(new QuirksCapability({
robot: this,
quirks: [
QuirkFactory.getQuirk(DreameQuirkFactory.KNOWN_QUIRKS.CARPET_MODE_SENSITIVITY),
QuirkFactory.getQuirk(DreameQuirkFactory.KNOWN_QUIRKS.TIGHT_MOP_PATTERN),
QuirkFactory.getQuirk(DreameQuirkFactory.KNOWN_QUIRKS.BASIC_AI_CAMERA_SETTINGS),
]
}));

this.state.upsertFirstMatchingAttribute(new entities.state.attributes.AttachmentStateAttribute({
type: entities.state.attributes.AttachmentStateAttribute.TYPE.MOP,
attached: false
}));
}

getModelName() {
return "D10S Pro";
}

getCloudSecretFromFS() {
return fs.readFileSync("/mnt/private/ULI/factory/key.txt");
}

getModelDetails() {
return Object.assign(
{},
super.getModelDetails(),
{
supportedAttachments: [
stateAttrs.AttachmentStateAttribute.TYPE.MOP,
]
}
);
}


static IMPLEMENTATION_AUTO_DETECTION_HANDLER() {
const deviceConf = MiioValetudoRobot.READ_DEVICE_CONF(DreameValetudoRobot.DEVICE_CONF_PATH);

return !!(deviceConf && deviceConf.model === "dreame.vacuum.r2250");
}
}


module.exports = DreameD10SProValetudoRobot;
3 changes: 2 additions & 1 deletion backend/lib/robots/dreame/index.js
@@ -1,6 +1,7 @@
module.exports = {
"Dreame1CValetudoRobot": require("./Dreame1CValetudoRobot"),
"Dreame1TValetudoRobot": require("./Dreame1TValetudoRobot"),
"DreameD10SProValetudoRobot": require("./DreameD10SProValetudoRobot"),
"DreameD9ProPlusValetudoRobot": require("./DreameD9ProPlusValetudoRobot"),
"DreameD9ProValetudoRobot": require("./DreameD9ProValetudoRobot"),
"DreameD9ValetudoRobot": require("./DreameD9ValetudoRobot"),
Expand All @@ -13,5 +14,5 @@ module.exports = {
"DreameP2149ValetudoRobot": require("./DreameP2149ValetudoRobot"),
"DreameW10ValetudoRobot": require("./DreameW10ValetudoRobot"),
"DreameX10PlusValetudoRobot": require("./DreameX10PlusValetudoRobot"),
"DreameZ10ProValetudoRobot": require("./DreameZ10ProValetudoRobot"),
"DreameZ10ProValetudoRobot": require("./DreameZ10ProValetudoRobot")
};

1 comment on commit 0939cbd

@Clusters
Copy link

@Clusters Clusters commented on 0939cbd Feb 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hypfer this does not mean that the D10s Pro will be supported by Valetudo anytime soon?
I am confused why this isn't referenced anywhere. Or does this just mean, it isn't referenced because it hasn't been tested yet?

edit: found the answer here -> #1690 (comment)

Please sign in to comment.