UNPKG

homebridge-miot

Version:

Homebridge plugin for devices supporting the miot protocol

94 lines (52 loc) 2.48 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'); //NOT: Color and Color Temp on a accessory are problematic for the color wheel in the home app, it always reads the color value when available so the selected color in the wheel will not match when color temeprature is set! class LightAccessory 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() { super.initAccessoryObject(); } /*----------========== ACCESSORY INFO ==========----------*/ getAccessoryType() { return DevTypes.LIGHT; } /*----------========== INIT ACCESSORIES ==========----------*/ initAccessories(name, uuid) { return [new Accessory(name, uuid, this.api.hap.Accessory.Categories.LIGHTBULB)]; } /*----------========== SETUP SERVICES ==========----------*/ setupMainAccessoryService() { if (this.getDevice().hasLightService()) { this.addLightService('lightService', this.getName(), this.getDevice().getLightService()); } } setupAdditionalAccessoryServices() { if (this.getDevice().hasAmbientLightService()) { this.addLightService('ambientLightService', "Ambient Light", this.getDevice().getAmbientLightService()); } 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 = LightAccessory;