Skip to content

Commit

Permalink
Handle changes of maxPower variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Matze2 committed Sep 29, 2024
1 parent 5e7371f commit c3a252b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion daikin.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ function startAdapter(options) {
if (!state || state.ack !== false || state.val === null) return;
adapter.log.debug(`stateChange ${id} ${JSON.stringify(state)}`);
const realNamespace = `${adapter.namespace}.control.`;
const stateId = id.substring(realNamespace.length);
const realNamespace2 = `${adapter.namespace}.demandControl.`;

// Hacky: two namespaces and assume uniqueness of the variable independent of the namespace
// To be checked with Apollon77
const stateId = id.startsWith(realNamespace) ? id.substring(realNamespace.length) : id.substring(realNamespace2.length);
changedStates[stateId] = state.val;
if (changeTimeout) {
adapter.log.debug('Clear change timeout');
Expand Down Expand Up @@ -381,6 +385,15 @@ function changeStates() {
}
}
}
if (changed.maxPower !== undefined) {
daikinDevice.setACDemandControl({maxPower: changed.maxPower}, (err, response) => {
adapter.log.debug(`changed maxPower to ${changed.maxPower}, response ${JSON.stringify(response)}`);
if (err) adapter.log.error(`change values failed: ${err.message}`);
delete changed.maxPower;
setSpecialMode(changed);
});
return;
}
setSpecialMode(changed);
}

Expand Down

0 comments on commit c3a252b

Please sign in to comment.