MindFreeze / ha-sankey-chart

A Home Assistant lovelace card to display a sankey chart. For example for power consumption
MIT License
378 stars 20 forks source link

Make children flowss precisely fit under parent width #189

Closed Cougar closed 5 months ago

Cougar commented 5 months ago

Is your feature request related to a problem? Please describe. In power monitoring, the sensor reading times are not in sync and because of this, sum of children power is rarely equal to parent power. This is how the difference looks like in graph:

Screenshot 2024-05-02 at 21-16-36 Energy2 – Home Assistant

Describe the solution you'd like I propose a configuration variable for a parent to state that it has all children listed and therefore all lines from parent to children should precisely fit under parent width. In term of math, it should take relative shares of all children and visually distribute it within parent width. It is basically opposite for remaining_child_state and remaining_parent_state where we specially say that there is some children missing and total is not sum of children.

Describe alternatives you've considered Alternative would be an additional sensor that is just a sum of children. It would fix a visual graph but the reading of parent value is never correct when children readings are updated in different moments. It would be correct to always show parent sensor reading instead (if it exists of course).

Additional context I have power monitoring for the whole fuse box: all three incoming phases and all fuses. The visualization starts from total sum of all phases from template. This is not always correct but not a bit problem. This is why it fits perfectly on the visualizations.

Next level is line usage (L1, L2, L3) from dedicated sensors. Every line has multiple fuses connected (7-8 in this case). Flows between level 2 and level 3 should always fit but does not due different devices and read times.

If there are sockets with power monitoring, then these a also visible on last level. Sometimes there are all consumers of one fuse monitored and should also perfectly fit. Like washer and dryer are connected to sockets that are under the same fuse but both are monitored separately as well.

This is how the whole graph looks like

Screenshot 2024-05-02 at 21-40-32 Energy2 – Home Assistant

MindFreeze commented 5 months ago

I know this feature is needed but it should be optional and is not trivial to implement. There is already an issue for this #37, so I will close this one as a duplicate

MindFreeze commented 5 months ago

I wanted to implement this for v3 but it turned out to be way more complex than anticipated

Cougar commented 5 months ago

It is definitely related but it is not about calculations like using latest, min, max or mean. This can be already done with template.

In this case (similarly with other closed cases) all numbers are actually correct "in some point of time" but visualization needs to be fixed.

Still fair enough as long as #37 stays open :)