Skip to content

Commit

Permalink
fix(vendor.dreame): Gracefully handle comma-separated error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed Feb 19, 2023
1 parent 87eb6af commit 460c5d1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion backend/lib/robots/dreame/DreameGen2ValetudoRobot.js
Expand Up @@ -471,7 +471,7 @@ class DreameGen2ValetudoRobot extends DreameValetudoRobot {
break;
}
case MIOT_SERVICES.VACUUM_2.PROPERTIES.ERROR_CODE.PIID: {
this.errorCode = elem.value;
this.errorCode = elem.value ?? "";

this.stateNeedsUpdate = true;
break;
Expand Down Expand Up @@ -626,6 +626,25 @@ class DreameGen2ValetudoRobot extends DreameValetudoRobot {
let statusError;
let statusMetaData = {};

/*
Somewhere in 2022, Dreame firmwares gained the ability to report multiple error codes at once
only separated by a comma. At the time of writing, the Valetudo abstraction does not support that.
Most of the time, it's two codes with one code being a non-error reminder error code.
Additionally, in all reported cases where there were two actual error codes, both of them mapped
to the same error type and description in Valetudo.
We can therefore simply filter the non-error codes and pick the first remaining element.
*/
if (this.errorCode.includes(",")) {
let errorArray = this.errorCode.split(",");

errorArray = errorArray.filter(e => !["68", "114"].includes(e));

this.errorCode = errorArray[0] ?? "";
}


if (this.errorCode === "0" || this.errorCode === "") {
statusValue = DreameValetudoRobot.STATUS_MAP[this.mode]?.value ?? stateAttrs.StatusStateAttribute.VALUE.IDLE;
statusFlag = DreameValetudoRobot.STATUS_MAP[this.mode]?.flag;
Expand Down

0 comments on commit 460c5d1

Please sign in to comment.