fix: follow topology in utility summaries and breakdowns

This commit is contained in:
jhartworks committed 2026-11-19 15:44:24 +01:00
1 parent 16eddacebf
commit 96e5311baf
11 files changed
+571 -383

No files matched your search

+1 -2
View File
@@ -190,8 +190,7 @@ export function floorUtilityReadings(hass: HomeAssistant, floor: Floor, rooms: r
}
/** Sum the effective floor meters; shared native sources count only once for the building. */
export function buildingUtilityReadings(hass: HomeAssistant, floors: readonly Floor[]): UtilityReading[] {
const rooms = floors.flatMap((f) => f.rooms);
export function buildingUtilityReadings(hass: HomeAssistant, floors: readonly Floor[], rooms: readonly Room[] = floors.flatMap((f) => f.rooms)): UtilityReading[] {
const sources = floors.flatMap((f) => floorUtilityReadings(hass, f, rooms).flatMap((r) => r.sources.map((id) => ({ kind: r.kind, metric: r.metric, period: r.period, id }))));
return readings(hass, sources);
}