UNPKG

homebridge-miot

Version:

Homebridge plugin for devices supporting the miot protocol

90 lines (49 loc) 2.23 kB
let Service, Characteristic, Accessory, HapStatusError, HAPStatus; const BaseAccessory = require('../../base/BaseAccessory.js'); const Constants = require('../../constants/Constants.js'); const DevTypes = require('../../constants/DevTypes.js'); class AirMonitorAccessory extends BaseAccessory { constructor(name, device, uuid, config, api, logger) { Service = api.hap.Service; Characteristic = api.hap.Characteristic; Accessory = api.platformAccessory; HapStatusError = api.hap.HapStatusError; HAPStatus = api.hap.HAPStatus; super(name, device, uuid, config, api, logger); } /*----------========== INIT ==========----------*/ initAccessoryObject() { this.pm25Breakpoints = this.getConfigValue('pm25Breakpoints', [7, 15, 30, 55]); this.co2AbnormalThreshold = this.getConfigValue('co2AbnormalThreshold', 1000); super.initAccessoryObject(); } /*----------========== ACCESSORY INFO ==========----------*/ getAccessoryType() { return DevTypes.AIR_MONITOR; } /*----------========== INIT ACCESSORIES ==========----------*/ initAccessories(name, uuid) { return [new Accessory(name, uuid, this.api.hap.Categories.SENSOR)]; } /*----------========== SETUP SERVICES ==========----------*/ setupMainAccessoryService() { this.prepareAirQualityService(this.pm25Breakpoints); } setupAdditionalAccessoryServices() { this.prepareCarbonDioxideService(this.co2AbnormalThreshold); super.setupAdditionalAccessoryServices(); // make sure we call super } /*----------========== CREATE ADDITIONAL SERVICES ==========----------*/ /*----------========== HOMEBRIDGE STATE SETTERS/GETTERS ==========----------*/ // ----- additional services /*----------========== STATUS ==========----------*/ updateAccessoryStatus() { super.updateAccessoryStatus(); } /*----------========== MULTI-SWITCH SERVICE HELPERS ==========----------*/ /*----------========== GETTERS ==========----------*/ /*----------========== PROPERTY WRAPPERS ==========----------*/ /*----------========== PROPERTY HELPERS ==========----------*/ /*----------========== HELPERS ==========----------*/ } module.exports = AirMonitorAccessory;