Skip to content

Commit

Permalink
Combined SimpleBlinds and SimpleBlinds2
Browse files Browse the repository at this point in the history
- Manufacturer types possible (case-insensitive): "type1" (simpleBlinds) & "type2" (simpleBlinds2)
-- By default the device defaults to type1 if it's not specified.
  • Loading branch information
ElphaX authored Apr 25, 2021
1 parent c118874 commit f85c4e3
Showing 1 changed file with 44 additions and 8 deletions.
52 changes: 44 additions & 8 deletions lib/SimpleBlindsAccessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,69 @@ 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();
}

_registerCharacteristics(dps) {
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();
}
Expand Down

1 comment on commit f85c4e3

@xrust83
Copy link

@xrust83 xrust83 commented on f85c4e3 May 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';
    }

Please sign in to comment.