cap:autonomous-cleaning
- activate cleaning¶
autonomous-cleaning
is an extension to cleaning state
for things that also support autonomously performing cleaning. This is commonly
used for robots such as robot vacuums and robot mops.
if(thing.matches('cap:autonomous-cleaning')) {
const isCleaning = await thing.cleaning();
if(! isCleaning) {
// Request clean if not currently cleaning
await thing.clean();
}
}
API¶
-
clean
()¶ Start autonomous cleaning.
Returns: Promise that resolves to null
.Example:
// Using async/await await thing.clean(); // Using promise then/catch thing.clean() .then(...) .catch(...);
-
stop
()¶ Stop autonomous cleaning.
Returns: Promise that resolves to null
.Example:
// Using async/await await thing.stop(); // Using promise then/catch thing.stop() .then(...) .catch(...);
Protected methods¶
-
activateCleaning
()¶ Abstract. Activate autonomous cleaning. Called whenever
clean()
is called by the user.Returns: Promise if asynchronous. Example:
activateCleaning() { return activateViaPromise(...) .then(() => this.updateCleaning(true)); }
-
deactivateCleaning
()¶ Abstract. Deactivate autonomous cleaning. Called whenever
stop()
is called by the user.Returns: Promise if asynchronous. Example:
deactivateCleaning() { return deactivateViaPromise(...) .then(() => this.updateCleaning(false)); }
Implementing capability¶
When implementing this capability refer to the requirements of
cleaning-state. In addition to that the methods
activateCleaning
and deactivateCleaning
need to be implemented.
Example:
const { Thing } = require('abstract-things');
const { AutonomousCleaning } = require('abstract-things/climate');
class Example extends Thing.with(AutonomousCleaning) {
activateCleaning() {
return ...;
}
deactivateCleaning() {
return ...;
}
}