Skip to content

Commit

Permalink
feat(vendor.Dreame): Adding wheel consumable monitoring (master branch)
Browse files Browse the repository at this point in the history
  • Loading branch information
DGAlexandru committed Jan 8, 2025
1 parent 0790d4c commit 50a2554
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 1 deletion.
2 changes: 2 additions & 0 deletions backend/lib/robots/dreame/DreameGen2NoCloudRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ class DreameGen2NoCloudRobot extends DreameNoCloudRobot {
case MIOT_SERVICES.MOP.SIID:
case MIOT_SERVICES.SECONDARY_FILTER.SIID:
case MIOT_SERVICES.DETERGENT.SIID:
case MIOT_SERVICES.WHEEL.SIID:
case MIOT_SERVICES.MOP_EXPANSION.SIID:
case MIOT_SERVICES.MISC_STATES.SIID:
this.parseAndUpdateState([e]);
Expand Down Expand Up @@ -652,6 +653,7 @@ class DreameGen2NoCloudRobot extends DreameNoCloudRobot {
case MIOT_SERVICES.MOP.SIID:
case MIOT_SERVICES.SECONDARY_FILTER.SIID:
case MIOT_SERVICES.DETERGENT.SIID:
case MIOT_SERVICES.WHEEL.SIID:
if (this.capabilities[ConsumableMonitoringCapability.TYPE]) {
this.capabilities[ConsumableMonitoringCapability.TYPE].parseConsumablesMessage(elem);
}
Expand Down
8 changes: 8 additions & 0 deletions backend/lib/robots/dreame/DreameL40UltraNoCloudRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class DreameL40UltraNoCloudRobot extends DreameGen4NoCloudRobot {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.SIID,
piid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.PROPERTIES.TIME_LEFT.PIID
},
wheel: {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.SIID,
piid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.PROPERTIES.TIME_LEFT.PIID
}
},
miot_actions: {
reset_main_brush: {
Expand All @@ -108,6 +112,10 @@ class DreameL40UltraNoCloudRobot extends DreameGen4NoCloudRobot {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.SIID,
aiid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.ACTIONS.RESET.AIID
},
reset_wheel: {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.SIID,
aiid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.ACTIONS.RESET.AIID
}
},
}));

Expand Down
18 changes: 17 additions & 1 deletion backend/lib/robots/dreame/DreameMiotServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,22 @@ module.exports = {
PIID: 4
}
}
}
},
WHEEL: {
SIID: 30,
PROPERTIES: {
TIME_LEFT: { //Hours
PIID: 1
},
PERCENT_LEFT: {
PIID: 2
}
},
ACTIONS: {
RESET: {
AIID: 1
}
}
},
})
};
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class DreameMovaP10ProUltraNoCloudRobot extends DreameGen4NoCloudRobot {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.SIID,
piid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.PROPERTIES.TIME_LEFT.PIID
},
wheel: {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.SIID,
piid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.PROPERTIES.TIME_LEFT.PIID
}
},
miot_actions: {
reset_main_brush: {
Expand All @@ -108,6 +112,10 @@ class DreameMovaP10ProUltraNoCloudRobot extends DreameGen4NoCloudRobot {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.SIID,
aiid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.ACTIONS.RESET.AIID
},
reset_wheel: {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.SIID,
aiid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.ACTIONS.RESET.AIID
}
},
}));

Expand Down
8 changes: 8 additions & 0 deletions backend/lib/robots/dreame/DreameX40MasterNoCloudRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class DreameX40MasterNoCloudRobot extends DreameGen4NoCloudRobot {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.SIID,
piid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.PROPERTIES.TIME_LEFT.PIID
},
wheel: {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.SIID,
piid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.PROPERTIES.TIME_LEFT.PIID
}
},
miot_actions: {
reset_main_brush: {
Expand All @@ -108,6 +112,10 @@ class DreameX40MasterNoCloudRobot extends DreameGen4NoCloudRobot {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.SIID,
aiid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.ACTIONS.RESET.AIID
},
reset_wheel: {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.SIID,
aiid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.ACTIONS.RESET.AIID
}
},
}));

Expand Down
8 changes: 8 additions & 0 deletions backend/lib/robots/dreame/DreameX40UltraNoCloudRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class DreameX40UltraNoCloudRobot extends DreameGen4NoCloudRobot {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.SIID,
piid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.PROPERTIES.TIME_LEFT.PIID
},
wheel: {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.SIID,
piid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.PROPERTIES.TIME_LEFT.PIID
}
},
miot_actions: {
reset_main_brush: {
Expand All @@ -108,6 +112,10 @@ class DreameX40UltraNoCloudRobot extends DreameGen4NoCloudRobot {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.SIID,
aiid: DreameGen2NoCloudRobot.MIOT_SERVICES.SENSOR.ACTIONS.RESET.AIID
},
reset_wheel: {
siid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.SIID,
aiid: DreameGen2NoCloudRobot.MIOT_SERVICES.WHEEL.ACTIONS.RESET.AIID
}
},
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class DreameConsumableMonitoringCapability extends ConsumableMonitoringCapabilit
* @param {object} [options.miot_actions.reset_detergent]
* @param {number} options.miot_actions.reset_detergent.siid
* @param {number} options.miot_actions.reset_detergent.aiid
*
* @param {object} [options.miot_actions.reset_wheel]
* @param {number} options.miot_actions.reset_wheel.siid
* @param {number} options.miot_actions.reset_wheel.aiid
*
*
* @param {object} options.miot_properties
Expand Down Expand Up @@ -70,6 +74,10 @@ class DreameConsumableMonitoringCapability extends ConsumableMonitoringCapabilit
* @param {object} [options.miot_properties.detergent]
* @param {number} options.miot_properties.detergent.siid
* @param {number} options.miot_properties.detergent.piid
*
* @param {object} [options.miot_properties.wheel]
* @param {number} options.miot_properties.wheel.siid
* @param {number} options.miot_properties.wheel.piid
*/
constructor(options) {
super(options);
Expand Down Expand Up @@ -108,6 +116,10 @@ class DreameConsumableMonitoringCapability extends ConsumableMonitoringCapabilit
props.push(this.miot_properties.detergent);
}

if (this.miot_properties.wheel) {
props.push(this.miot_properties.wheel);
}


const response = await this.robot.sendCommand("get_properties", props.map(e => {
return Object.assign({}, e, {did: this.robot.deviceId});
Expand Down Expand Up @@ -164,6 +176,11 @@ class DreameConsumableMonitoringCapability extends ConsumableMonitoringCapabilit
payload = this.miot_actions.reset_sensor;
}
break;
case ConsumableStateAttribute.SUB_TYPE.WHEEL:
if (this.miot_actions.reset_wheel) {
payload = this.miot_actions.reset_wheel;
}
break;

}
break;
Expand Down Expand Up @@ -315,6 +332,20 @@ class DreameConsumableMonitoringCapability extends ConsumableMonitoringCapabilit
}
});
}
} else if (
this.miot_properties.wheel &&
msg.siid === this.miot_properties.wheel.siid
) {
if (msg.piid === this.miot_properties.wheel.piid) {
consumable = new ConsumableStateAttribute({
type: ConsumableStateAttribute.TYPE.CLEANING,
subType: ConsumableStateAttribute.SUB_TYPE.WHEEL,
remaining: {
value: Math.round(Math.max(0, msg.value * 60)),
unit: ConsumableStateAttribute.UNITS.MINUTES
}
});
}
}
}

Expand Down Expand Up @@ -391,6 +422,17 @@ class DreameConsumableMonitoringCapability extends ConsumableMonitoringCapabilit
);
}

if (this.miot_properties.wheel) {
availableConsumables.push(
{
type: ConsumableStateAttribute.TYPE.CLEANING,
subType: ConsumableStateAttribute.SUB_TYPE.WHEEL,
unit: ConsumableStateAttribute.UNITS.MINUTES,
maxValue: 30 * 60
}
);
}

return {
availableConsumables: availableConsumables
};
Expand Down

0 comments on commit 50a2554

Please sign in to comment.