Config UI: allow setting priority=0 (#20795)

This commit is contained in:
Michael Geers 2025-04-23 13:05:36 +02:00 • committed by GitHub
parent 2a403daa90
commit 956480f9cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 3 deletions

View file

@ -308,7 +308,7 @@ func (lp *Loadpoint) restoreSettings() {
if v, err := lp.settings.String(keys.Mode); err == nil && v != "" && lp.DefaultMode == api.ModeEmpty {
lp.setMode(api.ChargeMode(v))
}
if v, err := lp.settings.Int(keys.Priority); err == nil && v > 0 {
if v, err := lp.settings.Int(keys.Priority); err == nil {
lp.setPriority(int(v))
}
if v, err := lp.settings.Int(keys.PhasesConfigured); err == nil && (v > 0 || lp.hasPhaseSwitching()) {

View file

@ -218,8 +218,7 @@ func (lp *Loadpoint) SetPriority(prio int) {
defer lp.Unlock()
lp.log.DEBUG.Println("set priority:", prio)
if lp.Priority != prio {
if lp.priority != prio {
lp.setPriority(prio)
}
}

View file

@ -196,6 +196,20 @@ test.describe("loadpoint", async () => {
await page.getByTestId("loadpoint").nth(1).getByRole("button", { name: "edit" }).click();
await expectModalVisible(lpModal);
await expect(lpModal.getByLabel("Priority")).toHaveValue("1");
// change back to 0
await lpModal.getByLabel("Priority").selectOption("0 (default)");
await lpModal.getByRole("button", { name: "Save" }).click();
await expectModalHidden(lpModal);
// restart
await restart(CONFIG_ONE_LP);
await page.reload();
// check priorities
await page.getByTestId("loadpoint").nth(1).getByRole("button", { name: "edit" }).click();
await expectModalVisible(lpModal);
await expect(lpModal.getByLabel("Priority")).toHaveValue("0 (default)");
});
test("vehicle", async ({ page }) => {