homebridge-virtual-accessories
Version:
Virtual HomeKit accessories for Homebridge.
43 lines • 1.5 kB
JavaScript
import { Sensor } from './sensor.js';
/**
* CarbonDioxideSensor - Sensor implementation
*/
export class CarbonDioxideSensor extends Sensor {
static ACCESSORY_TYPE_NAME = 'CarbonDioxideSensor';
static CO2_LEVELS_NORMAL = 0; // Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL;
static CO2_LEVELS_ABNORMAL = 1; // Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL;
constructor(platform, accessory, accessoryConfiguration) {
super(platform, accessory, accessoryConfiguration);
}
getService() {
return this.platform.Service.CarbonDioxideSensor;
}
getEventDetectedCharacteristic() {
return this.platform.Characteristic.CarbonDioxideDetected;
}
getStateName(state) {
let sensorStateName;
switch (state) {
case undefined: {
sensorStateName = 'undefined';
break;
}
case CarbonDioxideSensor.CO2_LEVELS_NORMAL: {
sensorStateName = Sensor.NORMAL_INACTIVE;
break;
}
case CarbonDioxideSensor.CO2_LEVELS_ABNORMAL: {
sensorStateName = Sensor.TRIGGERED_ACTIVE;
break;
}
default: {
sensorStateName = state.toString();
}
}
return sensorStateName;
}
getAccessoryTypeName() {
return CarbonDioxideSensor.ACCESSORY_TYPE_NAME;
}
}
//# sourceMappingURL=virtualSensorCarbonDioxide.js.map