fix(vendor.roborock): Gracefully handle dual-identity s5 max

This commit is contained in:
Sören Beye 2025-05-11 14:11:39 +02:00
parent 0f1ac47ce3
commit 2472f29429

View File

@ -1,5 +1,6 @@
const capabilities = require("./capabilities");
const entities = require("../../entities");
const fs = require("fs");
const MiioValetudoRobot = require("../MiioValetudoRobot");
const QuirksCapability = require("../../core/capabilities/QuirksCapability");
const RoborockQuirkFactory = require("./RoborockQuirkFactory");
@ -67,13 +68,27 @@ class RoborockS5MaxValetudoRobot extends RoborockValetudoRobot {
return "S5 Max";
}
setEmbeddedParameters() {
super.setEmbeddedParameters();
if (fs.existsSync(RESERVE_CONF_PATH)) {
this.deviceConfPath = RESERVE_CONF_PATH;
}
}
static IMPLEMENTATION_AUTO_DETECTION_HANDLER() {
const deviceConf = MiioValetudoRobot.READ_DEVICE_CONF(RoborockValetudoRobot.DEVICE_CONF_PATH);
const deviceConfPath = fs.existsSync(RESERVE_CONF_PATH) ? RESERVE_CONF_PATH : RoborockValetudoRobot.DEVICE_CONF_PATH;
const deviceConf = MiioValetudoRobot.READ_DEVICE_CONF(deviceConfPath);
return !!(deviceConf && deviceConf.model === "roborock.vacuum.s5e");
}
}
// As it should turn out, some of these robots actually have two identities of which the regular one stays unused.
// Roborock added logic in their stock firmware that prioritizes this second device.conf if it exists
// Hence, Valetudo shall do the same
const RESERVE_CONF_PATH = "/mnt/reserve/device.conf";
const FAN_SPEEDS = {
[entities.state.attributes.PresetSelectionStateAttribute.INTENSITY.LOW]: 101,
[entities.state.attributes.PresetSelectionStateAttribute.INTENSITY.MEDIUM]: 102,