Anyone using the Sankey Chart Card?

@MindFreeze how do I turn OFF the sort by parent - My charts are ALL supposed to be sorted by state, asc (yes I throttle it, significantly)

Take a look at the last two columns - card code did not change and worked in the immediately preceeding version - now:

That’s not sorted at ALL. I couldnt figure out what it was trying to do until I read the sort by parent ‘upgrade’

(same card code - i just reload versions between shots)
Downgraded to 1.16.0: better - but Still not quite right:

Finally back to 1.15.1: correct…

I need sort-asc to override it.

edit: @hummingbear I like the IDEA of sort by parent - but I need it to work.
edit2: we’ll talk about the scaling change afterwards… I also need a way to have the previous behavior.

Opened:
Feature #153 Breaks sort by state. · Issue #143 · MindFreeze/ha-sankey-chart (github.com)
and
1.16 breaks scaling between card sections · Issue #142 · MindFreeze/ha-sankey-chart (github.com)

Edit3: 1.17.1 fixed all of these and split group by parent out on its own option.

How do you use the new ‘sort_group_by_parent’ function?

I’ve tried writing it in various ways, but I never manage to have all the groups and sensors in order.

This is how I’ve written it:
sort_by: state
sort_group_by_parent: true

This is the result:

This is exactly how you should write it for each section, you want to sort. Maybe you have cache issue

just started using it.

I like this very much and wonder of this would be possible with dynamic connections (wifi device on various access points in the house)?
This would perfectly visualize the different connections between the main router, the mesh devices as well as the phones, cameras, etc.

Do you know if this is possible and if so, could you provide a small example how to connect the dynamic devices to the sankey configuration?

I tested what I am able to do:

I would like to create a view of my network devices spread all over the various repeaters around the house.
My idea is to start with the router (fritz.box) and let it branch into the 7 repeaters.
From there I would like to connect the devices like tasmota bulbs, cameras, phones etc to the connected repeater.
For the middle part (repeater) I have created dynamic groups which are populated with the members connected to the repeater:

service: group.set
data:
  object_id: fritz_clients_rep_wozi_sofa
  name: Geräte an Fritz Wozi-Sofa
  icon: mdi:network-outline
  entities: >
    {{ states.device_tracker | selectattr('attributes.connected_to', 'search',
    'fritz-Powerline-1220E-WoZi-Sofa') | map(attribute='entity_id') | list }}

I tried to create a Sankey Card with it and wonder if this is even possible.
My code looks like this and I am happy to hear about your comments:

type: entities
title: Mesh
view_layout:
  grid-area: footer
entities:
  - type: custom:hui-element
    card_type: custom:sankey-chart
    show_names: true
    height: 500
    width: 800
    unit_prefix: null
    wide: true
    sections:
      - entities:
          - entity_id: group.fritz_clients_fritzbox
            name: Fritzbox
            color: blue
            children:
              - entity_id: device_tracker.echo_kueche
              - entity_id: device_tracker.gas_meter_esp8266
              - entity_id: device_tracker.lupin
              - entity_id: device_tracker.tasmota_flurlicht_keller_l
              - entity_id: device_tracker.tasmota_flurlicht_keller_r
              - entity_id: device_tracker.tasmota_heizungsstrom
              - entity_id: device_tracker.tasmota_server
              - entity_id: device_tracker.tasmota_stromleser
              - entity_id: device_tracker.tasmota_wama_strom
          - entity_id: Sonstige
            type: remaining_parent_state
            name: Keine Verbindung
            color: black
      - entities:
          - entity_id: device_tracker.echo_kueche
            name: Echo Küche
          - entity_id: device_tracker.gas_meter_esp8266
            name: Gas-Zähler
          - entity_id: device_tracker.lupin
            name: Alarmanl.
          - entity_id: device_tracker.tasmota_flurlicht_keller_l
            name: L. Flur (UG l)
          - entity_id: device_tracker.tasmota_flurlicht_keller_r
            name: L. Flur (UG r)
          - entity_id: device_tracker.tasmota_heizungsstrom
            name: Hz-Strom
          - entity_id: device_tracker.tasmota_server
            name: Server-Strom
          - entity_id: device_tracker.tasmota_stromleser
            name: Stromleser
          - entity_id: device_tracker.tasmota_wama_strom
            name: WaMa-Strom

Hi @amaximus

Would you mind sharing your code?
I would like to try to setup a view of my network with mesh repeaters and the devices connected to them.

Thank you in advance.
NCO

Hi @NCO3,

my solution works the following way:

  • I defined a dedicated template sensor for each device or entity that I wanted to include in the dependency tree:
    ** the “branches” in the dependency tree have a value depending on their state. The difference in value is 0.1 which is not really visible when displayed, still it can be used in the card configuration to display color-based states. The value of a “branch” is the sum of values of its children’s values.
    ** the “leaves” in the dependency tree have a value of 1, however you may use the above logic if you want to display them color-changing state-dependent.
platform: template
sensors:
  dep_mqtt:
    friendly_name: MQTT
    value_template: "{% if states('sensor.mqtt')|int > 0 %}6{% else %}6.1{%endif %}"
    icon_template: mdi:message-processing-outline
:
   dep_smoke_detector1:
    friendly_name: Füstérzékelő1
    value_template: "1"
    icon_template: mdi:smoke-detector
:
  • I use a dedicated view of sidebar type to display the dependency tree
  • my card uses color based states. The color limit at a certain point is the sum of the values of the children devices.
  • the card displays columns based on the list of entities from the sections part: first list of entites is the left-most column, followed by the next list of entities, etc.
  • simplified example explained:
    ** RF blinds, garage door, etc depend on the RF433 bridge; they are leaves with values 1 each, the RF bridge has a value of 4 (having four leaves with values 1).
    ** similarly Zigbee temp/humidity (zbth_akos) and door/window (zbdw_akos) sensors are leaves having values 1 each, but they depend on the Zigbee bridge that has value 2 (having two leaves with values 1)
    ** MQTT device has two children, the RF and the Zigbee bridges, having a value of 6 (4+2 from its children)
  - type: custom:sankey-chart
    show_names: true
    show_icons: true
    show_states: false
    min_box_height: 15
    height: 500
    sections:
      - entities:
          - entity_id: sensor.dep_mqtt
            color_on_state: true
            color_below: red
            color_above: mediumaquamarine
            color_limit: 6
            children:
              - sensor.dep_sonoff_rf433
              - sensor.dep_sonoff_zigbee
      - entities:
          - entity_id: sensor.dep_sonoff_rf433
            color_on_state: true
            color_below: mediumaquamarine
            color_above: red
            color_limit: 4
            children:
              - sensor.dep_blinds
              - sensor.dep_garage_door
              - sensor.dep_smoke_detector0
              - sensor.dep_smoke_detector1
          - entity_id: sensor.dep_sonoff_zigbee
            color_on_state: true
            color_below: mediumaquamarine
            color_above: red
            color_limit: 2
            children:
              - sensor.dep_zbth_akos
              - sensor.dep_zbdw_akos
1 Like

Awesome!
Thank you very much for your detailed response!
This helps a lot.
Creating additional template sensors for each entity I would like to include is a lot of effort, but worth the work for such a nice overview.
It’s a good project for the upcoming end-of-year holidays!
:smiley:

EDIT:
@amaximus:
I have one more question I struggle with.
Because some devices’ connection will jump between the different repeaters (e.g. when I walk around with my phone).
That’s why I created the different dynamic groups.
I guess this dynamic structure cannot be taken into account with the sankey card?
Like:

children:
   {{ expand('group.fritz_clients_fritzbox') }}

@NCO3 I was thinking a little bit about your goal and the way it could be implemented. This is how would I approach the dynamic display:

  • the router and repetears each should have a template defined where their value is the number of statically connected devices + for each device that can be connected to multiple devices (e.g. mobiles, tablets, anything that moves around the house) a device*is_connected
    e.g. mobileA would have a mobileA_repeater1, mobileA_repeater2, … mobileA_repeaterN and their template sensor would define it which will have value 1 for the the repeater that is connected to, the others will get automatically value of 0
  • so repeater1’s template value would be sum of the statically connected devices + the sum of mobileN_repeaterK
  • on the sankey-chart you could use option min_state: 1 (however I guess by default shows the ones with non-zero value) , therefore they will dynamically appear as child of repeater1 when connected to it and disappear from the rest of repeaterKs.

Please note that I haven’t tested this, it’s purely a theoretical solution.

Wow, thank you for spending even more time on my topic.
That’s an interesting approach.
For 7 repeaters / access points including the Fritzbox itself, it would require 7 times the number of portable devices in the house (around 8) additional sensors.
I am not sure yet, if this is worth the effort.

Because the auto-entities card uses some JS code filter the entities shown, I wonder if this would be possible for a Sankey card to move the entities dynamically between the groups (repeaters) as well.
But the JS code is far beyond my capabilities.

Anyway, I will start trying your approach and might come back with questions. :wink:
Again - thank you for your support!

Dear all !

Is there a way to combine multiple entities into a intermediate level dirrectly on the card ?

My current sankey :

  • image

My wish : Get 3 levels for
=> EDF => Kitchen => Frigo Garage + Frigo buanderie + Cuisine

My current card configuration :

height: 200
unit_prefix: ''
round: 0
min_box_height: 3
min_box_distance: 5
show_states: true
show_units: true
sections:
  - entities:
      - type: entity
        children:
          - sensor.ecocompteur_inst_data1
          - sensor.ecocompteur_inst_data2
          - sensor.ecocompteur_inst_data3
          - sensor.ecocompteur_inst_data4
          - sensor.ecocompteur_inst_data5
          - sensor.prise_chauffage_inertie_power
          - sensor.prise_chauffage_power
          - sensor.eaton_baieinfo_current_real_power
          - sensor.prise_frigo_buanderie_power
          - sensor.prise_frigo_garage_power
          - sensor.eaton_salon_current_real_power
          - house_other_energy
        entity_id: sensor.enedis_power
        name: EDF
        sort_by: state
  - entities:
      - type: entity
        children: []
        name: Pompe à chaleur
        color: red
        entity_id: sensor.ecocompteur_inst_data1
      - type: entity
        children: []
        entity_id: sensor.ecocompteur_inst_data2
        name: Ballon thermodynamique
      - type: entity
        children: []
        entity_id: sensor.ecocompteur_inst_data3
        name: Eclairage
      - type: entity
        children: []
        entity_id: sensor.ecocompteur_inst_data4
        name: Cuisine
        color: purple
      - type: entity
        children: []
        entity_id: sensor.ecocompteur_inst_data5
        name: Buanderie
      - type: entity
        children: []
        entity_id: sensor.prise_chauffage_inertie_power
        name: Radiateur salon
        color: red
      - type: entity
        children: []
        entity_id: sensor.prise_chauffage_power
        name: Radiateur cuisine
        color: red
      - type: entity
        children: []
        entity_id: sensor.eaton_baieinfo_current_real_power
        name: Baie informatique
        color: green
      - type: entity
        children: []
        entity_id: sensor.prise_frigo_buanderie_power
        name: Frigo buanderie
        color: purple
      - type: entity
        children: []
        entity_id: sensor.prise_frigo_garage_power
        name: Frigo garage
        color: purple
      - type: entity
        children: []
        color: grey
        entity_id: sensor.eaton_salon_current_real_power
        name: TV & Ordinateur salon
      - type: remaining_parent_state
        children: []
        entity_id: house_other_energy
        name: Autres
    sort_by: state
type: custom:sankey-chart
show_names: true
min_state: 0
title: Répartition énergétique

You can easily do this with a type: remaining_child_state entity in the new section. Just make an entity like this with name Kitchen and add the 3 entities you want as children. There may be an example in the Readme.
Make sure to add Kitchen as child of EDF and remove the other 3 from EDF

2 Likes

Im trying to create a chart for the energy flow in my solar/battery system to house usage.

I believe I have all the data needed to do this but I cannot work out how to get it to work.

Above is what im trying to get to. The 7 bullet points are sensors with the data. Can you combine multiple sensors into a single entity. E.g for the Solar entity it should be the sum for Solar2House + Solar2Battery + Solar2Grid

The house bit onwards I’ve sorted, its just the first half im struggling with.

You can combine entities with add_entities but I recommend just creating sum helper entities in HA instead of relying on the card for this. It is easier to debug, track and customize in HA

thanks for the heads up, that was alot easier than trying to work out the add_entites or subtract_entities options.

Would you mind sharing your config please, that’s what I’m trying to achieve

Sure this the code for my dashboard. This is for a GivEnergy battery system, so might be quite different for another manufacturer.

GivEnergy gives the following sensors:
Grid to Battery
Grid to House
Solar to House
Solar to Battery
Solar to Grid
Battery to House
Battery to Grid

I then had to create the following summed entities:
GridAll
- Grid to Battery
- Grid to House
SolarAll
- Solar to House
- Solar to Battery
- Solar to Grid
BatteryAll
- Battery to House
- Battery to Grid

MyGrid
- Solar to Grid
- Battery to Grid
MyHouse
- Grid to House
- Solar to House
- Battery to House
MyBattery
- Grid to Battery
- Solar to Battery

height: 500
unit_prefix: k
round: 1
min_box_height: 10
min_box_distance: 5
show_states: true
show_units: true
sections:
  - entities:
      - type: entity
        children:
          - sensor.ma9_um_solar2house
          - sensor.ma9_um_solar2battery
          - sensor.ma9_um_solar2grid
        entity_id: sensor.ma9_um_solarall
        name: Solar
        color: orange
      - type: entity
        children:
          - sensor.ma9_um_grid2battery
          - sensor.ma9_um_grid2house
        entity_id: sensor.ma9_um_gridall
        name: Grid
        color: red
  - entities:
      - type: entity
        entity_id: sensor.ma9_um_solar2house
        children:
          - sensor.ma9_um_myhouse
        name: To House
        color: orange
      - type: entity
        entity_id: sensor.ma9_um_solar2battery
        children:
          - sensor.ma9_um_mybattery
        name: To Battery
        color: orange
      - type: entity
        entity_id: sensor.ma9_um_solar2grid
        children: []
        color: green
        name: Export
      - type: entity
        entity_id: sensor.ma9_um_grid2house
        children:
          - sensor.ma9_um_myhouse
        name: To House
        color: red
      - type: entity
        entity_id: sensor.ma9_um_grid2battery
        children:
          - sensor.ma9_um_mybattery
        name: To Battery
        color: red
  - entities:
      - type: passthrough
        children:
          - sensor.ma9_um_myhouse
        entity_id: sensor.ma9_um_myhouse
        name: House
      - type: entity
        children:
          - sensor.ma9_um_myhouse
          - sensor.ma9_um_battery2grid
          - BatteryLeft
        entity_id: sensor.ma9_um_mybattery
        name: Battery
        color: purple
  - entities:
      - type: entity
        children:
          - office_today
          - kitchen_today
          - house_other
          - sensor.tv_master_today_s_consumption
          - sensor.tv_speakers_today_s_consumption
          - sensor.myenergi_eddi_xxxxxxxx_energy_used_today
          - sensor.ma9_um_givenergy_losses
        entity_id: sensor.ma9_um_myhouse
        name: House
      - type: remaining_parent_state
        children: []
        entity_id: BatteryLeft
        name: Battery Left
        color: purple
      - type: entity
        entity_id: sensor.ma9_um_battery2grid
        children: []
        color: Green
        name: Export
    sort_by: state
  - entities:
      - type: remaining_child_state
        children:
          - sensor.office_computers_monitors_xbox_today_s_consumption
          - sensor.office_2_today_s_consumption
        entity_id: office_today
        name: Office
      - type: remaining_child_state
        children:
          - sensor.fridge_today_s_consumption
          - sensor.dishwasher_today_s_consumption
          - sensor.washing_machine_today_s_consumption
        entity_id: kitchen_today
        name: Kitchen
      - type: passthrough
        children:
          - sensor.tv_master_today_s_consumption
        entity_id: sensor.tv_master_today_s_consumption
        name: TV Master
      - type: passthrough
        children:
          - sensor.tv_speakers_today_s_consumption
        entity_id: sensor.tv_speakers_today_s_consumption
        name: TV Lounge
      - type: passthrough
        children:
          - sensor.myenergi_eddi_xxxxxxxx_energy_used_today
        entity_id: sensor.myenergi_eddi_xxxxxxxx_energy_used_today
        name: Eddi
      - type: remaining_parent_state
        children: []
        entity_id: house_other
        name: Other
      - type: Entity
        children: []
        entity_id: sensor.ma9_um_givenergy_losses
        name: System Losses
        color: red
    sort_by: state
  - entities:
      - type: entity
        children: []
        entity_id: sensor.office_computers_monitors_xbox_today_s_consumption
        name: Monitors
      - type: entity
        children: []
        entity_id: sensor.office_2_today_s_consumption
        name: Computers
      - type: entity
        children: []
        entity_id: sensor.fridge_today_s_consumption
        name: Fridge
      - type: entity
        children: []
        entity_id: sensor.dishwasher_today_s_consumption
        name: Dishwasher
      - type: entity
        children: []
        entity_id: sensor.washing_machine_today_s_consumption
        name: Washing Machine
      - type: entity
        children: []
        entity_id: sensor.tv_master_today_s_consumption
        name: TV Master
      - type: entity
        children: []
        entity_id: sensor.tv_speakers_today_s_consumption
        name: TV Lounge
      - type: entity
        children: []
        entity_id: sensor.myenergi_eddi_xxxxxxxx_energy_used_today
        name: Eddi
    sort_by: state
type: custom:sankey-chart
show_names: true
wide: true
min_state: 0.1
show_icons: false
energy_date_selection: false
1 Like

Thanks, that works great

Hello, who can help me fix the error?
I’ve tried everything but I keep having problems.
This error:
RangeError: Maximum call stack size exceeded

height: 400
unit_prefix: k
round: 1
min_box_height: 7
min_box_distance: 5
show_states: true
show_units: true
sections:
  - entities:
      - type: entity
        children:
          - sensor.p1_meter_total_power_export
          - totaal
        entity_id: sensor.envoy_122241000712_today_s_energy_production
        color: var(--warning-color)
        name: Totaal zon
      - type: entity
        children:
          - totaal
        entity_id: sensor.p1_meter_total_power_import_t1
        add_entities:
          - sensor.p1_meter_total_power_import_t2
        name: Total import
    sort_group_by_parent: false
  - entities:
      - type: remaining_parent_state
        children:
          - keuken
          - was & droger
          - warmtepomp
          - kantoor voor
          - onbekend
        entity_id: totaal
        name: Totaal gebruikt
      - type: entity
        children: []
        entity_id: sensor.p1_meter_total_power_export
    sort_group_by_parent: false
  - entities:
      - type: remaining_parent_state
        children:
          - sensor.quooker_energy
        entity_id: keuken
      - type: remaining_parent_state
        children:
          - sensor.3d_printer_energy
        entity_id: kantoor voor
      - type: remaining_parent_state
        children:
          - sensor.energie_warmtepomp_buitendeel_energy
          - sensor.energie_warmtepomp_element_energy
        entity_id: warmtepomp
      - type: remaining_parent_state
        children:
          - sensor.droger_switch_0_current
        entity_id: was & droger
      - type: remaining_parent_state
        entity_id: onbekend
    sort_group_by_parent: false
  - entities:
      - type: entity
        children: []
        entity_id: sensor.quooker_energy
      - type: entity
        children: []
        entity_id: sensor.3d_printer_energy
      - type: entity
        children: []
        entity_id: sensor.energie_warmtepomp_buitendeel_energy
      - type: entity
        children: []
        entity_id: sensor.energie_warmtepomp_element_energy
      - type: entity
        children: []
        entity_id: sensor.droger_switch_0_current
    sort_group_by_parent: false
energy_date_selection: true
type: custom:sankey-chart
show_names: true
wide: true
min_state: 0
show_icons: false

Has anyone experimented with using this card together with auto-entities?