Skip to content

Commit

Permalink
feat(vendor.viomi): Add y_mopping quirk
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed Nov 12, 2022
1 parent 0c7d757 commit 5ac847f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
43 changes: 42 additions & 1 deletion backend/lib/robots/viomi/ViomiQuirkFactory.js
Expand Up @@ -54,14 +54,55 @@ class ViomiQuirkFactory {
return this.robot.sendCommand("set_light", [val], {});
}
});
case ViomiQuirkFactory.KNOWN_QUIRKS.MOP_PATTERN:
return new Quirk({
id: id,
title: "Mop Pattern",
description: "This robot can either mop in straight lines or in a Y-pattern",
options: ["normal", "y_pattern"],
getter: async () => {
const res = await this.robot.sendCommand("get_prop", ["mop_route"], {});

if (!(Array.isArray(res) && res.length === 1)) {
throw new Error(`Received invalid response: ${res}`);
} else {
switch (res[0]) {
case 1:
return "y_pattern";
case 0:
return "normal";
default:
throw new Error(`Received invalid value ${res}`);
}
}

},
setter: async (value) => {
let val;

switch (value) {
case "y_pattern":
val = 1;
break;
case "normal":
val = 0;
break;
default:
throw new Error(`Received invalid value ${value}`);
}

return this.robot.sendCommand("set_moproute", [val], {});
}
});
default:
throw new Error(`There's no quirk with id ${id}`);
}
}
}

ViomiQuirkFactory.KNOWN_QUIRKS = {
BUTTON_LEDS: "977c5972-1f12-4ef1-9622-ce71fd085193"
BUTTON_LEDS: "977c5972-1f12-4ef1-9622-ce71fd085193",
MOP_PATTERN: "0ae06cb4-8cc7-429f-95fb-f3d0bbfc06de"
};

module.exports = ViomiQuirkFactory;
3 changes: 2 additions & 1 deletion backend/lib/robots/viomi/ViomiV6ValetudoRobot.js
Expand Up @@ -26,7 +26,8 @@ class ViomiV6ValetudoRobot extends ViomiValetudoRobot {
this.registerCapability(new QuirksCapability({
robot: this,
quirks: [
quirkFactory.getQuirk(ViomiQuirkFactory.KNOWN_QUIRKS.BUTTON_LEDS)
quirkFactory.getQuirk(ViomiQuirkFactory.KNOWN_QUIRKS.BUTTON_LEDS),
quirkFactory.getQuirk(ViomiQuirkFactory.KNOWN_QUIRKS.MOP_PATTERN)
]
}));
}
Expand Down

0 comments on commit 5ac847f

Please sign in to comment.