Skip to content

Commit

Permalink
feat(vendor.dreame): Add support for the STYTJO6ZHM
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed May 1, 2022
1 parent deca9e8 commit 519c5b4
Show file tree
Hide file tree
Showing 16 changed files with 588 additions and 27 deletions.
16 changes: 16 additions & 0 deletions backend/lib/robots/dreame/DreameD9ProValetudoRobot.js
Expand Up @@ -3,6 +3,7 @@ const DreameGen2LidarValetudoRobot = require("./DreameGen2LidarValetudoRobot");
const DreameGen2ValetudoRobot = require("./DreameGen2ValetudoRobot");
const DreameValetudoRobot = require("./DreameValetudoRobot");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const ValetudoSelectionPreset = require("../../entities/core/ValetudoSelectionPreset");

class DreameD9ProValetudoRobot extends DreameGen2LidarValetudoRobot {
/**
Expand All @@ -14,6 +15,21 @@ class DreameD9ProValetudoRobot extends DreameGen2LidarValetudoRobot {
constructor(options) {
super(options);

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.DreameConsumableMonitoringCapability({
robot: this,
miot_properties: {
Expand Down
16 changes: 16 additions & 0 deletions backend/lib/robots/dreame/DreameD9ValetudoRobot.js
Expand Up @@ -3,6 +3,7 @@ const DreameGen2LidarValetudoRobot = require("./DreameGen2LidarValetudoRobot");
const DreameGen2ValetudoRobot = require("./DreameGen2ValetudoRobot");
const DreameValetudoRobot = require("./DreameValetudoRobot");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const ValetudoSelectionPreset = require("../../entities/core/ValetudoSelectionPreset");

class DreameD9ValetudoRobot extends DreameGen2LidarValetudoRobot {
/**
Expand All @@ -14,6 +15,21 @@ class DreameD9ValetudoRobot extends DreameGen2LidarValetudoRobot {
constructor(options) {
super(options);

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.DreameConsumableMonitoringCapability({
robot: this,
miot_properties: {
Expand Down
18 changes: 18 additions & 0 deletions backend/lib/robots/dreame/DreameGen2VSlamValetudoRobot.js
@@ -1,6 +1,9 @@
const DreameGen2ValetudoRobot = require("./DreameGen2ValetudoRobot");

const capabilities = require("./capabilities");
const DreameValetudoRobot = require("./DreameValetudoRobot");
const ValetudoSelectionPreset = require("../../entities/core/ValetudoSelectionPreset");


class DreameGen2VSlamValetudoRobot extends DreameGen2ValetudoRobot {
constructor(options) {
Expand All @@ -12,6 +15,21 @@ class DreameGen2VSlamValetudoRobot extends DreameGen2ValetudoRobot {
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.PERSISTENT_MAPS.SIID,
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.PERSISTENT_MAPS.PROPERTIES.ENABLED.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.DreameCarpetModeControlCapability({
robot: this,
siid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.SIID,
piid: DreameGen2ValetudoRobot.MIOT_SERVICES.VACUUM_2.PROPERTIES.CARPET_MODE.PIID
}));
}
}

Expand Down
47 changes: 26 additions & 21 deletions backend/lib/robots/dreame/DreameGen2ValetudoRobot.js
Expand Up @@ -37,6 +37,15 @@ class DreameGen2ValetudoRobot extends DreameValetudoRobot {
)
);

/** @type {Array<{siid: number, piid: number, did: number}>} */
this.statePropertiesToPoll = this.getStatePropertiesToPoll().map(e => {
return {
siid: e.siid,
piid: e.piid,
did: this.deviceId
};
});

this.lastMapPoll = new Date(0);

this.mode = 0; //Idle
Expand Down Expand Up @@ -75,15 +84,6 @@ class DreameGen2ValetudoRobot extends DreameValetudoRobot {
piid: MIOT_SERVICES.VACUUM_2.PROPERTIES.FAN_SPEED.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: MIOT_SERVICES.VACUUM_2.SIID,
piid: MIOT_SERVICES.VACUUM_2.PROPERTIES.WATER_USAGE.PIID
}));

this.registerCapability(new capabilities.DreameLocateCapability({
robot: this,
siid: MIOT_SERVICES.AUDIO.SIID,
Expand Down Expand Up @@ -225,12 +225,6 @@ class DreameGen2ValetudoRobot extends DreameValetudoRobot {
install_voicepack_piid: MIOT_SERVICES.AUDIO.PROPERTIES.INSTALL_VOICEPACK.PIID
}));

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

this.registerCapability(new capabilities.DreamePendingMapChangeHandlingCapability({
robot: this,
miot_actions: {
Expand Down Expand Up @@ -349,6 +343,7 @@ class DreameGen2ValetudoRobot extends DreameValetudoRobot {
case MIOT_SERVICES.SIDE_BRUSH.SIID:
case MIOT_SERVICES.FILTER.SIID:
case MIOT_SERVICES.SENSOR.SIID:
case MIOT_SERVICES.MOP.SIID:
this.parseAndUpdateState([e]);
break;
case MIOT_SERVICES.DEVICE.SIID:
Expand Down Expand Up @@ -390,8 +385,13 @@ class DreameGen2ValetudoRobot extends DreameValetudoRobot {
return false;
}

async pollState() {
const response = await this.sendCommand("get_properties", [
/**
* May be extended by children
*
* @return {Array<{piid: number, siid: number}>}
*/
getStatePropertiesToPoll() {
return [
{
siid: MIOT_SERVICES.VACUUM_2.SIID,
piid: MIOT_SERVICES.VACUUM_2.PROPERTIES.MODE.PIID
Expand Down Expand Up @@ -424,11 +424,14 @@ class DreameGen2ValetudoRobot extends DreameValetudoRobot {
siid: MIOT_SERVICES.BATTERY.SIID,
piid: MIOT_SERVICES.BATTERY.PROPERTIES.CHARGING.PIID
}
].map(e => {
e.did = this.deviceId;
];
}

return e;
}));
async pollState() {
const response = await this.sendCommand(
"get_properties",
this.statePropertiesToPoll
);

if (response) {
this.parseAndUpdateState(response);
Expand Down Expand Up @@ -520,6 +523,7 @@ class DreameGen2ValetudoRobot extends DreameValetudoRobot {
case MIOT_SERVICES.VACUUM_2.PROPERTIES.CARPET_MODE.PIID:
case MIOT_SERVICES.VACUUM_2.PROPERTIES.KEY_LOCK.PIID:
case MIOT_SERVICES.VACUUM_2.PROPERTIES.OBSTACLE_AVOIDANCE.PIID:
case MIOT_SERVICES.VACUUM_2.PROPERTIES.MOP_DOCK_STATE.PIID:
//ignored for now
break;

Expand Down Expand Up @@ -552,6 +556,7 @@ class DreameGen2ValetudoRobot extends DreameValetudoRobot {
case MIOT_SERVICES.SIDE_BRUSH.SIID:
case MIOT_SERVICES.FILTER.SIID:
case MIOT_SERVICES.SENSOR.SIID:
case MIOT_SERVICES.MOP.SIID:
if (this.capabilities[ConsumableMonitoringCapability.TYPE]) {
this.capabilities[ConsumableMonitoringCapability.TYPE].parseConsumablesMessage(elem);
}
Expand Down
16 changes: 16 additions & 0 deletions backend/lib/robots/dreame/DreameL10ProValetudoRobot.js
Expand Up @@ -5,6 +5,7 @@ const DreameQuirkFactory = require("./DreameQuirkFactory");
const DreameValetudoRobot = require("./DreameValetudoRobot");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const QuirksCapability = require("../../core/capabilities/QuirksCapability");
const ValetudoSelectionPreset = require("../../entities/core/ValetudoSelectionPreset");

class DreameL10ProValetudoRobot extends DreameGen2LidarValetudoRobot {
/**
Expand All @@ -20,6 +21,21 @@ class DreameL10ProValetudoRobot extends DreameGen2LidarValetudoRobot {
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.DreameConsumableMonitoringCapability({
robot: this,
miot_properties: {
Expand Down
22 changes: 22 additions & 0 deletions backend/lib/robots/dreame/DreameMiotServices.js
Expand Up @@ -310,6 +310,12 @@ module.exports = {
OBSTACLE_AVOIDANCE: {
PIID: 21
},
MOP_DOCK_SETTINGS: {
PIID: 23
},
MOP_DOCK_STATE: {
PIID: 25
},
KEY_LOCK: {
PIID: 27
},
Expand Down Expand Up @@ -448,6 +454,22 @@ module.exports = {
}
}
},
MOP: {
SIID: 18,
PROPERTIES: {
TIME_LEFT: { //Hours
PIID: 2
},
PERCENT_LEFT: {
PIID: 1
}
},
ACTIONS: {
RESET: {
AIID: 1
}
}
},
MAP: {
SIID: 6,
PROPERTIES: {
Expand Down

0 comments on commit 519c5b4

Please sign in to comment.