MindFreeze / ha-sankey-chart

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

Auto config for energy dashboard #60

Closed MindFreeze closed 11 months ago

MindFreeze commented 1 year ago

In theory the card can be auto configured for energy with the data from the energy dashboard.

The most basic resulting config would be ${energy sources} -> ${individual consumers} with probably a sum in the middle.

An even better config would group the consumers by area as well. So: ${energy sources} -> ${total consumed} -> ${areas from HA} -> ${individual consumers}

house2001 commented 1 year ago

Hi,

I'm getting an error when building a chart with autoconfig:

Is it helpful to share the generated yaml and error? This is a great project and I know it's in beta still.

MindFreeze commented 1 year ago

Yes, please share. a picture of you energy-distribution card would also be very useful

martinarva commented 1 year ago

Could somebody share the lovelace YAML that works. I have tried everything but get the result:

Screenshot 2023-01-02 at 16 39 03
kamaradclimber commented 1 year ago

I have the same output (2022.12.x and 2023.1.x) , should we open an dedicated issue?

MindFreeze commented 1 year ago

No need for a dedicated issue but I do need the outputof this command in the browser's dev console (F12) JSON.stringify((await hassConnection).conn._energy.prefs.energy_sources) and/or a picture of the energy-distribution card in your energy dashboard

kamaradclimber commented 1 year ago
"[{\"type\":\"grid\",\"flow_from\":[{\"stat_energy_from\":\"sensor.home_energy_meter_gen5_electric_consumed_kwh\",\"stat_cost\":null,\"entity_energy_price\":\"sensor.electricity_cost\",\"number_energy_price\":null}],\"flow_to\":[],\"cost_adjustment_day\":0},{\"type\":\"gas\",\"stat_energy_from\":\"sensor.gaz_consumption_in_kwh\",\"stat_cost\":null,\"entity_energy_price\":null,\"number_energy_price\":0.1563},{\"type\":\"water\",\"stat_energy_from\":\"sensor.water_total\",\"stat_cost\":null,\"entity_energy_price\":null,\"number_energy_price\":null}]"

image

MindFreeze commented 1 year ago

I can't reproduce this. Added some debug logs in v1.7.0 , so post back if you get something in the console with that version

kamaradclimber commented 1 year ago

Thanks for your reply.

I still get the "not found" message (present in previous version as well) and a new debug object: 2023-01-10-165509_2278x288_scrot

Xitro01 commented 1 year ago

Same problem here, just cleanly installed Sankey Chart, never used it before.

I currently do have 1 entity in the Energy Dashboard which is currently unavailable/missing, might that have something to do with this issue occuring? It is the dryer which I'm currently replacing, should be delivered today so can check if this fixes it by the end of the day. Might be good for Sankey to just ignore missing entities if this really is the case.

Running: Home Assistant 2023.1.5 Supervisor 2022.12.1 Operating System 9.4 Frontend-version: 20230110.0 - latest HA-Sankey-Chart: v1.8.0

Card config:

- type: custom:sankey-chart
  autoconfig:
    print_yaml: false

Error on dashboard:

Error: Something went wrong. No energy data received.
height: 200
unit_prefix: k
round: 1
min_box_height: 3
min_box_distance: 5
show_states: true
show_units: true
energy_date_selection: true
sections: []
type: custom:sankey-chart
autoconfig:
  print_yaml: false

Error in console log:

ha-sankey-chart.js:1  sankey-chart  Version 1.8.0 
0:1 Uncaught (in promise) Objectcode: "not_found"message: "Entity not found"[[Prototype]]: Objectconstructor: ƒ Object()assign: ƒ assign()create: ƒ create()defineProperties: ƒ defineProperties()defineProperty: ƒ defineProperty()entries: ƒ entries()freeze: ƒ freeze()fromEntries: ƒ fromEntries()getOwnPropertyDescriptor: ƒ getOwnPropertyDescriptor()getOwnPropertyDescriptors: ƒ getOwnPropertyDescriptors()getOwnPropertyNames: ƒ getOwnPropertyNames()getOwnPropertySymbols: ƒ getOwnPropertySymbols()getPrototypeOf: ƒ getPrototypeOf()hasOwn: ƒ hasOwn()is: ƒ is()isExtensible: ƒ isExtensible()isFrozen: ƒ isFrozen()isSealed: ƒ isSealed()keys: ƒ keys()length: 1name: "Object"preventExtensions: ƒ preventExtensions()prototype: {constructor: ƒ, __defineGetter__: ƒ, __defineSetter__: ƒ, hasOwnProperty: ƒ, __lookupGetter__: ƒ, …}seal: ƒ seal()setPrototypeOf: ƒ setPrototypeOf()values: ƒ values()arguments: (...)caller: (...)[[Prototype]]: ƒ ()hasOwnProperty: ƒ hasOwnProperty()isPrototypeOf: ƒ isPrototypeOf()propertyIsEnumerable: ƒ propertyIsEnumerable()toLocaleString: ƒ toLocaleString()toString: ƒ toString()valueOf: ƒ valueOf()__defineGetter__: ƒ __defineGetter__()__defineSetter__: ƒ __defineSetter__()__lookupGetter__: ƒ __lookupGetter__()__lookupSetter__: ƒ __lookupSetter__()__proto__: (...)get __proto__: ƒ __proto__()set __proto__: ƒ __proto__()
MindFreeze commented 1 year ago

That could be it. I'll try to reproduce with a missing entity.

martinarva commented 1 year ago

I have some missing entities as well, but I don't want to delete them, because when it will delete history as well from energy dashboard. For example, my PV entity changed, because I changed the integration
Screenshot 2023-01-18 at 12 17 36

Maybe it's possible to just skip unavailable entities?

MindFreeze commented 1 year ago

1.8.2 will ignore missing entities

martinarva commented 1 year ago

1.8.2 will ignore missing entities

Screenshot 2023-01-18 at 16 36 35

Now a new kind of error

type: custom:sankey-chart autoconfig: print_yaml: false

Dutchy-79 commented 1 year ago

Autoconfig error Screenshot_20230118_153610_Home Assistant Screenshot_20230118_160229_Home Assistant

MindFreeze commented 1 year ago

@martinarva try v1.9.0 . I was only checking the consumers before. Now it checks producers as well

Xitro01 commented 1 year ago

It is working for me on v1.8.0 now, since I connected my dryer again.

Updated to v1.9.0 and it's still working, only it doesn't seem to populate the lines/stripes and names of consumers automatically, is this expected behaviour?

MindFreeze commented 1 year ago

Not expected. You are the second person to report this. Mind posting a pic of your energy distribution card?

Xitro01 commented 1 year ago

Not expected. You are the second person to report this. Mind posting a pic of your energy distribution card?

Already did this, but strangely enough my screenshot did not go through, hopefully now it works: Schermafbeelding 2023-01-18 171142

MindFreeze commented 1 year ago

I mean the card that is called Energy Distribution, in the Energy dashboard. On the right in desktop mode

Xitro01 commented 1 year ago

I mean the card that is called Energy Distribution, in the Energy dashboard. On the right in desktop mode

D5FBBD98-E898-4955-859B-90C40DCCDA75

MindFreeze commented 1 year ago

Looks quite similar to the other report. Maybe grid export is causing this. I'll try to reproduce this tomorrow

martinarva commented 1 year ago

image

Now a new error in every sankey chart

N0BaDaY commented 1 year ago

Same issue, even after going back to 1.8.2 4D4F56FE-CA5E-429A-B023-1FC6914B9CE1

Dutchy-79 commented 1 year ago

Screenshot_20230118_193253_Home Assistant

Reboot and stays the same, v1. 9

MindFreeze commented 1 year ago

I think I fixed the export problem. Please let me know

martinarva commented 1 year ago

I think I fixed the export problem. Please let me know

Yes, graph in general works now, but autoconfig still dont:

Screenshot 2023-01-19 at 15 17 23

Where can i see the logs for that?

martinarva commented 1 year ago

Screenshot 2023-01-19 at 15 24 24 Screenshot 2023-01-19 at 15 23 36

Xitro01 commented 1 year ago

Just like the rest, I get the following error now:

Custom element doesn't exist: sankey-chart.
type: custom:sankey-chart
autoconfig:
  print_yaml: false

Using v1.9.2 and already cleared my cache a couple of times.

Dutchy-79 commented 1 year ago

Going from v1. 9 to 1.9.2 solved that for me somehow.

MindFreeze commented 1 year ago

@Xitro01 HA cached the bad version somewhere else and not only the normal browser cache. WebWorkers or something similar, haven't investigated. You have to clear all application data and unregister wokers, or just wait for it to expire. Took a couple of hours for me.

Xitro01 commented 1 year ago

@Xitro01 HA cached the bad version somewhere else and not only the normal browser cache. WebWorkers or something similar, haven't investigated. You have to clear all application data and unregister wokers, or just wait for it to expire. Took a couple of hours for me.

The HA update this morning finally fixed it. Washer and dryer are not connected anymore, getting new ones this morning. So the missing entities issue is resolved.

But still missing labels and I expect the highest consumers on top, now it seems a bit random (unsorted): week

Also it doesn't really seem to take into account that some solar power might not be used yourself, that it's delivered back. Should actually say: 58,2 from net, 9,4 used in solar (and 6,6 delivered back to the grid)

P.S. Awesome work for developing this chart and creating a feature like this, therefore I'm happy to help as much as I can to make it near perfect. It is much appreciated, I think I can speak for all of us.

N0BaDaY commented 1 year ago

Fixed with v1.9.2 👍🏻

Xitro01 commented 1 year ago

Another update from me, I found out that I could just use "show_names: true". Knipsel

Also as mentioned in my post before: It doesn't really seem to take into account that some solar power might not be used yourself, that it's delivered back.

Dutchy-79 commented 1 year ago

You can setup yourself Screenshot_20230122_122924_Home Assistant

Xitro01 commented 1 year ago

You can setup yourself

Beats the purpose of 'autoconfig', the information is already there, ready to be used.

Dutchy-79 commented 1 year ago

It's used but configured differently. Autoconfig is just a basic to get started imo.

N0BaDaY commented 1 year ago

I still don't understand how to configure the autoconfig. I am just curious what it will come up with but I can't get it to work...don't know where to put the " type: energy-date-selection" No matter where I put this it comes up with error messages. Anyone has a clue?

Scherm­afbeelding 2023-01-23 om 10 08 31

this doesn't work:

Scherm­afbeelding 2023-01-23 om 10 15 27
Dutchy-79 commented 1 year ago

I had the same problem but the Readme makes it look wrong.

You need 2 cards

Card 1 Custom card type: energy-data-selection

Card 2 Sankey card type: custom:sankey-chart energy_date_selection: true autoconfig: print_yaml: true

N0BaDaY commented 1 year ago

Thanks a lot, it works now:

Scherm­afbeelding 2023-01-23 om 11 49 25
MindFreeze commented 1 year ago

Yep, the README assumes a yaml mode dashboard. I hadn't used UI mode until recently and am just now seeing the differences. Working on improving this in #77

@Xitro01 autoconfig is indeed just a starting point. This is the point of the print_yaml option. show_names should be turned on by default, I guess, but you other expectations are very subjective.

martinarva commented 1 year ago

In my case it's still not working: Screenshot 2023-01-25 at 17 44 49

N0BaDaY commented 1 year ago

It worked all right but now it doesn't any more...same error message as above..I haven't changed anything apart from the update tot the latest version