Skip to content

Commit

Permalink
Add setting for showing 1/3 phases - Pulse
Browse files Browse the repository at this point in the history
  • Loading branch information
philipostli committed Oct 30, 2024
1 parent 90db5e5 commit 57ffb8c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,19 @@
]
}
]
},
{
"id": "phase_mode",
"type": "checkbox",
"label": {
"en": "Show 3 phases",
"no": "Vis 3 faser"
},
"hint": {
"en": "Enables 3 phase mode\nDefault: true\n\nWill show current on separate phases 1, 2 and 3/nTurn off to show only one phase",
"no": "Aktiverer 3-fase modus\nDefault: true\n\nViser strøm på fase 1, 2 og 3 separat/nSlå av for å vise kun én fase."
},
"value": true
}
],
"id": "pulse"
Expand Down
15 changes: 15 additions & 0 deletions drivers/pulse/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class PulseDevice extends Device {
#currency?: string;
#cachedNordPoolPrice: { hour: number; price: number } | null = null;
#area?: string;
#phaseMode!: boolean;
#prevPowerProduction?: number;
#prevUpdate?: moment.Moment;
#prevPower?: number;
Expand All @@ -40,6 +41,7 @@ class PulseDevice extends Device {
this.#api = new TibberApi(this.log, this.homey.settings, id, token);
this.#deviceId = id;
this.#throttle = this.getSetting('pulse_throttle') || 30;
this.#phaseMode = this.getSetting('phase_mode') || true;

this.#powerChangedTrigger =
this.homey.flow.getDeviceTriggerCard('power_changed');
Expand Down Expand Up @@ -107,6 +109,19 @@ class PulseDevice extends Device {
this.#area = newSettings.pulse_area;
this.#cachedNordPoolPrice = null;
}
if (changedKeys.includes('phase_mode')) {
this.log('Updated 3-phase mode value: ', Boolean(newSettings.phase_mode));
this.#phaseMode = Boolean(newSettings.phase_mode);
if (this.#phaseMode) {
this.log('3-phase mode enabled');
await this.addCapability('measure_current.L2');
await this.addCapability('measure_current.L3');
} else {
this.log('3-phase mode disabled');
await this.removeCapability('measure_current.L2');
await this.removeCapability('measure_current.L3');
}
}
}

async #subscribeToLive() {
Expand Down
13 changes: 13 additions & 0 deletions drivers/pulse/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,19 @@
]
}
]
},
{
"id": "phase_mode",
"type": "checkbox",
"label": {
"en": "Show 3 phases",
"no": "Vis 3 faser"
},
"hint": {
"en": "Enables 3 phase mode\nDefault: true\n\nWill show current on separate phases 1, 2 and 3/nTurn off to show only one phase",
"no": "Aktiverer 3-fase modus\nDefault: true\n\nViser strøm på fase 1, 2 og 3 separat/nSlå av for å vise kun én fase."
},
"value": true
}
]
}

0 comments on commit 57ffb8c

Please sign in to comment.