From 43024db09765d768068b5e17d5732baa7be9c4ce Mon Sep 17 00:00:00 2001 From: Brett-S-OWB Date: Fri, 16 Oct 2026 16:50:46 +0200 Subject: [PATCH 1/2] counter own power values in info dialog --- .../energyFlowChart/EnergyFlowChart.vue | 8 ++- .../HomeConsumptionDetailsDialog.vue | 5 +- .../koala/source/src/stores/mqtt-store.ts | 71 ++++++++++++++++++- 3 files changed, 76 insertions(+), 8 deletions(-) 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..10e5620661 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 @@ -144,8 +144,10 @@ const notInHomeVariants = { iconColor: 'var(--q-secondary-counter-stroke)', }, }; +// follows the counters listed in the details: if all of them are hidden, the +// node only shows consumers const notInHomeVariant = computed(() => { - if (!countersNotInHome.value) { + if (mqttStore.shownCounterIds.notInHome.length === 0) { return notInHomeVariants.consumer; } return mqttStore.notInHomeConsumption.consumerIds.length > 0 @@ -171,12 +173,12 @@ const openDetails = (event: MouseEvent, component: FlowComponent) => { const homeHasDetails = computed( () => mqttStore.inHomeConsumption.consumerIds.length > 0 || - mqttStore.inHomeConsumption.counterIds.length > 0, + mqttStore.shownCounterIds.inHome.length > 0, ); const notInHomeHasDetails = computed( () => mqttStore.notInHomeConsumption.consumerIds.length > 0 || - mqttStore.notInHomeConsumption.counterIds.length > 0, + mqttStore.shownCounterIds.notInHome.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..833f60e57c 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,10 +77,11 @@ const visible = computed({ }); const items = computed((): DetailsItem[] => { - const { consumerIds, counterIds } = + const { consumerIds } = props.scope === 'inHome' ? mqttStore.inHomeConsumption : mqttStore.notInHomeConsumption; + const counterIds = mqttStore.shownCounterIds[props.scope]; const unmeasured = props.scope === 'inHome' && mqttStore.unmeasuredHomeConsumptionPower('value') !== undefined @@ -109,7 +110,7 @@ const items = computed((): DetailsItem[] => { color: mqttStore.secondaryCounterColor(id) || 'var(--q-secondary-counter-stroke)', - power: mqttStore.counterPower('textValue', id) as string, + power: mqttStore.counterLocalPower('textValue', id) as string, })), ...unmeasured, ]; 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 b245f09246..05c6c0c4d3 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 @@ -4267,6 +4267,32 @@ export const useMqttStore = defineStore('mqtt', () => { }; }); + /** + * Get the counter's own share of power: its power minus the power of the + * components directly below it. identified by counterId + * @param returnType type of return value, 'textValue', 'value', 'scaledValue', 'scaledUnit' or 'object' + * @param counterId counter ID + * @returns string | number | ValueObject | undefined + */ + const counterLocalPower = computed(() => { + return (returnType: string = 'textValue', counterId?: number) => { + const id = counterId; + let localPower = undefined; + if (id !== undefined) { + localPower = getValue.value(`openWB/counter/${id}/get/local_power`) as + number | undefined; + } + const valueObject = getValueObject.value(localPower); + if (returnType in valueObject) { + return valueObject[returnType as keyof ValueObject]; + } + if (returnType == 'object') { + return valueObject; + } + console.error('returnType not found!', returnType, localPower); + }; + }); + /** * Get daily counter energy imported identified by root grid counter in component hierarchy or counterId * @param returnType type of return value, 'textValue', 'value', 'scaledValue', 'scaledUnit' or 'object' @@ -4424,6 +4450,7 @@ export const useMqttStore = defineStore('mqtt', () => { const ids = () => ({ consumerIds: [] as number[], counterIds: [] as number[], + counterIdsWithChildren: [] as number[], }); const result = { inHome: ids(), notInHome: ids() }; function walk( @@ -4442,10 +4469,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.counterIdsWithChildren.push(node.id); + } } walk(node.children, mode, false); } else if (node.type === 'consumer') { @@ -4490,6 +4526,33 @@ export const useMqttStore = defineStore('mqtt', () => { () => homeConsumptionAssignment.value.notInHome, ); + // own share in W below which a counter with components below it is hidden (threshold for showing in the home consumption details) + const COUNTER_OWN_SHARE_THRESHOLD = 50; + + /** + * Get the counters to list in the home consumption details. A counter with + * components below it is left out if its own share is negligible, as it + * then only measures those components. + * @returns object with the keys inHome and notInHome, each holding counter ids + */ + const shownCounterIds = computed(() => { + const shown = (bucket: { + counterIds: number[]; + counterIdsWithChildren: number[]; + }) => { + // a counter that only measures the components below it is hidden + const hidden = (id: number) => + bucket.counterIdsWithChildren.includes(id) && + Math.abs(Number(counterLocalPower.value('value', id) ?? 0)) < + COUNTER_OWN_SHARE_THRESHOLD; + return bucket.counterIds.filter((id) => !hidden(id)); + }; + return { + inHome: shown(inHomeConsumption.value), + notInHome: shown(notInHomeConsumption.value), + }; + }); + /** * Get the summed power of all consumers and counters that are not counted * in the home consumption. @@ -4901,11 +4964,13 @@ export const useMqttStore = defineStore('mqtt', () => { counterPower, counterDailyImported, counterDailyExported, + counterLocalPower, // Home data homePower, homeDailyYield, inHomeConsumption, notInHomeConsumption, + shownCounterIds, notInHomeConsumptionPower, unmeasuredHomeConsumptionPower, // PV data From 08dfa18e70c9d64aa54f933ccf7a3d995425ee54 Mon Sep 17 00:00:00 2001 From: Brett-S-OWB Date: Fri, 16 Oct 2026 16:55:00 +0200 Subject: [PATCH 2/2] formatting --- .../modules/web_themes/koala/source/src/stores/mqtt-store.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 05c6c0c4d3..17ba8a3dbb 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 @@ -4526,7 +4526,8 @@ export const useMqttStore = defineStore('mqtt', () => { () => homeConsumptionAssignment.value.notInHome, ); - // own share in W below which a counter with components below it is hidden (threshold for showing in the home consumption details) + // own share in W below which a counter with components below it is hidden + // (threshold for showing in the home consumption details) const COUNTER_OWN_SHARE_THRESHOLD = 50; /** @@ -4962,9 +4963,9 @@ export const useMqttStore = defineStore('mqtt', () => { componentName, gridComponentColor, counterPower, + counterLocalPower, counterDailyImported, counterDailyExported, - counterLocalPower, // Home data homePower, homeDailyYield,