Skip to content

Commit

Permalink
feat(vendor.roborock): Dock dustbin consumable for all auto-empty docks
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed Nov 18, 2023
1 parent 868bd74 commit e3d13fa
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 95 deletions.
11 changes: 11 additions & 0 deletions backend/lib/robots/roborock/RoborockConst.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
/**
* @typedef {string} RoborockDockType
* @enum {string}
*/
DOCK_TYPE: Object.freeze({
ULTRA: "ultra",
AUTO_EMPTY: "auto_empty",
CHARGING: "charging"
})
};
8 changes: 2 additions & 6 deletions backend/lib/robots/roborock/RoborockG10SValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fs = require("fs");
const Logger = require("../../Logger");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const QuirksCapability = require("../../core/capabilities/QuirksCapability");
const RoborockConst = require("./RoborockConst");
const RoborockGen4ValetudoRobot = require("./RoborockGen4ValetudoRobot");
const RoborockQuirkFactory = require("./RoborockQuirkFactory");
const RoborockValetudoRobot = require("./RoborockValetudoRobot");
Expand All @@ -24,7 +25,7 @@ class RoborockG10SValetudoRobot extends RoborockGen4ValetudoRobot {
{
waterGrades: WATER_GRADES,
supportedAttachments: SUPPORTED_ATTACHMENTS,
hasUltraDock: true
dockType: RoborockConst.DOCK_TYPE.ULTRA
}
)
);
Expand All @@ -45,11 +46,6 @@ class RoborockG10SValetudoRobot extends RoborockGen4ValetudoRobot {
})
}));

this.registerCapability(new capabilities.RoborockConsumableMonitoringCapability({
robot: this,
hasUltraDock: true
}));

this.registerCapability(new capabilities.RoborockCarpetSensorModeControlCapability({
robot: this,
liftModeId: 1
Expand Down
1 change: 0 additions & 1 deletion backend/lib/robots/roborock/RoborockM1SValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class RoborockM1SValetudoRobot extends RoborockValetudoRobot {
super(Object.assign({}, options, {fanSpeeds: FAN_SPEEDS}));

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockMapSnapshotCapability,
capabilities.RoborockCombinedVirtualRestrictionsCapability,
capabilities.RoborockPersistentMapControlCapability,
Expand Down
5 changes: 3 additions & 2 deletions backend/lib/robots/roborock/RoborockQ7MaxValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const capabilities = require("./capabilities");
const entities = require("../../entities");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const QuirksCapability = require("../../core/capabilities/QuirksCapability");
const RoborockConst = require("./RoborockConst");
const RoborockGen4ValetudoRobot = require("./RoborockGen4ValetudoRobot");
const RoborockQuirkFactory = require("./RoborockQuirkFactory");
const RoborockValetudoRobot = require("./RoborockValetudoRobot");
Expand All @@ -21,7 +22,8 @@ class RoborockQ7MaxValetudoRobot extends RoborockGen4ValetudoRobot {
options,
{
waterGrades: WATER_GRADES,
supportedAttachments: SUPPORTED_ATTACHMENTS
supportedAttachments: SUPPORTED_ATTACHMENTS,
dockType: RoborockConst.DOCK_TYPE.AUTO_EMPTY
}
)
);
Expand All @@ -43,7 +45,6 @@ class RoborockQ7MaxValetudoRobot extends RoborockGen4ValetudoRobot {
}));

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockAutoEmptyDockAutoEmptyControlCapability,
capabilities.RoborockAutoEmptyDockManualTriggerCapability,
capabilities.RoborockKeyLockCapability,
Expand Down
1 change: 0 additions & 1 deletion backend/lib/robots/roborock/RoborockS4MaxValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class RoborockS4MaxValetudoRobot extends RoborockGen4ValetudoRobot {
super(options);

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockCombinedVirtualRestrictionsCapability
].forEach(capability => {
this.registerCapability(new capability({robot: this}));
Expand Down
1 change: 0 additions & 1 deletion backend/lib/robots/roborock/RoborockS4ValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class RoborockS4ValetudoRobot extends RoborockValetudoRobot {
super(Object.assign({}, options, {fanSpeeds: FAN_SPEEDS}));

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockCombinedVirtualRestrictionsCapability,
capabilities.RoborockMultiMapPersistentMapControlCapability,
capabilities.RoborockMultiMapMapResetCapability,
Expand Down
1 change: 0 additions & 1 deletion backend/lib/robots/roborock/RoborockS5MaxValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class RoborockS5MaxValetudoRobot extends RoborockValetudoRobot {
}));

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockMultiMapPersistentMapControlCapability,
capabilities.RoborockMultiMapMapResetCapability,
capabilities.RoborockMapSegmentationCapability,
Expand Down
1 change: 0 additions & 1 deletion backend/lib/robots/roborock/RoborockS5ValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class RoborockS5ValetudoRobot extends RoborockValetudoRobot {
super(Object.assign({}, options, {fanSpeeds: FAN_SPEEDS}));

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockMapSnapshotCapability,
capabilities.RoborockCombinedVirtualRestrictionsCapability,
capabilities.RoborockPersistentMapControlCapability,
Expand Down
1 change: 0 additions & 1 deletion backend/lib/robots/roborock/RoborockS6MaxVValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class RoborockS6MaxVValetudoRobot extends RoborockValetudoRobot {
}));

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockMultiMapPersistentMapControlCapability,
capabilities.RoborockMultiMapMapResetCapability,
capabilities.RoborockMapSegmentationCapability,
Expand Down
1 change: 0 additions & 1 deletion backend/lib/robots/roborock/RoborockS6PureValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class RoborockS6PureValetudoRobot extends RoborockValetudoRobot {
super(Object.assign({}, options, {fanSpeeds: FAN_SPEEDS}));

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockCombinedVirtualRestrictionsCapability,
capabilities.RoborockMultiMapPersistentMapControlCapability,
capabilities.RoborockMultiMapMapResetCapability,
Expand Down
1 change: 0 additions & 1 deletion backend/lib/robots/roborock/RoborockS6ValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RoborockS6ValetudoRobot extends RoborockValetudoRobot {
}));

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockMapSnapshotCapability,
capabilities.RoborockMultiMapPersistentMapControlCapability,
capabilities.RoborockMultiMapMapResetCapability,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const capabilities = require("./capabilities");
const entities = require("../../entities");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const QuirksCapability = require("../../core/capabilities/QuirksCapability");
const RoborockConst = require("./RoborockConst");
const RoborockGen4ValetudoRobot = require("./RoborockGen4ValetudoRobot");
const RoborockQuirkFactory = require("./RoborockQuirkFactory");
const RoborockValetudoRobot = require("./RoborockValetudoRobot");
Expand All @@ -23,7 +24,7 @@ class RoborockS7ProUltraValetudoRobot extends RoborockGen4ValetudoRobot {
{
waterGrades: WATER_GRADES,
supportedAttachments: SUPPORTED_ATTACHMENTS,
hasUltraDock: true
dockType: RoborockConst.DOCK_TYPE.ULTRA
}
)
);
Expand All @@ -44,11 +45,6 @@ class RoborockS7ProUltraValetudoRobot extends RoborockGen4ValetudoRobot {
})
}));

this.registerCapability(new capabilities.RoborockConsumableMonitoringCapability({
robot: this,
hasUltraDock: true
}));

this.registerCapability(new capabilities.RoborockCarpetSensorModeControlCapability({
robot: this,
liftModeId: 1
Expand Down
5 changes: 3 additions & 2 deletions backend/lib/robots/roborock/RoborockS7ValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const capabilities = require("./capabilities");
const entities = require("../../entities");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const QuirksCapability = require("../../core/capabilities/QuirksCapability");
const RoborockConst = require("./RoborockConst");
const RoborockGen4ValetudoRobot = require("./RoborockGen4ValetudoRobot");
const RoborockQuirkFactory = require("./RoborockQuirkFactory");
const RoborockValetudoRobot = require("./RoborockValetudoRobot");
Expand All @@ -21,7 +22,8 @@ class RoborockS7ValetudoRobot extends RoborockGen4ValetudoRobot {
options,
{
waterGrades: WATER_GRADES,
supportedAttachments: SUPPORTED_ATTACHMENTS
supportedAttachments: SUPPORTED_ATTACHMENTS,
dockType: RoborockConst.DOCK_TYPE.AUTO_EMPTY
}
)
);
Expand All @@ -48,7 +50,6 @@ class RoborockS7ValetudoRobot extends RoborockGen4ValetudoRobot {
}));

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockAutoEmptyDockAutoEmptyControlCapability,
capabilities.RoborockAutoEmptyDockManualTriggerCapability,
capabilities.RoborockKeyLockCapability,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fs = require("fs");
const Logger = require("../../Logger");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const QuirksCapability = require("../../core/capabilities/QuirksCapability");
const RoborockConst = require("./RoborockConst");
const RoborockGen4ValetudoRobot = require("./RoborockGen4ValetudoRobot");
const RoborockQuirkFactory = require("./RoborockQuirkFactory");
const RoborockValetudoRobot = require("./RoborockValetudoRobot");
Expand All @@ -24,7 +25,7 @@ class RoborockS8ProUltraValetudoRobot extends RoborockGen4ValetudoRobot {
{
waterGrades: WATER_GRADES,
supportedAttachments: SUPPORTED_ATTACHMENTS,
hasUltraDock: true
dockType: RoborockConst.DOCK_TYPE.ULTRA
}
)
);
Expand All @@ -45,11 +46,6 @@ class RoborockS8ProUltraValetudoRobot extends RoborockGen4ValetudoRobot {
})
}));

this.registerCapability(new capabilities.RoborockConsumableMonitoringCapability({
robot: this,
hasUltraDock: true
}));

this.registerCapability(new capabilities.RoborockCarpetSensorModeControlCapability({
robot: this,
liftModeId: 3
Expand Down
5 changes: 3 additions & 2 deletions backend/lib/robots/roborock/RoborockS8ValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fs = require("fs");
const Logger = require("../../Logger");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const QuirksCapability = require("../../core/capabilities/QuirksCapability");
const RoborockConst = require("./RoborockConst");
const RoborockGen4ValetudoRobot = require("./RoborockGen4ValetudoRobot");
const RoborockQuirkFactory = require("./RoborockQuirkFactory");
const RoborockValetudoRobot = require("./RoborockValetudoRobot");
Expand All @@ -23,7 +24,8 @@ class RoborockS8ValetudoRobot extends RoborockGen4ValetudoRobot {
options,
{
waterGrades: WATER_GRADES,
supportedAttachments: SUPPORTED_ATTACHMENTS
supportedAttachments: SUPPORTED_ATTACHMENTS,
dockType: RoborockConst.DOCK_TYPE.AUTO_EMPTY
}
)
);
Expand All @@ -50,7 +52,6 @@ class RoborockS8ValetudoRobot extends RoborockGen4ValetudoRobot {
}));

[
capabilities.RoborockConsumableMonitoringCapability,
capabilities.RoborockAutoEmptyDockAutoEmptyControlCapability,
capabilities.RoborockAutoEmptyDockManualTriggerCapability,
capabilities.RoborockKeyLockCapability,
Expand Down
7 changes: 0 additions & 7 deletions backend/lib/robots/roborock/RoborockV1ValetudoRobot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const capabilities = require("./capabilities");
const entities = require("../../entities");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const RoborockValetudoRobot = require("./RoborockValetudoRobot");
Expand All @@ -14,12 +13,6 @@ class RoborockV1ValetudoRobot extends RoborockValetudoRobot {
*/
constructor(options) {
super(Object.assign({}, options, {fanSpeeds: FAN_SPEEDS}));

[
capabilities.RoborockConsumableMonitoringCapability,
].forEach(capability => {
this.registerCapability(new capability({robot: this}));
});
}

getModelName() {
Expand Down
15 changes: 10 additions & 5 deletions backend/lib/robots/roborock/RoborockValetudoRobot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const capabilities = require("./capabilities");
const fs = require("fs");
const Logger = require("../../Logger");
const RoborockConst = require("./RoborockConst");
const RoborockMapParser = require("./RoborockMapParser");

const DustBinFullValetudoEvent = require("../../valetudo_events/events/DustBinFullValetudoEvent");
Expand All @@ -27,7 +28,7 @@ class RoborockValetudoRobot extends MiioValetudoRobot {
* @param {object} options.fanSpeeds
* @param {object} [options.waterGrades]
* @param {Array<import("../../entities/state/attributes/AttachmentStateAttribute").AttachmentStateAttributeType>} [options.supportedAttachments]
* @param {boolean} [options.hasUltraDock]
* @param {import("./RoborockConst").DOCK_TYPE} [options.dockType]
*/
constructor(options) {
super(options);
Expand All @@ -36,6 +37,7 @@ class RoborockValetudoRobot extends MiioValetudoRobot {
this.fanSpeeds = options.fanSpeeds;
this.waterGrades = options.waterGrades ?? {};
this.supportedAttachments = options.supportedAttachments ?? [];
this.dockType = options.dockType ?? RoborockConst.DOCK_TYPE.CHARGING;

this.supportedAttachments.forEach(attachmentType => {
this.state.upsertFirstMatchingAttribute(new entities.state.attributes.AttachmentStateAttribute({
Expand All @@ -44,15 +46,18 @@ class RoborockValetudoRobot extends MiioValetudoRobot {
}));
});

this.hasUltraDock = !!options.hasUltraDock;

this.registerCapability(new capabilities.RoborockFanSpeedControlCapability({
robot: this,
presets: Object.keys(this.fanSpeeds).map(k => {
return new ValetudoSelectionPreset({name: k, value: this.fanSpeeds[k]});
})
}));

this.registerCapability(new capabilities.RoborockConsumableMonitoringCapability({
robot: this,
dockType: this.dockType
}));

[
capabilities.RoborockBasicControlCapability,
capabilities.RoborockZoneCleaningCapability,
Expand Down Expand Up @@ -82,7 +87,7 @@ class RoborockValetudoRobot extends MiioValetudoRobot {
}));
}

if (this.hasUltraDock) {
if (this.dockType === RoborockConst.DOCK_TYPE.ULTRA) {
this.state.upsertFirstMatchingAttribute(new entities.state.attributes.DockStatusStateAttribute({
value: entities.state.attributes.DockStatusStateAttribute.VALUE.IDLE
}));
Expand Down Expand Up @@ -247,7 +252,7 @@ class RoborockValetudoRobot extends MiioValetudoRobot {
parseAndUpdateState(data) {
let newStateAttr;

if (this.hasUltraDock) {
if (this.dockType === RoborockConst.DOCK_TYPE.ULTRA) {
if (data["state"] !== undefined) {
switch (data["state"]) {
case 23:
Expand Down
Loading

0 comments on commit e3d13fa

Please sign in to comment.