Skip to content

Commit

Permalink
use maximum valve state of all linked TRVs
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Jan 12, 2019
1 parent 78ab573 commit fba2f7c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
40 changes: 21 additions & 19 deletions homematic-devices/hm-tc-it-wm-w-eu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,17 @@ module.exports = class HmTcItWmWEu extends Accessory {
let valveState = 0;
let valueSetpoint;

let datapointValveState;
let valveStateDevice;

let controlMode;
let target;

const levels = {};
let level = 0;

const that = this;

const links = ccu.getLinks(config.iface, config.description.ADDRESS + ':2') || [];
node.debug(config.name + ' linked to ' + JSON.stringify(links));

if (links[0]) {
valveStateDevice = links[0].split(':')[0];
datapointValveState = config.iface + '.' + valveStateDevice + ':4.VALVE_STATE';
}

function targetState() {
// 0=off, 1=heat, 3=auto
switch (controlMode) {
Expand Down Expand Up @@ -121,17 +116,24 @@ module.exports = class HmTcItWmWEu extends Accessory {
that.acc.getService(subtypeThermostat).updateCharacteristic(hap.Characteristic.TargetHeatingCoolingState, target);
}

if (valveStateDevice) {
this.subscriptions.push(ccu.subscribe({
cache: true,
change: true,
datapointName: datapointValveState
}, msg => {
valveState = msg.value;
node.debug('update ' + config.name + ' valveState ' + msg.value);
updateHeatingCoolingState();
}));
}
links.forEach(link => {
const valveStateDevice = link.split(':')[0];
const datapointLevel = config.iface + '.' + valveStateDevice + ':4.VALVE_STATE';
this.subscribe(datapointLevel, value => {
levels[datapointLevel] = value;
let max = 0;
Object.keys(levels).forEach(dp => {
if (levels[dp] > max) {
max = levels[dp];
}
});
if (level !== max) {
level = max;
node.debug('update ' + config.name + ' level ' + level);
updateHeatingCoolingState();
}
});
});

this.subscriptions.push(ccu.subscribe({
cache: true,
Expand Down
29 changes: 18 additions & 11 deletions homematic-devices/hmip-wth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ module.exports = class HmipWth extends Accessory {
const {bridgeConfig, ccu} = node;
const {hap} = bridgeConfig;

const levels = {};
let level = 0;
let valueSetpoint;
let setpointMode;
let target;
let valveStateDevice;
let datapointLevel;

function targetState() {
// 0=off, 1=heat, 3=auto
Expand All @@ -34,11 +33,6 @@ module.exports = class HmipWth extends Accessory {
const links = ccu.getLinks(config.iface, config.description.ADDRESS + ':3') || [];
node.debug(config.name + ' linked to ' + JSON.stringify(links));

if (links[0]) {
valveStateDevice = links[0].split(':')[0];
datapointLevel = config.iface + '.' + valveStateDevice + ':1.LEVEL';
}

const serviceThermostat = this.addService('Thermostat', config.name);
const subtypeThermostat = serviceThermostat.subtype;

Expand Down Expand Up @@ -112,10 +106,23 @@ module.exports = class HmipWth extends Accessory {
serviceThermostat.update('TargetHeatingCoolingState', targetState());
}

this.subscribe(datapointLevel, value => {
level = value;
node.debug('update ' + config.name + ' level ' + level);
updateHeatingCoolingState();
links.forEach(link => {
const valveStateDevice = link.split(':')[0];
const datapointLevel = config.iface + '.' + valveStateDevice + ':1.LEVEL';
this.subscribe(datapointLevel, value => {
levels[datapointLevel] = value;
let max = 0;
Object.keys(levels).forEach(dp => {
if (levels[dp] > max) {
max = levels[dp];
}
});
if (level !== max) {
level = max;
node.debug('update ' + config.name + ' level ' + level);
updateHeatingCoolingState();
}
});
});

this.subscribe(config.deviceAddress + ':1.SET_POINT_MODE', value => {
Expand Down

0 comments on commit fba2f7c

Please sign in to comment.