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

Open
kzajac83 opened this issue Nov 29, 2024 · 3 comments
Open
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

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