diff --git a/lib/SimpleBlindsAccessory.js b/lib/SimpleBlindsAccessory.js index cacb709..e208ecc 100644 --- a/lib/SimpleBlindsAccessory.js +++ b/lib/SimpleBlindsAccessory.js @@ -15,12 +15,25 @@ class SimpleBlindsAccessory extends BaseAccessory { constructor(...props) { super(...props); } - + + _isType1() { + if (this.device.context.manufacturer.trim().toLowerCase() === 'type1') { + return true; + } else { + return false; + } + } + + _isType2() { + if (this.device.context.manufacturer.trim().toLowerCase() === 'type2') { + return true; + } else { + return false; + } + } _registerPlatformAccessory() { const {Service} = this.hap; - this.accessory.addService(Service.WindowCovering, this.device.context.name); - super._registerPlatformAccessory(); } @@ -28,20 +41,43 @@ class SimpleBlindsAccessory extends BaseAccessory { const {Service, Characteristic} = this.hap; const service = this.accessory.getService(Service.WindowCovering); this._checkServiceName(service, this.device.context.name); - this.dpAction = this._getCustomDP(this.device.context.dpAction) || '1'; - - let _cmdOpen = '1'; + + if (this._isType1()) { + let _cmdOpen = '1'; + } + else if (this._isBelleLife()) { + let _cmdOpen = 'on'; + } + else { + let _cmdOpen = '1'; + } if (this.device.context.cmdOpen) { _cmdOpen = ('' + this.device.context.cmdOpen).trim(); } - let _cmdClose = '2'; + if (this._isType1()) { + let _cmdOpen = '2'; + } + else if (this._isType2()) { + let _cmdOpen = 'off'; + } + else { + let _cmdOpen = '2'; + } if (this.device.context.cmdClose) { _cmdClose = ('' + this.device.context.cmdClose).trim(); } - this.cmdStop = '3'; + if (this._isType1()) { + let _cmdOpen = '3'; + } + else if (this._isType2()) { + let _cmdOpen = 'stop'; + } + else { + let _cmdOpen = '3'; + } if (this.device.context.cmdStop) { this.cmdStop = ('' + this.device.context.cmdStop).trim(); }