Anyone using the Sankey Chart Card?

I couldnt get it all in one nice sankey so I split it up in the overall view, and a detailed view with all individual endpoints, and have selector set the minimum precision.

Advantage here is the overall view is created by sensors directly measuring the solar and smart meter (and some templating for return/consumption color) and can not fluke, where the detailed is using the utility_meter entities that need some repairing every now and then.,… that way my main overview is always correct, and I simply ignore the detailes for the day :wink:

other big plus is the size of the children isnt out of proportion too much

1 Like

Has anyone managed to solve the problem?

Nope. Seems to be a bug. I was able to reproduce it but haven’t had time to work on it

OK, thanks for the feedback.

I tried a test last night hoping it could be helpful for solving the problem.
I usually turn off Homeassistant at 23:00 and the display problem is always there.
Now I tried turning it off at 00:05 and the energy is displayed correctly, so it seems to be a problem that happens when the sensor is unavailable at 00:00.

Hey @MindFreeze - I recently posted the feature request for sorting while grouping by the parent. I’m happy to work on building that request but would love a little input from you on how I’m thinking to implement it. I responded on the GH Issue here. Thanks for your work on this, it’s much appreciated!

@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