Skip to content

Commit

Permalink
hmipw-drs4 virtual channels (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Aug 25, 2019
1 parent 0afe91b commit 7ad7471
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
48 changes: 31 additions & 17 deletions homematic-devices/hmipw-drs4.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,25 @@ class AccMultiService extends Accessory {
const channels = config.description.CHILDREN;

for (let i = 2; i < (channels.length - 1); i += 4) {
const ch = channels[i];
if (!this.option(i)) {
continue;
}
for (let vi = 0; vi < 3; vi ++) {
const channelNumber = i + vi;
const ch = channels[channelNumber];
if (vi === 0 && !this.option(channelNumber)) {
continue;
} else if (vi !== 0 && !this.option(channelNumber, 'enabled')) {
continue;
}


const name = ccu.channelNames[ch];
const dp = config.iface + '.' + ch + '.STATE';
const type = this.option(channelNumber, 'type') || 'Switch';

const name = ccu.channelNames[ch];
const dp = config.iface + '.' + ch + '.STATE';
const type = this.option(i, 'type') || 'Switch';
node.debug(channelNumber + ' ' + type + ' ' + this.option(channelNumber, 'type'));

node.debug(i + ' ' + type + ' ' + this.option(i, 'type'));
addService.call(this, type, dp, name);
}

addService.call(this, type, dp, name);
}
}
}
Expand Down Expand Up @@ -98,17 +105,24 @@ module.exports = class HmipwDrs {
} else {
const channels = config.description.CHILDREN;
for (let i = 2; i < (channels.length - 1); i += 4) {
const ch = channels[i];
if (!this.option(ch)) {
continue;
}
for (let vi = 0; vi < 3; vi ++) {
const channelNumber = i + vi;
const ch = channels[channelNumber];
if (vi === 0 && !this.option(channelNumber)) {
continue;
} else if (vi !== 0 && !this.option(channelNumber, 'enabled')) {
continue;
}

const name = ccu.channelNames[ch];
const name = ccu.channelNames[ch];

const chConfig = Object.assign({}, config, {accChannel: ch, name});
chConfig.description = Object.assign({}, config.description, {ADDRESS: ch});

new AccSingleService(chConfig, node);
}

const chConfig = Object.assign({}, config, {accChannel: ch, name});
chConfig.description = Object.assign({}, config.description, {ADDRESS: ch});

new AccSingleService(chConfig, node);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion nodes/redmatic-homekit-homematic-devices.html
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
case 'hmipw-drs4':
case 'hmipw-drs8':
addOption(addr, 'SingleAccessory');
addChannels(addr, 2, channelCount - 2, 4, {type: switchTypes});
addVirtualChannels(addr, 2, channelCount - 2, 4, {type: switchTypes});
break;

case 'hmipw-dri16':
Expand Down

0 comments on commit 7ad7471

Please sign in to comment.