Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remaining of children or parent + type: passthrough = wrong calculations #246

Closed
kzajac83 opened this issue Nov 29, 2024 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@kzajac83
Copy link

Hello

I see discrepancy for parent and children calculation longer time but cannot show ease as now due to many entities in graphs.
The issue is related to calculations of remaining parent.children probably where is used type: passthrough because only this chart i found I issue wrong calculated discrepancy.

My Sankey displaying square meters of water, where one liter is is equal 1/1000 of m3. Left site of picture is main water supply and right site is end water meters. Between is sub water meter for boiling room. I build two Sankey graphs with and without middle section with sub water meter. And unfortunately both graphs always calculate difference values of remaining of children or parent.

For the period (from 0:00 to 1:00) is only two liters (0.002 m3) consumed.

image

image

I will show two examples, correct and wrong.

Correct example

8 liter = 6 liter + 1 liter + 1 liter ==> TRUE

image

layout: horizontal
height: 400
unit_prefix: ""
round: 4
convert_units_to: ""
co2_intensity_entity: sensor.co2_signal_co2_intensity
gas_co2_intensity: 2351.6459999999997
min_box_size: 6
min_box_distance: 7
show_states: true
show_units: true
sections:
  - entities:
      - type: remaining_child_state
        children:
          - sensor.cwu_1_total_volume_m3
          - sensor.cwu_2_total_volume_m3
          - sensor.cwu_3_total_volume_m3
          - sensor.cwu_4_total_volume_m3
          - sensor.cwu_5_total_volume_m3
          - sensor.cwu_7_total_volume_m3
          - sensor.cwu_8_total_volume_m3
          - sensor.cwu_9_total_volume_m3
          - sensor.cwu_10_total_volume_m3
          - sensor.cwu_11_total_volume_m3
          - sensor.cwu_12_total_volume_m3
          - sensor.cwu_12a_total_volume_m3
          - sensor.cwu_adm_total_volume_m3
          - sensor.1_zw
          - sensor.2_zw
          - sensor.3_zw
          - sensor.4_zw
          - sensor.5_zw
          - sensor.6_zw
          - sensor.7_zw
          - sensor.8_zw
          - sensor.9_zw
          - sensor.10_zw
          - sensor.11_zw
          - sensor.12_zw
          - sensor.12a_zw
          - sensor.adm_zw
        entity_id: whatever
        name: Discrepancy
        color: green
      - type: entity
        children:
          - sensor.cwu_1_total_volume_m3
          - sensor.cwu_2_total_volume_m3
          - sensor.cwu_3_total_volume_m3
          - sensor.cwu_4_total_volume_m3
          - sensor.cwu_5_total_volume_m3
          - sensor.cwu_7_total_volume_m3
          - sensor.cwu_8_total_volume_m3
          - sensor.cwu_9_total_volume_m3
          - sensor.cwu_10_total_volume_m3
          - sensor.cwu_11_total_volume_m3
          - sensor.cwu_12_total_volume_m3
          - sensor.cwu_12a_total_volume_m3
          - sensor.cwu_adm_total_volume_m3
          - sensor.1_zw
          - sensor.2_zw
          - sensor.3_zw
          - sensor.4_zw
          - sensor.5_zw
          - sensor.6_zw
          - sensor.7_zw
          - sensor.8_zw
          - sensor.9_zw
          - sensor.10_zw
          - sensor.11_zw
          - sensor.12_zw
          - sensor.12a_zw
          - sensor.adm_zw
          - reszta
        name: Input
        entity_id: sensor.wmbus_reader_v2_apator_wifi_na_1_total
        color: blue
        color_on_state: false
  - entities:
      - type: entity
        children: []
        entity_id: sensor.cwu_1_total_volume_m3
        color: DarkSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_2_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_3_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_4_total_volume_m3
        color: IndianRed
      - type: entity
        children: []
        entity_id: sensor.cwu_5_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_7_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_8_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_9_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_10_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_11_total_volume_m3
        color: Salmon
      - type: entity
        children: []
        entity_id: sensor.cwu_12_total_volume_m3
        color: LightCoral
      - type: entity
        children: []
        entity_id: sensor.cwu_12a_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_adm_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.1_zw
      - type: entity
        children: []
        entity_id: sensor.2_zw
      - type: entity
        children: []
        entity_id: sensor.3_zw
      - type: entity
        children: []
        entity_id: sensor.4_zw
      - type: entity
        children: []
        entity_id: sensor.5_zw
      - type: entity
        children: []
        entity_id: sensor.6_zw
      - type: entity
        children: []
        entity_id: sensor.7_zw
      - type: entity
        children: []
        entity_id: sensor.8_zw
      - type: entity
        children: []
        entity_id: sensor.9_zw
      - type: entity
        children: []
        entity_id: sensor.10_zw
      - type: entity
        children: []
        entity_id: sensor.11_zw
      - type: entity
        children: []
        entity_id: sensor.12_zw
      - type: entity
        children: []
        entity_id: sensor.12a_zw
      - type: entity
        children: []
        entity_id: sensor.adm_zw
      - type: remaining_parent_state
        children: []
        name: reszta
        entity_id: reszta
        color: green
type: custom:sankey-chart
title: Sankey wodociągi
energy_date_selection: true
show_names: true
show_icons: false
sort_dir: desc
wide: true
sort_by: state
min_state: 0.0001

Issue example

8 liters =/= 7 liters + 1 liter + 1 liter ==> FALSE

There is in middle entity related to "sensor.wmbus_reader_v2_wezel_zw_do_cwu_wifi_total" but zero registered

image

layout: horizontal
height: 400
unit_prefix: ""
round: 4
convert_units_to: ""
co2_intensity_entity: sensor.co2_signal_co2_intensity
gas_co2_intensity: 2351.6459999999997
min_box_size: 6
min_box_distance: 7
show_states: true
show_units: true
sections:
  - entities:
      - type: remaining_child_state
        children:
          - sensor.wmbus_reader_v2_wezel_zw_do_cwu_wifi_total
          - sensor.1_zw
          - sensor.2_zw
          - sensor.3_zw
          - sensor.4_zw
          - sensor.5_zw
          - sensor.6_zw
          - sensor.7_zw
          - sensor.8_zw
          - sensor.9_zw
          - sensor.10_zw
          - sensor.11_zw
          - sensor.12_zw
          - sensor.12a_zw
          - sensor.adm_zw
        entity_id: whatever
        name: Discrepancy
        color: green
      - type: entity
        children:
          - sensor.wmbus_reader_v2_wezel_zw_do_cwu_wifi_total
          - sensor.1_zw
          - sensor.2_zw
          - sensor.3_zw
          - sensor.4_zw
          - sensor.5_zw
          - sensor.6_zw
          - sensor.7_zw
          - sensor.8_zw
          - sensor.9_zw
          - sensor.10_zw
          - sensor.11_zw
          - sensor.12_zw
          - sensor.12a_zw
          - sensor.adm_zw
          - reszta
        name: Input
        entity_id: sensor.wmbus_reader_v2_apator_wifi_na_1_total
        color: blue
        color_on_state: false
  - entities:
      - type: entity
        children:
          - sensor.cwu_1_total_volume_m3
          - sensor.cwu_2_total_volume_m3
          - sensor.cwu_3_total_volume_m3
          - sensor.cwu_4_total_volume_m3
          - sensor.cwu_5_total_volume_m3
          - sensor.cwu_7_total_volume_m3
          - sensor.cwu_8_total_volume_m3
          - sensor.cwu_9_total_volume_m3
          - sensor.cwu_10_total_volume_m3
          - sensor.cwu_11_total_volume_m3
          - sensor.cwu_12_total_volume_m3
          - sensor.cwu_12a_total_volume_m3
          - sensor.cwu_adm_total_volume_m3
        entity_id: sensor.wmbus_reader_v2_wezel_zw_do_cwu_wifi_total
        color: red
      - type: passthrough
        children: []
        entity_id: sensor.1_zw
      - type: passthrough
        children: []
        entity_id: sensor.2_zw
      - type: passthrough
        children: []
        entity_id: sensor.3_zw
      - type: passthrough
        children: []
        entity_id: sensor.4_zw
      - type: passthrough
        children: []
        entity_id: sensor.5_zw
      - type: passthrough
        children: []
        entity_id: sensor.6_zw
      - type: passthrough
        children: []
        entity_id: sensor.7_zw
      - type: passthrough
        children: []
        entity_id: sensor.8_zw
      - type: passthrough
        children: []
        entity_id: sensor.9_zw
      - type: passthrough
        children: []
        entity_id: sensor.10_zw
      - type: passthrough
        children: []
        entity_id: sensor.11_zw
      - type: passthrough
        children: []
        entity_id: sensor.12_zw
      - type: passthrough
        children: []
        entity_id: sensor.12a_zw
      - type: passthrough
        children: []
        entity_id: sensor.adm_zw
      - type: passthrough
        children: []
        name: reszta
        entity_id: reszta
        color: green
  - entities:
      - type: entity
        children: []
        entity_id: sensor.cwu_1_total_volume_m3
        color: DarkSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_2_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_3_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_4_total_volume_m3
        color: IndianRed
      - type: entity
        children: []
        entity_id: sensor.cwu_5_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_7_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_8_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_9_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_10_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_11_total_volume_m3
        color: Salmon
      - type: entity
        children: []
        entity_id: sensor.cwu_12_total_volume_m3
        color: LightCoral
      - type: entity
        children: []
        entity_id: sensor.cwu_12a_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.cwu_adm_total_volume_m3
        color: LightSalmon
      - type: entity
        children: []
        entity_id: sensor.1_zw
      - type: entity
        children: []
        entity_id: sensor.2_zw
      - type: entity
        children: []
        entity_id: sensor.3_zw
      - type: entity
        children: []
        entity_id: sensor.4_zw
      - type: entity
        children: []
        entity_id: sensor.5_zw
      - type: entity
        children: []
        entity_id: sensor.6_zw
      - type: entity
        children: []
        entity_id: sensor.7_zw
      - type: entity
        children: []
        entity_id: sensor.8_zw
      - type: entity
        children: []
        entity_id: sensor.9_zw
      - type: entity
        children: []
        entity_id: sensor.10_zw
      - type: entity
        children: []
        entity_id: sensor.11_zw
      - type: entity
        children: []
        entity_id: sensor.12_zw
      - type: entity
        children: []
        entity_id: sensor.12a_zw
      - type: entity
        children: []
        entity_id: sensor.adm_zw
      - type: remaining_parent_state
        children: []
        name: reszta
        entity_id: reszta
        color: green
type: custom:sankey-chart
title: Sankey wodociągi
energy_date_selection: true
show_names: true
show_icons: false
sort_dir: desc
wide: true
sort_by: state
min_state: 0.0001

Example for the same yesterday period and please check "reszta" / remaining value. Fiers with middle section, 2nd without middle section.

image

image

Another day:

image

image

@kzajac83 kzajac83 added the bug Something isn't working label Nov 29, 2024
@kzajac83
Copy link
Author

Update. For period 0:00 to 2:00, there is one liter missing in 1st chart with passthrought.

image

image

@MindFreeze
Copy link
Owner

This could be floating point error because you have such small numbers. Try adding unit_prefix: m to see if it improves

@kzajac83
Copy link
Author

Yes. I thinking too about prefix but:

  • I tested already and nothing change, below fresh test from "now"
  • this is only 3 digits after digital separator. I know how numbers are stored by computer especially float numbers and I can understood ten or more places after dec. separator but for 3 digits this shouldn't be a problem.
  • strange looks mm3 = "mili m3" is just liter

Will be very stage if 3 digits after decimal separator is a problem for calculations,the root of cause should be in other place, I guess on formula behind calc remaining.

image
image

@MindFreeze
Copy link
Owner

I see the issue now, after a lot of staring. The problem is not the passthrough.
It's that you are adding a real entity in the middle that has a smaller value than the sum of its children. So then you have a discrepancy in the middle section that is correctly not displayed.
Your discrepancy in the first section looks at its direct children and when you put another entity in the middle, it doesn't check its children because that wouldn't make sense.

You have 3 options:

  1. Use reconcile options so there is no discrepancy between section 2 and section 3
  2. add another discrepancy entity in the middle section
  3. link the current discrepancy directly to the end entities

@MindFreeze MindFreeze closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
@kzajac83
Copy link
Author

Thank you, yes now I see it also. The middle section should update every 5 min where end meters every 3 min hence the difference.

Regarding answers, option 1. and 2. is not what I search. Can you tell me how 3rd option implement correctly?

@MindFreeze
Copy link
Owner

You can try adding all the children of sensor.wmbus_reader_v2_wezel_zw_do_cwu_wifi_total as children of the discrepancy as well. In theory that should work but it is pretty complex setup so who knows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants