diff --git a/packages/modules/web_themes/koala/source/src/components/charts/energyFlowChart/EnergyFlowChart.vue b/packages/modules/web_themes/koala/source/src/components/charts/energyFlowChart/EnergyFlowChart.vue index 2017b1dfc8..50dc0a8689 100644 --- a/packages/modules/web_themes/koala/source/src/components/charts/energyFlowChart/EnergyFlowChart.vue +++ b/packages/modules/web_themes/koala/source/src/components/charts/energyFlowChart/EnergyFlowChart.vue @@ -145,12 +145,17 @@ const notInHomeVariants = { }, }; const notInHomeVariant = computed(() => { - if (!countersNotInHome.value) { - return notInHomeVariants.consumer; + const { consumerIds, counterIdsWithoutChildren } = + mqttStore.notInHomeConsumption; + if (consumerIds.length > 0) { + // counters with children are not listed in the details + return counterIdsWithoutChildren.length > 0 + ? notInHomeVariants.mixed + : notInHomeVariants.consumer; } - return mqttStore.notInHomeConsumption.consumerIds.length > 0 - ? notInHomeVariants.mixed - : notInHomeVariants.counter; + return countersNotInHome.value + ? notInHomeVariants.counter + : notInHomeVariants.consumer; }); const detailsVisible = ref(false); const detailsScope = ref<'inHome' | 'notInHome'>('inHome'); @@ -171,12 +176,12 @@ const openDetails = (event: MouseEvent, component: FlowComponent) => { const homeHasDetails = computed( () => mqttStore.inHomeConsumption.consumerIds.length > 0 || - mqttStore.inHomeConsumption.counterIds.length > 0, + mqttStore.inHomeConsumption.counterIdsWithoutChildren.length > 0, ); const notInHomeHasDetails = computed( () => mqttStore.notInHomeConsumption.consumerIds.length > 0 || - mqttStore.notInHomeConsumption.counterIds.length > 0, + mqttStore.notInHomeConsumption.counterIdsWithoutChildren.length > 0, ); const showConsumerPower = computed( () => diff --git a/packages/modules/web_themes/koala/source/src/components/charts/energyFlowChart/HomeConsumptionDetailsDialog.vue b/packages/modules/web_themes/koala/source/src/components/charts/energyFlowChart/HomeConsumptionDetailsDialog.vue index cabef6a752..bb89c65ec2 100644 --- a/packages/modules/web_themes/koala/source/src/components/charts/energyFlowChart/HomeConsumptionDetailsDialog.vue +++ b/packages/modules/web_themes/koala/source/src/components/charts/energyFlowChart/HomeConsumptionDetailsDialog.vue @@ -77,7 +77,7 @@ const visible = computed({ }); const items = computed((): DetailsItem[] => { - const { consumerIds, counterIds } = + const { consumerIds, counterIdsWithoutChildren } = props.scope === 'inHome' ? mqttStore.inHomeConsumption : mqttStore.notInHomeConsumption; @@ -102,7 +102,7 @@ const items = computed((): DetailsItem[] => { color: mqttStore.consumerColor(id) || 'var(--q-consumer)', power: mqttStore.consumerPower(id, 'textValue') as string, })), - ...counterIds.map((id) => ({ + ...counterIdsWithoutChildren.map((id) => ({ key: `counter-${id}`, name: mqttStore.componentName(id) || `Zähler ${id}`, icon: CounterIcon, diff --git a/packages/modules/web_themes/koala/source/src/stores/mqtt-store.ts b/packages/modules/web_themes/koala/source/src/stores/mqtt-store.ts index 999dc0c400..cc6f38f06d 100644 --- a/packages/modules/web_themes/koala/source/src/stores/mqtt-store.ts +++ b/packages/modules/web_themes/koala/source/src/stores/mqtt-store.ts @@ -4389,7 +4389,8 @@ export const useMqttStore = defineStore('mqtt', () => { * Sort the consumers and sub-counters by whether they are counted in the * home consumption. The root counter is only listed if it is excluded. * @returns object with the keys inHome and notInHome, each holding the ids - * of the consumers and counters + * of the consumers and counters. counterIdsWithoutChildren holds the + * counters that have no components below them. */ const homeConsumptionAssignment = computed(() => { const AUTO = 'auto_home_consumption'; @@ -4397,6 +4398,7 @@ export const useMqttStore = defineStore('mqtt', () => { const ids = () => ({ consumerIds: [] as number[], counterIds: [] as number[], + counterIdsWithoutChildren: [] as number[], }); const result = { inHome: ids(), notInHome: ids() }; function walk( @@ -4415,10 +4417,19 @@ export const useMqttStore = defineStore('mqtt', () => { AUTO, ) as string | undefined; const mode = own && own !== AUTO ? own : parentMode; + let bucket; if (mode === NOT_HOME) { - result.notInHome.counterIds.push(node.id); - } else if (!isRoot) { - result.inHome.counterIds.push(node.id); + bucket = result.notInHome; + } else if (isRoot) { + bucket = undefined; + } else { + bucket = result.inHome; + } + if (bucket) { + bucket.counterIds.push(node.id); + if (!node.children?.length) { + bucket.counterIdsWithoutChildren.push(node.id); + } } walk(node.children, mode, false); } else if (node.type === 'consumer') {