Skip to content

Commit

Permalink
Check for type==1 before we change demand control
Browse files Browse the repository at this point in the history
  • Loading branch information
Matze2 committed Oct 4, 2024
1 parent 0404c83 commit 5314e0f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/models/DemandControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ export class DemandControl {
}

public overwrite(obj: Partial<DemandControl>) {
if (obj.type !== undefined) this.type = obj.type;
if (obj.enabled !== undefined) this.enabled = obj.enabled;
if (obj.mode !== undefined) this.mode = obj.mode;
if (obj.maxPower !== undefined) this.maxPower = obj.maxPower;
}

// According to https://www.akkudoktor.net/forum/postid/190147/
public getRequestDict(): RequestDict {
const dict: RequestDict = {};
if (this.enabled == undefined) throw new Error('Required Field enabled does not exist');

const dict: RequestDict = {};
dict['lpw'] = ''; // Appeared in all examples but doesn't seem to be necessary
dict['en_demand'] = this.enabled ? 1 : 0;
if (!this.enabled) {
Expand All @@ -39,7 +41,8 @@ export class DemandControl {
// Enable and set demand control
// http://<DAIKIN-IP>/aircon/set_demand_control?lpw=&en_demand=1&mode=0&type=1&max_pow=[40-100]

// For automatic or manual demand control we need mode, type and maxPower
// For automatic or manual demand control we need type==1, mode and maxPower
if (this.type !== 1) throw new Error('Required Field type != 1. Assume no support for demand control');
if (this.mode === undefined) throw new Error('Required Field mode do not exists');
if (this.maxPower === undefined) throw new Error('Required Field maxPower do not exists');

Expand Down

0 comments on commit 5314e0f

Please sign in to comment.