Battery (experimental): restore priority/buffer soc constraint (#31900)
This commit is contained in:
parent
e239af5d25
commit
362620ba07
2 changed files with 35 additions and 5 deletions
|
|
@ -102,8 +102,7 @@ import InlineSocSelect from "./InlineSocSelect.vue";
|
||||||
|
|
||||||
// Battery usage controls for the experimental page. The logic is intentionally duplicated
|
// Battery usage controls for the experimental page. The logic is intentionally duplicated
|
||||||
// from the classic BatteryUsageSettings.vue (slated for removal) so the two can diverge
|
// from the classic BatteryUsageSettings.vue (slated for removal) so the two can diverge
|
||||||
// during the transition. Difference here: priority and buffer SoC are independent, there is
|
// during the transition.
|
||||||
// no priority < buffer constraint.
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "BatteryConfigCard",
|
name: "BatteryConfigCard",
|
||||||
components: { Card, InlineSocSelect },
|
components: { Card, InlineSocSelect },
|
||||||
|
|
@ -135,14 +134,21 @@ export default defineComponent({
|
||||||
priorityOptions() {
|
priorityOptions() {
|
||||||
const options = [];
|
const options = [];
|
||||||
for (let i = 100; i >= 0; i -= 5) {
|
for (let i = 100; i >= 0; i -= 5) {
|
||||||
options.push({ value: i, name: this.fmtSoc(i) });
|
const disabled =
|
||||||
|
i > this.selectedBufferSoc &&
|
||||||
|
!(this.selectedBufferSoc == this.selectedPrioritySoc);
|
||||||
|
options.push({ value: i, name: this.fmtSoc(i), disabled });
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
},
|
},
|
||||||
bufferOptions() {
|
bufferOptions() {
|
||||||
const options = [];
|
const options = [];
|
||||||
for (let i = 100; i >= 5; i -= 5) {
|
for (let i = 100; i >= 5; i -= 5) {
|
||||||
options.push({ value: i, name: this.fmtSoc(i) });
|
options.push({
|
||||||
|
value: i,
|
||||||
|
name: this.fmtSoc(i),
|
||||||
|
disabled: i < this.selectedPrioritySoc,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
},
|
},
|
||||||
|
|
@ -180,7 +186,15 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changePrioritySoc($event: Event) {
|
changePrioritySoc($event: Event) {
|
||||||
this.savePrioritySoc(parseInt(($event.target as HTMLInputElement).value, 10));
|
const soc = parseInt(($event.target as HTMLInputElement).value, 10);
|
||||||
|
if (soc > (this.bufferSoc || 100)) {
|
||||||
|
this.saveBufferSoc(soc);
|
||||||
|
if (soc > this.bufferStartSoc && this.bufferStartSoc > 0) {
|
||||||
|
this.setBufferStartSoc(soc);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.savePrioritySoc(soc);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
changeBufferStart($event: Event) {
|
changeBufferStart($event: Event) {
|
||||||
this.setBufferStartSoc(parseInt(($event.target as HTMLInputElement).value, 10));
|
this.setBufferStartSoc(parseInt(($event.target as HTMLInputElement).value, 10));
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,22 @@ test.describe("experimental battery page", async () => {
|
||||||
await prioritySoc.selectOption("30");
|
await prioritySoc.selectOption("30");
|
||||||
await expect(prioritySoc).toHaveValue("30");
|
await expect(prioritySoc).toHaveValue("30");
|
||||||
|
|
||||||
|
// values crossing the other threshold are not selectable (prioritySoc 30, bufferSoc 80)
|
||||||
|
await expect(prioritySoc.getByRole("option", { name: "85%", exact: true })).toHaveAttribute(
|
||||||
|
"disabled",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
await expect(bufferSoc.getByRole("option", { name: "25%", exact: true })).toHaveAttribute(
|
||||||
|
"disabled",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
|
// equal values unlock higher priorities; selecting one raises the buffer instead
|
||||||
|
await prioritySoc.selectOption("80");
|
||||||
|
await prioritySoc.selectOption("85");
|
||||||
|
await expect(bufferSoc).toHaveValue("85");
|
||||||
|
await expect(prioritySoc).toHaveValue("80");
|
||||||
|
|
||||||
// discharge control is offered for the controllable battery and toggles on
|
// discharge control is offered for the controllable battery and toggles on
|
||||||
const discharge = page.getByRole("switch", { name: /Prevent home battery/ });
|
const discharge = page.getByRole("switch", { name: /Prevent home battery/ });
|
||||||
await expect(discharge).not.toBeChecked();
|
await expect(discharge).not.toBeChecked();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue