Skip to content

Commit

Permalink
try to fix #71
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Jan 13, 2019
1 parent 47c53dd commit bdff33e
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions homematic-devices/hm-lc-ja1pbu-fm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ const Accessory = require('./lib/accessory');
module.exports = class HmLcJa1 extends Accessory {
init(config) {
let timeout;
let level;
let levelSlats;
let level = null;
let levelSlats = null;

const that = this;

const service = this.addService('WindowCovering', config.name);

service
.get('CurrentPosition', config.deviceAddress + ':1.LEVEL', value => {
if (typeof level === 'undefined') {
level = value;
}
return value * 100;
})

Expand Down Expand Up @@ -42,9 +39,6 @@ module.exports = class HmLcJa1 extends Accessory {
})

.get('CurrentVerticalTiltAngle', config.deviceAddress + ':1.LEVEL_SLATS', value => {
if (typeof levelSlats === 'undefined') {
levelSlats = value;
}
return (value * 180) - 90;
})

Expand All @@ -61,14 +55,28 @@ module.exports = class HmLcJa1 extends Accessory {
});

function setCombined() {
const b1 = ('0' + ((level || 0) * 200).toString(16)).slice(-2);
const b2 = ('0' + ((levelSlats || 0) * 200).toString(16)).slice(-2);
const value = '0x' + b1 + ',0x' + b2;
that.ccuSetValue(config.deviceAddress + ':1.LEVEL_COMBINED', value, error => {
let dp;
let value;
if (levelSlats !== null && level !== null) {
const b1 = ('0' + ((level || 0) * 200).toString(16)).slice(-2);
const b2 = ('0' + ((levelSlats || 0) * 200).toString(16)).slice(-2);
value = '0x' + b1 + ',0x' + b2;
dp = config.deviceAddress + ':1.LEVEL_COMBINED';

} else if (level !== null) {
value = level;
dp = config.deviceAddress + ':1.LEVEL';
} else if (levelSlats !== null) {
value = levelSlats;
dp = config.deviceAddress + ':1.LEVEL_SLATS';
}
that.ccuSetValue(dp, value, error => {
if (error) {
service.updateCharacteristic('TargetPosition', error);
}
});
level = null;
levelSlats = null;
}
}
};

0 comments on commit bdff33e

Please sign in to comment.