Skip to content

Commit

Permalink
feat(vendor.dreame): Add auto empty interval quirk
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed Jan 10, 2022
1 parent 79deeb1 commit 1b6205a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/lib/core/capabilities/QuirksCapability.js
Expand Up @@ -46,7 +46,7 @@ class QuirksCapability extends Capability {
new Promise((resolve, reject) => {
quirkFetchTimeout = setTimeout(() => {
reject(new Error("Timeout while fetching quirks"));
}, 8000);
}, 9000);
})
]);
clearTimeout(quirkFetchTimeout);
Expand Down
52 changes: 51 additions & 1 deletion backend/lib/robots/dreame/DreameQuirkFactory.js
Expand Up @@ -106,6 +106,55 @@ class DreameQuirkFactory {
);
}
});
case DreameQuirkFactory.KNOWN_QUIRKS.AUTO_EMPTY_INTERVAL:
return new Quirk({
id: id,
title: "Auto-empty Interval",
description: "Depending on the size of your home, you might not need to auto-empty the dustbin on" +
"every single cleanup. Note that you can also disable auto-empty entirely and manually trigger" +
"it via REST and/or MQTT instead of changing the interval.",
options: ["every_cleanup", "every_second_cleanup", "every_third_cleanup"],
getter: async () => {
const res = await this.helper.readProperty(
DreameMiotServices["GEN2"].AUTO_EMPTY_DOCK.SIID,
DreameMiotServices["GEN2"].AUTO_EMPTY_DOCK.PROPERTIES.INTERVAL.PIID
);

switch (res) {
case 1:
return "every_cleanup";
case 2:
return "every_second_cleanup";
case 3:
return "every_third_cleanup";
default:
throw new Error(`Received invalid value ${res}`);
}
},
setter: async (value) => {
let val;

switch (value) {
case "every_cleanup":
val = 1;
break;
case "every_second_cleanup":
val = 2;
break;
case "every_third_cleanup":
val = 3;
break;
default:
throw new Error(`Received invalid value ${value}`);
}

return this.helper.writeProperty(
DreameMiotServices["GEN2"].AUTO_EMPTY_DOCK.SIID,
DreameMiotServices["GEN2"].AUTO_EMPTY_DOCK.PROPERTIES.INTERVAL.PIID,
val
);
}
});
default:
throw new Error(`There's no quirk with id ${id}`);
}
Expand All @@ -114,7 +163,8 @@ class DreameQuirkFactory {

DreameQuirkFactory.KNOWN_QUIRKS = {
CARPET_MODE_SENSITIVITY: "f8cb91ab-a47a-445f-b300-0aac0d4937c0",
TIGHT_MOP_PATTERN: "8471c118-f1e1-4866-ad2e-3c11865a5ba8"
TIGHT_MOP_PATTERN: "8471c118-f1e1-4866-ad2e-3c11865a5ba8",
AUTO_EMPTY_INTERVAL: "d38118f2-fb5d-4ed9-b668-262db15e5269"
};

module.exports = DreameQuirkFactory;
3 changes: 2 additions & 1 deletion backend/lib/robots/dreame/DreameZ10ProValetudoRobot.js
Expand Up @@ -89,7 +89,8 @@ class DreameZ10ProValetudoRobot extends DreameGen2LidarValetudoRobot {
robot: this,
quirks: [
QuirkFactory.getQuirk(DreameQuirkFactory.KNOWN_QUIRKS.CARPET_MODE_SENSITIVITY),
QuirkFactory.getQuirk(DreameQuirkFactory.KNOWN_QUIRKS.TIGHT_MOP_PATTERN)
QuirkFactory.getQuirk(DreameQuirkFactory.KNOWN_QUIRKS.TIGHT_MOP_PATTERN),
QuirkFactory.getQuirk(DreameQuirkFactory.KNOWN_QUIRKS.AUTO_EMPTY_INTERVAL)
]
}));
}
Expand Down

0 comments on commit 1b6205a

Please sign in to comment.