Skip to content

Commit

Permalink
fix(vendor.roborock): copy metadata from previous state on state upda…
Browse files Browse the repository at this point in the history
…te (#1489)
  • Loading branch information
004helix authored May 5, 2022
1 parent 7cf1fe9 commit 6ecc76b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion backend/lib/robots/roborock/RoborockValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,24 @@ class RoborockValetudoRobot extends MiioValetudoRobot {
) {
statusFlag = stateAttrs.StatusStateAttribute.FLAG.RESUMABLE;

if (data["in_cleaning"] === 2) {
if (data["in_cleaning"] === undefined) {
const previousState = this.state.getFirstMatchingAttributeByConstructor(stateAttrs.StatusStateAttribute);

// keep mataData from previous state
if (previousState &&
(
previousState.value === stateAttrs.StatusStateAttribute.VALUE.PAUSED ||
previousState.value === stateAttrs.StatusStateAttribute.VALUE.RETURNING ||
previousState.value === stateAttrs.StatusStateAttribute.VALUE.DOCKED
)
) {
if (previousState.metaData.zoned === true) {
statusMetaData.zoned = true;
} else if (previousState.metaData.segment_cleaning === true) {
statusMetaData.segment_cleaning = true;
}
}
} else if (data["in_cleaning"] === 2) {
//Since this is some roborock-related weirdness, we're using the metaData to store this
statusMetaData.zoned = true;
} else if (data["in_cleaning"] === 3) {
Expand Down

0 comments on commit 6ecc76b

Please sign in to comment.