mirror of https://github.com/Hypfer/Valetudo.git
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
const CurrentStatisticsCapability = require("../../../core/capabilities/CurrentStatisticsCapability");
|
|
const ValetudoDataPoint = require("../../../entities/core/ValetudoDataPoint");
|
|
|
|
/**
|
|
* @extends CurrentStatisticsCapability<import("../RoborockValetudoRobot")>
|
|
*/
|
|
class RoborockCurrentStatisticsCapability extends CurrentStatisticsCapability {
|
|
/**
|
|
* @param {object} options
|
|
* @param {import("../RoborockValetudoRobot")} options.robot
|
|
*/
|
|
constructor(options) {
|
|
super(options);
|
|
|
|
this.currentStatistics = {
|
|
time: undefined,
|
|
area: undefined
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @return {Promise<Array<ValetudoDataPoint>>}
|
|
*/
|
|
async getStatistics() {
|
|
await this.robot.pollState(); //fetching robot state populates the capability's internal state. somewhat spaghetti :(
|
|
|
|
return [
|
|
new ValetudoDataPoint({
|
|
type: ValetudoDataPoint.TYPES.TIME,
|
|
value: this.currentStatistics.time
|
|
}),
|
|
new ValetudoDataPoint({
|
|
type: ValetudoDataPoint.TYPES.AREA,
|
|
value: this.currentStatistics.area
|
|
})
|
|
];
|
|
}
|
|
|
|
getProperties() {
|
|
return {
|
|
availableStatistics: [
|
|
ValetudoDataPoint.TYPES.TIME,
|
|
ValetudoDataPoint.TYPES.AREA
|
|
]
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = RoborockCurrentStatisticsCapability;
|