Loadpoint UI: finer energy select (#29298)

This commit is contained in:
Michael Geers 2026-04-21 10:31:37 +02:00 • committed by GitHub
parent 2fb900c8ea
commit 033d055d66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@ export function optionStep(maxEnergy: number) {
if (maxEnergy < 10) return 0.5;
if (maxEnergy < 25) return 1;
if (maxEnergy < 50) return 2;
if (maxEnergy < 75) return 2.5;
return 5;
}
@ -21,7 +22,7 @@ export function fmtEnergy(
return zeroText;
}
const inKWh = step >= 0.1;
const digits = inKWh && step < 1 ? 1 : 0;
const digits = inKWh && !Number.isInteger(step) ? 1 : 0;
return fmtWh(energy * 1e3, inKWh ? POWER_UNIT.KW : POWER_UNIT.W, true, digits);
}