Skip to content

Commit

Permalink
add option method (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Jan 3, 2020
1 parent 71ff4df commit 85c84ba
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
18 changes: 18 additions & 0 deletions homematic-devices/hmipw-dri16.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,26 @@ class AccMultiService extends Accessory {
}

module.exports = class GenericContactSensor {
option(id, option) {
let addr = this.config.description.ADDRESS;
if (!addr.includes(':')) {
addr = addr + ':' + id;
}

let res;

if (option) {
res = this.config.options[addr] && this.config.options[addr][option];
} else {
res = !(this.config.options[addr] && this.config.options[addr].disabled);
}

this.node.debug('option ' + addr + ' ' + id + ' ' + option + ' ' + res);
return res;
}
constructor(config, node) {
const {ccu} = node;
this.node = node;
this.ccu = ccu;
this.config = config;
const channels = config.description.CHILDREN;
Expand Down
17 changes: 17 additions & 0 deletions homematic-devices/hmipw-drs4.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ class AccMultiService extends Accessory {
}

module.exports = class HmipwDrs {
option(id, option) {
let addr = this.config.description.ADDRESS;
if (!addr.includes(':')) {
addr = addr + ':' + id;
}

let res;

if (option) {
res = this.config.options[addr] && this.config.options[addr][option];
} else {
res = !(this.config.options[addr] && this.config.options[addr].disabled);
}

this.node.debug('option ' + addr + ' ' + id + ' ' + option + ' ' + res);
return res;
}
constructor(config, node) {
const {ccu} = node;
this.node = node;
Expand Down
17 changes: 17 additions & 0 deletions homematic-devices/hmipw-fio6.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ class AccMultiService extends Accessory {
}

module.exports = class HmipwFio {
option(id, option) {
let addr = this.config.description.ADDRESS;
if (!addr.includes(':')) {
addr = addr + ':' + id;
}

let res;

if (option) {
res = this.config.options[addr] && this.config.options[addr][option];
} else {
res = !(this.config.options[addr] && this.config.options[addr].disabled);
}

this.node.debug('option ' + addr + ' ' + id + ' ' + option + ' ' + res);
return res;
}
constructor(config, node) {
const {ccu} = node;
this.node = node;
Expand Down

0 comments on commit 85c84ba

Please sign in to comment.