History UI: fix consumption with no ext/aux meters (#30697)
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Demo (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
Michael Geers 2026-06-10 14:03:20 +02:00 • committed by GitHub
parent 6cf3ea92d2
commit 4149d67faf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View file

@ -282,7 +282,7 @@ export default defineComponent({
const activeMeters = meters
.map((s, i) => ({ ...s, paletteIndex: i }))
.filter(hasEnergy);
if (!home || activeMeters.length === 0) return activeMeters;
if (!home) return activeMeters;
const meterTotals = new Map<string, number>();
// Net per slot is computed from all meters (incl. inactive ones), so
// dropping inactive entries from the display doesn't shift the
@ -394,7 +394,8 @@ export default defineComponent({
hasEntityLegend(group: string): boolean {
const list = this.displaySeries(group);
if (!list.length) return false;
if (group === "loadpoint" || group === "meter") return true;
// Without explicit consumers an "Others"-only legend is meaningless.
if (group === "loadpoint" || group === "meter") return list.some((s) => !s.virtual);
if (group === "pv" || group === "battery") return list.length > 1;
return false;
},

View file

@ -190,6 +190,17 @@ test.describe("consumption breakdown", () => {
await expect(consumption.getByRole("button", { name: "Office 300 Wh" })).toBeVisible();
});
// 2026-03-24: home = 0.4 kWh, no meter entities with data.
test("home without meters shows chart without legend", async ({ page }) => {
await gotoDay(page, 2026, 3, 24);
const consumption = section(page, "meter");
await expect(consumption).toBeVisible();
await expect(consumption.getByRole("heading")).toContainText("0.4 kWh");
// No explicit consumers, no entity legend.
await expect(consumption.getByRole("button")).toHaveCount(0);
});
test("entity focus rescales axis and resets on unfocus", async ({ page }) => {
await gotoDay(page, 2026, 4, 7);
const consumption = section(page, "meter");