Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vendor.viomi): Refactoring, fixes and tests
- Loading branch information
Showing
9 changed files
with
2,537 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const capabilities = require("./capabilities"); | ||
const MiioValetudoRobot = require("../MiioValetudoRobot"); | ||
const QuirksCapability = require("../../core/capabilities/QuirksCapability"); | ||
const ViomiQuirkFactory = require("./ViomiQuirkFactory"); | ||
const ViomiValetudoRobot = require("./ViomiValetudoRobot"); | ||
|
||
|
||
class ViomiV6ValetudoRobot extends ViomiValetudoRobot { | ||
/** | ||
* @param {object} options | ||
* @param {import("../../Configuration")} options.config | ||
* @param {import("../../ValetudoEventStore")} options.valetudoEventStore | ||
* @param {object} [options.fanSpeeds] | ||
* @param {object} [options.waterGrades] | ||
*/ | ||
constructor(options) { | ||
super(options); | ||
|
||
this.registerCapability(new capabilities.ViomiVoicePackManagementCapability({ | ||
robot: this | ||
})); | ||
|
||
const quirkFactory = new ViomiQuirkFactory({ | ||
robot: this | ||
}); | ||
this.registerCapability(new QuirksCapability({ | ||
robot: this, | ||
quirks: [ | ||
quirkFactory.getQuirk(ViomiQuirkFactory.KNOWN_QUIRKS.BUTTON_LEDS) | ||
] | ||
})); | ||
} | ||
|
||
getModelName() { | ||
return "V6"; | ||
} | ||
|
||
static IMPLEMENTATION_AUTO_DETECTION_HANDLER() { | ||
const deviceConf = MiioValetudoRobot.READ_DEVICE_CONF(ViomiValetudoRobot.DEVICE_CONF_PATH); | ||
return !!(deviceConf && deviceConf.model === "viomi.vacuum.v6"); | ||
} | ||
} | ||
|
||
module.exports = ViomiV6ValetudoRobot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const capabilities = require("./capabilities"); | ||
const MiioValetudoRobot = require("../MiioValetudoRobot"); | ||
const QuirksCapability = require("../../core/capabilities/QuirksCapability"); | ||
const ViomiQuirkFactory = require("./ViomiQuirkFactory"); | ||
const ViomiValetudoRobot = require("./ViomiValetudoRobot"); | ||
|
||
|
||
class ViomiV8ValetudoRobot extends ViomiValetudoRobot { | ||
/** | ||
* @param {object} options | ||
* @param {import("../../Configuration")} options.config | ||
* @param {import("../../ValetudoEventStore")} options.valetudoEventStore | ||
* @param {object} [options.fanSpeeds] | ||
* @param {object} [options.waterGrades] | ||
*/ | ||
constructor(options) { | ||
super(options); | ||
|
||
this.registerCapability(new capabilities.ViomiVoicePackManagementCapability({ | ||
robot: this | ||
})); | ||
|
||
const quirkFactory = new ViomiQuirkFactory({ | ||
robot: this | ||
}); | ||
this.registerCapability(new QuirksCapability({ | ||
robot: this, | ||
quirks: [ | ||
quirkFactory.getQuirk(ViomiQuirkFactory.KNOWN_QUIRKS.BUTTON_LEDS) | ||
] | ||
})); | ||
} | ||
|
||
getModelName() { | ||
return "V8"; | ||
} | ||
|
||
static IMPLEMENTATION_AUTO_DETECTION_HANDLER() { | ||
const deviceConf = MiioValetudoRobot.READ_DEVICE_CONF(ViomiValetudoRobot.DEVICE_CONF_PATH); | ||
return !!(deviceConf && ["viomi.vacuum.v8", "viomi.vacuum.v9"].includes(deviceConf.model)); | ||
} | ||
} | ||
|
||
module.exports = ViomiV8ValetudoRobot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module.exports = { | ||
"ViomiV6ValetudoRobot": require("./ViomiV6ValetudoRobot"), | ||
"ViomiV7ValetudoRobot": require("./ViomiV7ValetudoRobot"), | ||
"ViomiV8ValetudoRobot": require("./ViomiV8ValetudoRobot"), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const fs = require("fs").promises; | ||
const path = require("path"); | ||
const should = require("should"); | ||
|
||
const ViomiMapParser = require("../../../../lib/robots/viomi/ViomiMapParser"); | ||
|
||
should.config.checkProtoEql = false; | ||
|
||
describe("ViomiMapParser", function () { | ||
it("Should pre-process & parse v7 fw 47 map with currently cleaned segments", async function() { | ||
let data = await fs.readFile(path.join(__dirname, "/res/map/v7_47_cleaned_segment_ids.bin")); | ||
let expected = JSON.parse(await fs.readFile(path.join(__dirname, "/res/map/v7_47_cleaned_segment_ids.json"), { encoding: "utf-8" })); | ||
const parserInstance = new ViomiMapParser(await ViomiMapParser.PREPROCESS(data)); | ||
let actual = parserInstance.parse(); | ||
|
||
if (actual.metaData?.nonce) { | ||
delete(actual.metaData.nonce); | ||
} | ||
|
||
actual.layers.length.should.equal(expected.layers.length, "layerCount"); | ||
|
||
actual.layers.forEach((layer, i) => { | ||
actual.layers[i].should.deepEqual(expected.layers[i]); | ||
}); | ||
|
||
actual.entities.length.should.equal(expected.entities.length, "entitiesCount"); | ||
|
||
actual.entities.forEach((layer, i) => { | ||
actual.entities[i].should.deepEqual(expected.entities[i]); | ||
}); | ||
|
||
actual.should.deepEqual(expected); | ||
}); | ||
}); |
Binary file not shown.
Oops, something went wrong.