MindFreeze / ha-sankey-chart

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

Parent/Child colors reversed #96

Closed GitHubGoody closed 10 months ago

GitHubGoody commented 1 year ago

Checklist:

Release with the issue: v1.9.3

Last working release (if known): N/A

Browser and Operating System: Edge on Windows 10

Description of problem:

Sometimes, the colors between parent and child display reversed as shown in the screenshot below between Grid and Outside.

Javascript errors shown in the web inspector (if applicable): None

Additional information:

image

MindFreeze commented 1 year ago

I can't reproduce this or figure out how it might happen

MindFreeze commented 1 year ago

closing as unreproducable

GitHubGoody commented 1 year ago

@MindFreeze Is there something I could do to help you reproduce it?

MindFreeze commented 1 year ago

@GitHubGoody an example config to reproduce this might help

starox commented 1 year ago

I just have some strange behaviour where the 4th section color was inversed with the 1st. It was caused by an improper color name, ie: light_blue instead LightBlue @GitHubGoody : Eventually check your colors

GitHubGoody commented 1 year ago

@MindFreeze and @starox

Here is the config excerpt for those two sections:

        - entities:
              # Main Panel
            - entity_id: sensor.main_panel_123_1d
              name: Grid
              color_on_state: true
              color_limit: 90
              color_above: red
              color_below: darkslateblue
              children:
                - sensor.inside_daily_energy
                - sensor.outside_daily_energy
                - sensor.garage_daily_energy
                - sensor.receptacles_energy
                - sensor.main_crawlspace_dehumidifier_7_1d
                - sensor.sunroom_crawlspace_dehumidifier_and_sump_pump_8_1d
        - entities:
              ## Outside
            - entity_id: sensor.outside_daily_energy
              name: Outside
              color: green
              children:
                - sensor.terrace_energy
                - sensor.outside_lights_energy
                - sensor.pool_energy
              ## Inside
            - entity_id: sensor.inside_daily_energy
              name: Inside
              color: whitesmoke
              children:
                - sensor.upstairs_daily_energy
                - sensor.downstairs_daily_energy
                - sensor.ac_subpanel_1_1d

The colors all seem to be working otherwise.

silfax commented 10 months ago

Ok, having a similar problem. I say it is similar since the colors can be reversed but also totally wrong. First I encountered the reversed colors issue, but after doing lots of changes in the code, I ended up with the result in the second screenshot. I really don't know what info would be relevant, therefore I leave below all my 'sections' section of the card. Please note that this always occurs only at the top, not with the specific entities shown in the screenshot. Being an energy card, any of the groups can move at the top and the colors are always reverted for the topmost group. Screenshots and code below.

Screenshot 1, colors reversed, sadly I don't have the code anymore:

Screenshot 2, wrong/messed up colors, code for this issue below: image

sections:
  - entities:
      - type: entity
        entity_id: sensor.inverter_active_power
        children:
          - sensor.putere_instantanee
          - sensor.power_meter_active_power
        color: green
        name: Productie
      - type: entity
        entity_id: sensor.putere_instantanee
        children:
          - sensor.putere_instantanee
        subtract_entities:
          - sensor.inverter_active_power
        color: red
        name: Import
  - entities:
      - type: entity
        entity_id: sensor.power_meter_active_power
        color: red
        name: Export
      - type: entity
        children:
          - sensor.terasa_mansarda_current_consumption
          - sensor.priza_centrala_termica_energy_power
          - sensor.priza_frigider_energy_power
          - sensor.priza_living_energy_power
        entity_id: sensor.putere_instantanee
        remaining:
          name: Alti consumatori
          color: '#295096'
        name: Consum total
        color: purple
        sort_group_by_parent: true
  - entities:
      - type: entity
        children:
          - sensor.terasa_parter_current_consumption
          - sensor.terasa_mansarda_current_consumption
        entity_id: sensor.terasa_mansarda_current_consumption
        add_entitites:
          - sensor.terasa_parter_current_consumption
        color: '#4DE738'
        name: Prize exterior
      - type: entity
        children:
          - sensor.priza_centrala_termica_energy_power
          - sensor.priza_pompa_basa_energy_power
        add_entitites:
          - sensor.priza_pompa_basa_energy_power
        entity_id: sensor.priza_centrala_termica_energy_power
        name: Utilitati
        color: red
      - type: entity
        entity_id: sensor.priza_frigider_energy_power
        children:
          - sensor.priza_frigider_energy_power
          - sensor.priza_cuptor_microunde_energy_power
          - sensor.priza_espressor_energy_power
          - sensor.priza_uscator_prosoape_energy_power
          - sensor.priza_masina_spalat_rufe_energy_power
        add_entities:
          - sensor.priza_cuptor_microunde_energy_power
          - sensor.priza_espressor_energy_power
          - sensor.priza_uscator_prosoape_energy_power
          - sensor.priza_masina_spalat_rufe_energy_power
        color: orange
        name: Electrocasnice
      - type: entity
        children:
          - sensor.garaj_current_consumption
          - sensor.priza_living_energy_power
          - sensor.priza_living_2_energy_power
          - sensor.priza_living_3_energy_power
          - sensor.priza_birou_1_energy_power
          - sensor.priza_birou_2_energy_power
          - sensor.priza_birou_3_energy_power
          - sensor.priza_retea_mansarda_energy_power_2
        add_entities:
          - sensor.garaj_current_consumption
          - sensor.priza_living_2_energy_power
          - sensor.priza_living_3_energy_power
          - sensor.priza_birou_1_energy_power
          - sensor.priza_birou_2_energy_power
          - sensor.priza_birou_3_energy_power
          - sensor.priza_retea_mansarda_energy_power_2
        subtract_entities:
          - sensor.terasa_mansarda_current_consumption
        entity_id: sensor.priza_living_energy_power
        name: IT & Media
        color_on_state: false
    sort_by: state
    sort_dir: desc
    sort_group_by_parent: true
  - entities:
      - type: entity
        children: []
        entity_id: sensor.garaj_current_consumption
        name: Garaj
      - type: entity
        children: []
        entity_id: sensor.priza_centrala_termica_energy_power
        color: red
        name: Centrala termica
      - type: entity
        children: []
        entity_id: sensor.priza_pompa_basa_energy_power
        color: red
        name: Pompa basa
      - type: entity
        children: []
        entity_id: sensor.terasa_parter_current_consumption
        color: '#4DE738'
        name: Terasa parter
      - type: entity
        children: []
        entity_id: sensor.terasa_mansarda_current_consumption
        color: '#4DE738'
        name: Terasa mansarda
      - type: entity
        entity_id: sensor.priza_frigider_energy_power
        children: []
        color: orange
        name: Frigider
      - type: entity
        children: []
        entity_id: sensor.priza_cuptor_microunde_energy_power
        color: orange
        name: Cuptor microunde
      - type: entity
        children: []
        entity_id: sensor.priza_espressor_energy_power
        color: orange
        name: Espressor
      - type: entity
        children: []
        entity_id: sensor.priza_uscator_prosoape_energy_power
        color: orange
        name: Uscator prosoape
      - type: entity
        children: []
        entity_id: sensor.priza_masina_spalat_rufe_energy_power
        color: orange
        name: Masina spalat rufe
      - type: entity
        children: []
        entity_id: sensor.priza_living_energy_power
        name: Living 1
      - type: entity
        children: []
        entity_id: sensor.priza_living_2_energy_power
        name: Living 2
      - type: entity
        children: []
        entity_id: sensor.priza_living_3_energy_power
        name: Living 3
      - type: entity
        children: []
        entity_id: sensor.priza_birou_1_energy_power
        name: Birou 1
      - type: entity
        children: []
        entity_id: sensor.priza_birou_2_energy_power
        name: Birou 2
      - type: entity
        children: []
        entity_id: sensor.priza_birou_3_energy_power
        name: Birou 3
      - type: entity
        children: []
        entity_id: sensor.priza_retea_mansarda_energy_power_2
        name: Retea mansarda
    sort_by: state
    sort_dir: desc
    sort_group_by_parent: true
    min_width: 10
silfax commented 10 months ago

On more thing that may help to narrow it down. If I change the first section from the code posted in the previous comment to the one below, I get the card from the screenshot below. Parent/child relationship is lost, but the colors are correct. No other changes to the code posted in the previous comment. image

  - entities:
      - type: entity
        entity_id: sensor.inverter_active_power
        children:
          - sensor.putere_instantanee
          - sensor.power_meter_active_power
        color: green
        name: Productie
      - type: entity
        entity_id: sensor.putere_instantanee
        children: []
        subtract_entities:
          - sensor.inverter_active_power
        color: red
        name: Import
silfax commented 10 months ago

Checked with latest release and I still get this. Thanks!

Opera Snapshot_2023-12-06_155651_ipv15 tk

MindFreeze commented 10 months ago

@silfax this has to be a cache issue. The bug is definitely fixed

silfax commented 10 months ago

Then it's maybe something in my specific card configuration. Tried it with a never used before browser and I still get the same wrong colors. Thanks anyway!

silfax commented 10 months ago

@GitHubGoody Can you confirm that v1.19.0 solves the issue for you? Thanks!

GitHubGoody commented 10 months ago

@GitHubGoody Can you confirm that v1.19.0 solves the issue for you? Thanks!

It appears to be solved for my configuration. Are you sure you're on v1.19.0? For some reason, HACS wasn't prompting me to update it, so I was on v1.18.0 and had to select Redownload from the 3 dots menu. The issue was there before the redownload and fixed after. No cache clearing required.

MindFreeze commented 10 months ago

@silfax the version is logged in the dev console. You can check that

GitHubGoody commented 10 months ago

Thanks, It's also in HACS in the top left.

silfax commented 10 months ago

Hmm... Strange. HACS was showing 1.19.0 installed, but after redownloading it, the card suddenly looks right. No need to clear the cache. Thank you both!