cap:carbon-monoxide-leve
- read carbon monoxide level¶
This capability is used to mark sensors that report their carbon monoxide level as PPM (parts per million). The value is reported as a number.
if(thing.matches('cap:carbon-monoxide-level')) {
console.log('Carbon monoxide:', await thing.carbonMonoxideLevel());
thing.on('carbonMonoxideLevelChanged', v => console.log('Changed to:', v));
}
API¶
Events¶
Protected methods¶
Implementing capability¶
Implementors of this capability should call updateCarbonMonoxideLevel
whenever the PPM of carbon monoxide changes.
const { Sensor, CarbonMonoxideLevel } = require('abstract-things/sensors');
class Example extends Sensor.with(CarbonMonoxideLevel) {
constructor() {
super();
this.updateCarbonMonoxideLevel(0);
}
}