Skip to content

Commit

Permalink
fix HmIP-FTD/-PDT virtual channels (#193, #208)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Nov 15, 2019
1 parent d236f60 commit 0106fc7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 30 deletions.
2 changes: 1 addition & 1 deletion homematic-devices/hmip-fdt.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = class HmipFdt extends Accessory {

let valueBrightness = 0;

for (let i = 2; i <= 2; i++) {
for (let i = 2; i <= 4; i++) {
if ((i === 2 && this.option(i)) || (i !== 2 && this.option(i, 'enabled'))) {
const channel = config.deviceAddress + ':' + i;
const name = ccu.channelNames[channel];
Expand Down
67 changes: 38 additions & 29 deletions homematic-devices/hmip-pdt.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
const Accessory = require('./lib/accessory');

module.exports = class HmipPdt extends Accessory {
init(config) {
module.exports = class HmipFdt extends Accessory {
init(config, node) {
const {ccu} = node;

let valueBrightness = 0;

this.addService('Lightbulb', config.name)
for (let i = 3; i <= 5; i++) {
if ((i === 3 && this.option(i)) || (i !== 2 && this.option(i, 'enabled'))) {
const channel = config.deviceAddress + ':' + i;
const name = ccu.channelNames[channel];

this.addService('Lightbulb', name)

.get('On', config.deviceAddress + ':3.LEVEL', value => {
valueBrightness = value;
return value > 0;
})
.get('On', channel + '.LEVEL', value => {
valueBrightness = value;
return value > 0;
})

.set('On', (value, callback) => {
if (value) {
setTimeout(() => {
if (valueBrightness === 0) {
value = 1;
.set('On', (value, callback) => {
if (value) {
setTimeout(() => {
if (valueBrightness === 0) {
value = 1;
} else {
value = valueBrightness / 100;
}

this.ccuSetValue(channel + '.LEVEL', value, callback);
}, 100);
} else {
value = valueBrightness / 100;
this.ccuSetValue(channel + '.LEVEL', 0, callback);
}
})

.get('Brightness', channel + '.LEVEL', value => {
valueBrightness = value * 100;
return value * 100;
})

this.ccuSetValue(config.deviceAddress + ':3.LEVEL', value, callback);
}, 100);
} else {
this.ccuSetValue(config.deviceAddress + ':3.LEVEL', 0, callback);
}
})

.get('Brightness', config.deviceAddress + ':3.LEVEL', value => {
valueBrightness = value * 100;
return value * 100;
})

.set('Brightness', config.deviceAddress + ':3.LEVEL', value => {
valueBrightness = value;
return value / 100;
});
.set('Brightness', channel + '.LEVEL', value => {
valueBrightness = value;
return value / 100;
});
}
}
}
};
1 change: 1 addition & 0 deletions nodes/redmatic-homekit-homematic-devices.html
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@
break;

case 'hmip-pdt':
addVirtualChannels(addr, 3, 3);
break;

case 'hmip-ps':
Expand Down

0 comments on commit 0106fc7

Please sign in to comment.