Skip to content

Commit

Permalink
improve HmIP Blind/Roll, fix vertical
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Dec 31, 2019
1 parent 507d6b4 commit 4471cd1
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions homematic-devices/lib/generic-hmip-blind.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ function createService(channel) {
console.log('generic-hmip-blind createService', channel);

let intermediatePosition; // 0-100
let LEVEL; // 0.0-1.0
let LEVEL_2; // 0.0-1.0
let LEVEL = 0; // 0.0-1.0
let LEVEL_2 = 0; // 0.0-1.0

const channelIndex = channel.channel.split(':')[1];

Expand Down Expand Up @@ -50,10 +50,21 @@ function createService(channel) {
const params = {
LEVEL
};

if (channel.tilt) {
params.LEVEL_2 = LEVEL_2;
}

if (channel.tilt || this.config.type === 'BLIND_VIRTUAL_RECEIVER') {
if (LEVEL === 0) {
params.LEVEL_2 = 0;
}

if (LEVEL === 1) {
params.LEVEL_2 = 1;
}
}

this.node.debug('set ' + this.config.name + ' (WindowCovering) TargetPosition ' + value + ' -> ' + this.config.description.ADDRESS + ':' + channelIndex + ' ' + JSON.stringify(params));
this.ccu.methodCall(this.config.iface, 'putParamset', [this.config.description.ADDRESS + ':' + channelIndex, 'VALUES', params])
.then(() => {
Expand All @@ -78,17 +89,23 @@ function createService(channel) {
if (channel.tilt) {
service
.get('CurrentVerticalTiltAngle', this.config.deviceAddress + ':' + channelIndex + '.LEVEL_2', value => {
LEVEL_2 = (value * 180) - 90;
return LEVEL_2;
LEVEL_2 = value;
value = (value * 180) - 90;
this.node.debug('get CurrentVerticalTiltAngle ' + this.config.name + ' LEVEL_2 ' + LEVEL_2 + ' ' + value);
return value;
})

.get('TargetVerticalTiltAngle', this.config.deviceAddress + ':' + channelIndex + '.LEVEL_2', value => {
LEVEL_2 = (value * 180) - 90;
return LEVEL_2;
LEVEL_2 = value;
value = (value * 180) - 90;
this.node.debug('get TargetVerticalTiltAngle ' + this.config.name + ' LEVEL_2 ' + LEVEL_2 + ' ' + value);
return value;
})

.set('TargetVerticalTiltAngle', (value, callback) => {
LEVEL_2 = (value + 90) / 180;
this.node.debug('set TargetVerticalTiltAngle ' + this.config.name + ' LEVEL_2 ' + LEVEL_2 + ' ' + value);

const params = {
LEVEL,
LEVEL_2
Expand Down Expand Up @@ -140,7 +157,7 @@ class GenericHmipBlind {
channels.push({channel, name, tilt});
}
} else if (this.config.options[channel] && this.config.options[channel].enabled) {
channels.push({channel, name, tilt});
channels.push({channel, name, tilt, type: desc.TYPE});
}

if (++pos === 3) {
Expand Down

0 comments on commit 4471cd1

Please sign in to comment.