Skip to content

Commit

Permalink
Refine NoCloud update checks
Browse files Browse the repository at this point in the history
  • Loading branch information
DGAlexandru committed Nov 18, 2024
1 parent 7794cad commit 823f6cf
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions backend/lib/updater/lib/steps/NoCloudUpdaterCheckStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,20 @@ class NoCloudUpdaterCheckStep extends NoCloudUpdaterStep {
stateAttrs.BatteryStateAttribute
);

if ((Math.round(batteryLevel.level)) < 50) {
if (!(statusAttribute && statusAttribute.value === stateAttrs.StatusStateAttribute.VALUE.DOCKED)) {
if (!(statusAttribute && statusAttribute.value === stateAttrs.StatusStateAttribute.VALUE.DOCKED)) {
if ((Math.round(batteryLevel.level)) >= 50) {
if (!(statusAttribute && statusAttribute.value === stateAttrs.StatusStateAttribute.VALUE.IDLE)) {
throw new NoCloudUpdaterError(
NoCloudUpdaterError.ERROR_TYPE.NOT_IDLE,
`Updating NoCloud is allowed only if the Robot is Idle or Docked! Current status: ${statusAttribute.value}`
);
}
} else {
throw new NoCloudUpdaterError(
NoCloudUpdaterError.ERROR_TYPE.NOT_DOCKED,
[
`Current battery level: ${Math.round(batteryLevel.level)}`,
"With battery level lower than 50% updating is permitted only while the robot is docked!"
].join()
`To update NoCloud with a battery level lower than 50% you need to Dock the Robot! Battery level: ${Math.round(batteryLevel.level)}%`
);
}
} else if (!(statusAttribute && statusAttribute.value === stateAttrs.StatusStateAttribute.VALUE.IDLE)) {
throw new NoCloudUpdaterError(
NoCloudUpdaterError.ERROR_TYPE.NOT_IDLE,
[
`Current status: ${statusAttribute.value}`,
"Updating NoCloud is only allowed if the Robot is Idle or Docked!"
].join()
);
}

const {
Expand Down

0 comments on commit 823f6cf

Please sign in to comment.