Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select number of phases setting #101

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 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 Expand Up @@ -1673,6 +1686,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": "watty"
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
}
]
}
15 changes: 15 additions & 0 deletions drivers/watty/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class WattyDevice 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 WattyDevice 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(
'watty_power_changed',
Expand Down Expand Up @@ -106,6 +108,19 @@ class WattyDevice 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
15 changes: 14 additions & 1 deletion drivers/watty/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,20 @@
}
]
}
]
]
},
{
"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
}
]
}