Skip to content

Commit

Permalink
fix(vendor.dreame): Assume that we're in the docked state if we're ch…
Browse files Browse the repository at this point in the history
…arging on the 1C
  • Loading branch information
Hypfer committed Nov 20, 2021
1 parent c1a51e9 commit c73e062
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions backend/lib/robots/dreame/Dreame1CValetudoRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ class Dreame1CValetudoRobot extends DreameValetudoRobot {
);

this.lastMapPoll = new Date(0);
this.isCharging = false;

this.registerCapability(new capabilities.Dreame1CBasicControlCapability({
robot: this,
Expand Down Expand Up @@ -626,6 +627,10 @@ class Dreame1CValetudoRobot extends DreameValetudoRobot {
{
siid: MIOT_SERVICES.BATTERY.SIID,
piid: MIOT_SERVICES.BATTERY.PROPERTIES.LEVEL.PIID
},
{
siid: MIOT_SERVICES.BATTERY.SIID,
piid: MIOT_SERVICES.BATTERY.PROPERTIES.CHARGING.PIID
}
].map(e => {
e.did = this.deviceId;
Expand Down Expand Up @@ -739,6 +744,15 @@ class Dreame1CValetudoRobot extends DreameValetudoRobot {
level: elem.value
}));
break;
case MIOT_SERVICES.BATTERY.PROPERTIES.CHARGING.PIID:
/*
1 = On Charger
2 = Not on Charger
5 = Returning to Charger
*/
this.isCharging = elem.value === 1;
this.stateNeedsUpdate = true;
break;
}
break;
}
Expand Down Expand Up @@ -766,6 +780,10 @@ class Dreame1CValetudoRobot extends DreameValetudoRobot {
statusValue = DreameValetudoRobot.STATUS_MAP[this.mode].value;
statusFlag = DreameValetudoRobot.STATUS_MAP[this.mode].flag;

if (this.isCharging === true) {
statusValue = stateAttrs.StatusStateAttribute.VALUE.DOCKED;
}

if (statusValue === stateAttrs.StatusStateAttribute.VALUE.DOCKED && this.taskStatus === 0) {
// Robot has a pending task but is charging due to low battery and will resume when battery >= 80%
statusFlag = stateAttrs.StatusStateAttribute.FLAG.RESUMABLE;
Expand Down

0 comments on commit c73e062

Please sign in to comment.