Anyone using the Sankey Chart Card?

Many thanks! That’s what I was hoping. So here’s an example I tried:

type: custom:sankey-chart
show_names: true
sections:
  - entities:
      - entity_id: sensor.smart_meter_electricity_power
        name: Electricity Consumption
        children:
          - lights
          - unmonitored
  - entities:
      - entity_id: lights
        type: remaining_child_state
        name: Lights
        children:
          - sensor.living_room_lights_power
          - sensor.richards_bedside_light_current_consumption
      - entity_id: unmonitored
        type: remaining_parent_state
        name: Unmonitored
  - entities:
      - entity_id: sensor.living_room_lights_power
        name: Living Room lights
      - entity_id: sensor.richards_bedside_light_current_consumption
        name: Bedside light

However I then get the following error:

Yep this kind of loop is what I was talking about. Though looking at the config it should work. I’ll try to reproduce and fix this.

Thank you! For some reason the summed entity doesn’t show up for me – the left side of the graph remains blank.

I have tried adding both consumed energy entities, but I get an error: RangeError: Maximum call stack size exceeded. Sounds like an infinite loop or something?

Here’s my config:

type: custom:sankey-chart
show_names: true
round: 1
unit_prefix: k
energy_date_selection: true
sections:
  - entities:
      - entity_id: sensor.energy_consumed_tariff_1
        children:
          - sensor.networking_plug_energy
          - sensor.fridge_energy
          - energy_other
      - entity_id: sensor.energy_consumed_tariff_2
        children:
          - sensor.networking_plug_energy
          - sensor.fridge_energy
          - energy_other
  - entities:
      - entity_id: sensor.networking_plug_energy
      - entity_id: sensor.fridge_energy
      - entity_id: energy_other
        type: remaining_parent_state
        name: Other

Am doing anything wrong here?

Thanks @MindFreeze - it looks like @bastiaanterhorst is seeing the same error as me, but not seeing that reported elsewhere in the thread so presumably its not common.

I’ll keep experimenting but if you work it out let us know - thanak again!

@Nuuki @bastiaanterhorst
Just fixed it in v1.3.3

Amazing work! I no longer get the error, but its not rendering the remaining parent entity now:

You mentioned poasible loops - in this case I don’t think that should be an issue but maybe…?

Still working for me (fourth section - “unmonitored”).

Should be fixed. Try v1.3.4

Thanks so much! I got it to work with the two separate sensors now. Strangely, the single sensor I created still does not work.

I’ll share the template for defining it – when I inspect the entity it looks good (correct values) and it has been up and running for several days now. But when I add it to the leftmost Sankey column it does not work…

Template sensor:

sensor:
  - platform: template
    sensors:
      energy_consumed_grid:
        unique_id: '0a7476cc-d6c1-40ba-8ae1-606518c3497f'
        friendly_name: "Grid consumption"
        unit_of_measurement: 'kWh'
        value_template: "{{ states('sensor.energy_consumed_tariff_1')|float + states('sensor.energy_consumed_tariff_2')|float }}"

Sankey card config:

type: custom:sankey-chart
show_names: true
round: 1
unit_prefix: k
energy_date_selection: true
sections:
  - entities:
      - entity_id: sensor.energy_consumed_grid
        name: Grid low tariff
        children:
          - sensor.floor_heating_bathroom_1_energy
          - sensor.floor_heating_bathroom_2_energy
          - sensor.bastiaans_workspace_energy
          - sensor.phase_1_em_channel_2_energy
          - sensor.phase_1_em_channel_1_energy
          - sensor.networking_plug_energy
          - sensor.plunge_pool_energy
          - sensor.shellyem3_3494547565ab_channel_a_energy
          - sensor.freezer_energy
          - sensor.water_treatment_energy
          - sensor.fridge_energy
          - sensor.washer_energy
          - sensor.dryer_energy
          - energy_other
  - entities:
      - entity_id: sensor.floor_heating_bathroom_1_energy
      - entity_id: sensor.floor_heating_bathroom_2_energy
      - entity_id: sensor.bastiaans_workspace_energy
      - entity_id: sensor.phase_1_em_channel_2_energy
      - entity_id: sensor.phase_1_em_channel_1_energy
      - entity_id: sensor.networking_plug_energy
      - entity_id: sensor.plunge_pool_energy
      - entity_id: sensor.shellyem3_3494547565ab_channel_a_energy
      - entity_id: sensor.freezer_energy
      - entity_id: sensor.water_treatment_energy
      - entity_id: sensor.fridge_energy
      - entity_id: sensor.washer_energy
      - entity_id: sensor.dryer_energy
      - entity_id: energy_other
        type: remaining_parent_state
        name: Other

What it looks like:
Screenshot 2022-11-28 at 09.21.33

What it looks like when I add my two tariff sensors (this is good!):

Am I doing something wrong with the single sensor? I would prefer that view because technically the separate tariff views are not correct; the Sankey card has no way of knowing what entity consumed energy from which tariff.

It now works perfectly - everything I had hoped for so thank you!

trying my first card with:

type: entities
title: Daily Energy Distribution
entities:
  - type: custom:hui-element
    card_type: custom:sankey-chart
    show_names: true
    height: 300
    round: 2
    wide: true
    sections:
      - entities:
          - entity_id: sensor.grid_energy_teller_2
            name: Grid Peak Energy Used
            color: '#488fc2'
            children:
              - sensor.grid_energy_total
          - entity_id: sensor.grid_energy_teller_1
            name: Grid Offpeak Energy Used
            color: '#2f5f82'
            children:
              - sensor.grid_energy_total
          - entity_id: sensor.solaredge_production_energy
            name: Solar Energy Produced
            color: '#ff9800'
            children:
              - sensor.calculated_totaal_dag_levering
              - sensor.solar_self_consumption_daily
      - entities:
          - entity_id: sensor.grid_energy_total
            name: Daily Imported Total
            children:
              - sensor.energy_consumed_daily
          - entity_id: sensor.solar_self_consumption_daily
            name: Self Consumed Solar
            color: '#ff9800'
            children:
              - sensor.energy_consumed_daily
          - entity_id: sensor.calculated_totaal_dag_levering
            name: Solar Energy Exported
            color: '#8353d1'

I keep seeing the Missing child entity sensor.energy_consumed_daily in Inspector. I did list that, but must have made a mistake?

secondly I do get a graph of sorts:

but there is no left element for the Sun energy (0 currently)

So, probably all noob mistakes, please be gentle…

This is very strange. Maybe your template sensors are somehow excluded from history stats. A simple workaround would be to create a middle section with a remaning_parent_state entity that is a child of both tariffs, and have everything else be children of that. This way the chart will create the sum for you but both tariffs will still be shown in the first section

You don’t have sensor.energy_consumed_daily in your config. You need 1 more section with that entity

1 Like

getting there, thanks :wink:

had some unit conversions going on too (some n wH, some in kWh) so had to adjust some templates.
guess we can not set unit_prefix in the individual entities to fx that for us?

now have to figure out why my card_mod on the card header doesnt work…

type: custom:sankey-chart
title: Energie verbruik
card_mod:
  class: class-header-margin
show_names: true
height: 300
round: 2
wide: true
sections:

History stats are working for this sensor… So that’s not the problem. I’ll stick to using the separate sensors for now, but very strange this is not working!

for a final sep today, trying to get the remaining_parent_state

  - entities:
      - entity_id: al_het_andere
        type: remaining_parent_state
        name: Alle andere
      - entity_id: sensor.energy_consumed_daily
        name: Gemeten verbruik
        color: '#488FC2'
        children:
          - sensor.boiler_bijkeuken_daily
          - sensor.wasdroger_bijkeuken_daily
          - etcetc

to show up. Doesnt work though:

probably an obvious reason…?

al_het_andere must be in the last section and be in children of sensor.energy_consumed_daily

like this?

# last section
  - entities:
      - entity_id: al_het_andere
        type: remaining_parent_state
        name: Alle andere
      - entity_id: sensor.energy_consumed_daily
        name: Gemeten verbruik
        color: '#488FC2'
        children:
          - al_het_andere
          - sensor.boiler_bijkeuken_daily
          - sensor.wasdroger_bijkeuken_daily

apparently not, getting Error: Entity not found al_het_andere now…

sensor.energy_consumed_daily should not be in the last one. Everything that is in children must be in the next section and no entity in the last section can have children because there is nothing after it.

still all bit confusing to me, but Ive found it to work like this:

  - entities:
      - entity_id: sensor.energy_consumed_daily
        name: Gemeten verbruik
        color: '#488FC2'
        children:
          - al_het_andere
          - sensor.boiler_bijkeuken_daily
          - sensor.wasdroger_bijkeuken_daily
          - etcetcetc
#last_section
  - entities:
      - entity_id: al_het_andere
        type: remaining_parent_state
        name: Alle andere
      - entity_id: sensor.boiler_bijkeuken_daily
        name: Boiler
      - entity_id: sensor.wasdroger_bijkeuken_daily
        name: Wasdroger
      - etcetcetc

will bring it to the bottom, because this looks a bit silly

on the header: would there be any reason for this and not to respond to

type: custom:sankey-chart
title: Energie verbruik
card_mod:
  class: class-header-margin

which is a regular class I use on all of my cards, containing:

        .: |
          ha-card.class-header-margin .card-header {
            background-color: var(--background-color-off);
            font-weight: 400;
            font-size: 20px;
            color: var(--text-color-off);
            padding: 0px 12px;
            margin: 0px 0px 16px 0px;
          }

can not get it to kick in, even though the inspector shows the header to be
Scherm­afbeelding 2022-11-28 om 17.08.34

update

for now, the only way I can find a solution is to use the sankey inside an entities card:

type: entities
title: Energie verbruik
card_mod:
  class: class-header-margin
entities:

  - type: custom:hui-element
    card_type: custom:sankey-chart
    card_mod:
      style: |
        ha-card {
          margin: -8px -16px -16px -16px;
          box-shadow: none:
        }

to get