home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
3.79k stars 2.59k forks source link

Energy Dashboard doesn't display 'consumed solar' in some scenarios #13701

Open sexysaxon opened 1 year ago

sexysaxon commented 1 year ago

Checklist

Describe the issue you are experiencing

On some days 'consumed solar' isn't displayed on the energy distribution graphic on energy dashboard. Consumed solar will be shown in the main energy usage graphic for that day but is absent when looking at the week view. I have a battery on my system and this appears to happen only on nights where I charge the battery between 00:30 and 04:30 (I'm using Octopus Go tariff). This scenario only appears to happen when using large charges. on 4/9/22 I gave the battery a small charge and the problem didn't manifest. Similarly on 7/9/22 I only put in 1kWH and the problem didn't appear.

image

Describe the behavior you expected

Consumed solar to be shown correctly. Attached screen shot of a good day 7/11/2022 image

Steps to reproduce the issue

  1. Charge a battery with over 1kWh between 00:30 and 04:30
  2. ...

What version of Home Assistant Core has the issue?

2022.8.4 and previous version

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

No response

Which operating system are you using to run this browser?

Windows 10

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

Ben00793 commented 7 months ago

Why did my last comment been marked off topic? I'm trying to fix the issue here.

I dont know it seems odd, If i had to guess something to do with the use of ChatGTP. It does seem that you are the only person that has made an effort to update the code, I dont know enough to know if its correct but i appreciate the effort :)

Thanks Mate!

langestefan commented 7 months ago

Why did my last comment been marked off topic? I'm trying to fix the issue here.

Because posting untested ChatGPT code doesn't help anyone. In fact it's considered annoying because people will waste time on code that is 99% rubbish.

smai86 commented 5 months ago

Hey Guys,

I´ve got the problem that I´ll got wrong values if the battery charges from grid... In this case energy Dashboard doubles up (only sometimes!) the value of energy that move into the battery. And I´ve got always the same problem with no values in this time for my house (this is every time the battery charges vom grid).

Is there any solution?

Bildschirmfoto 2024-01-09 um 20 25 52
Ben00793 commented 5 months ago

Hey Guys,

I´ve got the problem that I´ll got wrong values if the battery charges from grid... In this case energy Dashboard doubles up (only sometimes!) the value of energy that move into the battery. And I´ve got always the same problem with no values in this time for my house (this is every time the battery charges vom grid).

Is there any solution?

Bildschirmfoto 2024-01-09 um 20 25 52

You can manually edit the values in: developer tools - statistics. Search for the sensor and click on the little ramp icon on the right, then look for the specific time and date l.

sexysaxon commented 5 months ago

You definitely need grid in/out. How else would you be able to tell what the house load is?

Imagine you have: solar_production = 1kWh battery_output = 0.5 kWh battery_input = 0 kWh

What is the house load? Well, that's totally dependent on what the grid is providing (or being returned!). If grid_out = 1.5kWh then the house load is 0, but if grid_in = 10kWh then the house load is 11.5kWh!

The actual problem I think is that having battery_output be solar|grid makes it impossible to know accurately what the solar consumption is just by adding numbers - @kaitlinsm's proposal is to integrate to capture the difference which should resolve the inaccuracies.

For example, let's say battery_in is 1 kWh, but when the sun was down that day. Solar production was 1 kWh. If we add, we get solar consumption = 1kWh, which is wrong because battery_in occurred when the sun was down.

The correct solution is to integrate (or aggregate). In other words, if the wrong formula for solar consumption is:

solar_consumption(t)=solar_production(t)−grid_out(t)−battery_in(t)

Then the correct formula should be: solar_consumption(t)=∫solar_production−grid_out−battery_indt

Which solves the above problem.

The only problem here being that grid_out can include battery_out. Without a way to tell whether grid_out includes battery_out might be impossible without having a way to directly measure the house load. An example of where this could be a significant issue:

solar_production = 10kW house_load = 10kW battery_out = 10kW grid_out = 10kW

So, here's the question - is the solar consumption in this time slice 0% (the house is consuming the battery?) or 100% (the house is consuming the solar and exporting the battery?). Moreover, it seems that we would need to know what % of the battery was charged by solar too - and that presents the same problem - in this scenario, was the battery charged by solar, or the grid:

solar_production = 10kW house_load = 10kW battery_in = 10kW grid_in = 10kW

Perhaps this could be resolved if we designed some priority rules and kept them consistent. For instance, we could define that solar always goes to the house, and anything leftover goes into the battery. But this still leaves us with the problem of not knowing the house_load, and not being able to differentiate between battery export and solar export. Perhaps we could apply a priority rule on that as well? Battery export is prioritized, so perhaps the rule is then:

solar_consumption(t)=∫solar_production−max(grid_out−battery_out,0)−battery_indt

so if there is any battery output, that gets taken into account first - "the house is consuming the solar and exporting the battery" in the previous example.

@karwosts - perhaps this can be done by having the frontend implicitly create (or request the user create) an integration platform sensor for solar consumption?

Revised: I agree you need a grid sensor. You are correct in that you need more than the two sensors you mention but the HA dashboard has three sensors, Battery in/out, grid in/out and solar. From these three sensors the home can always be calculated so home sensor is not required. As stated previously Givenergy ( and other systems) only monitor the same three variables as the HA dashboard and produce all the information correctly so this issue is a software issue in HA and no other sensors are required.

purcell-lab commented 5 months ago

There has been some discussions about if people have access to that household load consumption as a seperate sensor, which could be added to the dashboard to resolve this issue.

If you have access to household consumption could you post the results here.

For those with a powerwall gateway the household consumption is available via the sensor: _sensor.powerwall_loadimport

Screenshot_20240114-203120

purcell-lab commented 5 months ago

For those with SolarEdge inverters with a consumption meter the household load is available in the entity _sensor.solaredge_consumptionenergy

Screenshot_20240114-204113

purcell-lab commented 5 months ago

For those with a Deye/ Sunsynk inverter the household load is available with the entity _sensor.sunsynk_day_loadenergy

Screenshot_20240114-204309

Ralphy140 commented 5 months ago

Thanks for looking at this Mark, I think a key message is that the Household load sensor MUST to be provided by the battery system because if its provided by a diffrent system (like the solar inverter or an CT clamp solution like Circuitsetup.us) depending on where the CT clamp is located it may also measure the charge/discharge power of the battery and include it in the household load. I know this is the case whit my setup with a SolarEdge Inverter and a Tesla Powerwall.

Ralphy140 commented 5 months ago

Saying that I am more than happy to help out in any testing thats required. I can spin up a beta system to test with and validate with my system that includes SolarEdge and Tesla Powerwall

Ben00793 commented 5 months ago

Saying that I am more than happy to help out in any testing thats required. I can spin up a beta system to test with and validate with my system that includes SolarEdge and Tesla Powerwall

Hello, I'm using Solar Assisstant integration with growatt inverter. I also have Load energy available as an entity. How can I add it to the energy dashboard? I'm also happy to do some beta testing with my system if I can have acces to the beta. image image

iainJersey commented 5 months ago

I'm with Ben ... Where, in the energy dashboard would I use the 'house load'? Both systems give me (broadly similar) grid import figures and naturally they differ as to the house load (the SolarEdge cant see the battery at all, obviously)

I have solarEdge and a Sunsynk, with (DC connected) battery.

langestefan commented 5 months ago

I'm with Ben ... Where, in the energy dashboard would I use the 'house load'? Both systems give me (broadly similar) grid import figures and naturally they differ as to the house load (the SolarEdge cant see the battery at all, obviously)

I have solarEdge and a Sunsynk, with (DC connected) battery.

There is no house load configurable at the moment, somebody will have to spend some time reworking the calculations for that to happen.

Ralphy140 commented 5 months ago

I think the challenge for a system that does not by default include a house load system is the many diffrent ways that the system can be configured to measure the grid import/export, battery import/export and solar production. The only feasable way i can see to move forwards is to have a section that lets you add a "house load" sensor and if your battery system does not provide out of the box the end user will need to use a template sensor to calculate it and then provide that as the sensor because there is no reliable way to calculate it for all scenarios otherwise

sexysaxon commented 5 months ago

I hate to keep banging the same drum but this topic has become confused as far as I can see. As stated before the three sensors on HA provide all the info required to calculate house load and this is actually calculated correctly on HA (and always has been). Again as stated before many battery systems (Including Givenergy which I have) do this and accurately calculate power and energy usage for the battery with just three sensors and none for home usage which is calculated from the three other values. On my system I also have Shelly EM clamps monitoring the same three values (Solar, Grid in/out and Battery on/out) and this also calculates battery power and energy correctly within the Shelly app. So if Shelly and Givenergy can calculate battery charge and discharge why can't HA. There is no need for a load sensor. As per my original comment on this thread this is purely a display issue under a specific set of circumstances as per the original few comments. Just for further clarification I run two HA instances one using the Givenergy sensors on the Energy Dashboard and one using the Shelly EMs and they both produce identical results.

langestefan commented 5 months ago

I hate to keep banging the same drum but this topic has become confused as far as I can see. As stated before the three sensors on HA provide all the info required to calculate house load and this is actually calculated correctly on HA (and always has been). Again as stated before many battery systems (Including Givenergy which I have) do this and accurately calculate power and energy usage for the battery with just three sensors and none for home usage which is calculated from the three other values. On my system I also have Shelly EM clamps monitoring the same three values (Solar, Grid in/out and grid on/out) and this also calculates battery power and energy correctly within the Shelly app. So if Shelly and Givenergy can calculate battery charge and discharge why can't HA. There is no need for a load sensor. As per my original comment on this thread this is purely a display issue under a specific set of circumstances as per the original few comments. Just for further clarification I run two HA instances one using the Givenergy sensors on the Energy Dashboard and one using the Shelly EMs and they both produce identical results.

I think you are confused, because the problem is not calculating house load but assigning the energy flows to different components when a battery is involved in the calculation.

Edit: but indeed you are correct if your battery or PV inverter can measure all variables simultaneously in real time then it can calculate house load from that. But most people will have separate integrations for which the measurement periods aren't synchronized, so then your calculation will fail.

sexysaxon commented 5 months ago

I hate to keep banging the same drum but this topic has become confused as far as I can see. As stated before the three sensors on HA provide all the info required to calculate house load and this is actually calculated correctly on HA (and always has been). Again as stated before many battery systems (Including Givenergy which I have) do this and accurately calculate power and energy usage for the battery with just three sensors and none for home usage which is calculated from the three other values. On my system I also have Shelly EM clamps monitoring the same three values (Solar, Grid in/out and grid on/out) and this also calculates battery power and energy correctly within the Shelly app. So if Shelly and Givenergy can calculate battery charge and discharge why can't HA. There is no need for a load sensor. As per my original comment on this thread this is purely a display issue under a specific set of circumstances as per the original few comments. Just for further clarification I run two HA instances one using the Givenergy sensors on the Energy Dashboard and one using the Shelly EMs and they both produce identical results.

I think you are confused, because the problem is not calculating house load but assigning the energy flows to different components when a battery is involved in the calculation.

Edit: but indeed you are correct if your battery or PV inverter can measure all variables simultaneously in real time then it can calculate house load from that. But most people will have separate integrations for which the measurement periods aren't synchronized, so then your calculation will fail

Partially agree on the synchronisation point it just depends how bad the synchronisation is of course. As stated earlier I use two Shelly EMs which have two channels each, so two sensors (Grid and Solar) on one and Battery on the other. The Shelly EMs aren't synchronised but update every 2 seconds or so and the results correlate almost exactly with the Givenergy sensors which are synchronised. The point is this problem is not really about synchronisation of sensors, it's the fact that under certain scenarios the Dashboard shows correctly and in others it doesn't. Hence the title of the issue "Energy Dashboard doesn't display 'consumed solar' in some scenario". These scenarios have been documented by myself and others at the start of the thread. If synchronisation is an issue for some I would suggest a separate issue is raised but I agree this would require a sperate sensor which I would suggest is a feature request not a bug.

langestefan commented 5 months ago

Okay let's take the following hypothetical situation where you have a battery, PV and grid sensors. Within a given hour, you have recorded:

The equation for the house consumption is:

house = pv_prod - batt_in + batt_out + grid_in − grid_out

Plug in the values:

house = 10 - 3 + 2 + 6 - 4 = 11 kWh

Okay great. Now how do we attribute that 11 kWh to the different sources? That's where the problem/ambiguity is.

iainJersey commented 5 months ago

The issue is that, from a Sunsynk point of view, you can choose whether PV goes to battery first, and then load, or load first with surplus to battery.It’s an unwinnable dichotomy, I suspect!My major irritation is that when the battery is charged with PV production we get the ‘nonsense’ combined from grid, which is meaningless- but might be the best availableIainOn 16 Jan 2024, at 18:14, Stefan de Lange @.***> wrote: Okay let's take the following hypothetical situation where you have a battery, PV and grid sensors. Within a given hour, you have recorded:

pv_prod = 10 kWh PV production grid_out = 4 kWh grid export grid_in = 6 kWh grid import batt_in = 3 kWh battery import batt_out = 2 kWh battery export

The equation for the house consumption is: house = pv_prod - batt_in + batt_out + grid_in − grid_out Plug in the values: house = 10 - 3 + 2 + 6 - 4 = 11 kWh Okay great. Now how do we attribute that 11 kWh to the different sources? That's where the problem/ambiguity is.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

langestefan commented 5 months ago

The issue is that, from a Sunsynk point of view, you can choose whether PV goes to battery first, and then load, or load first with surplus to battery.It’s an unwinnable dichotomy, I suspect!My major irritation is that when the battery is charged with PV production we get the ‘nonsense’ combined from grid, which is meaningless- but might be the best availableIain

Exactly. So should HA be aware of what Sunsynk does? What about batteries that trade energy with the grid? I can't think of a way for HA to account for all these cases besides adding more sensors that measure flows between PV->house etc.

sexysaxon commented 5 months ago

Okay let's take the following hypothetical situation where you have a battery, PV and grid sensors. Within a given hour, you have recorded:

  • pv_prod = 10 kWh PV production
  • grid_out = 4 kWh grid export
  • grid_in = 6 kWh grid import
  • batt_in = 3 kWh battery import
  • batt_out = 2 kWh battery export

The equation for the house consumption is:

house = pv_prod - batt_in + batt_out + grid_in − grid_out

Plug in the values:

house = 10 - 3 + 2 + 6 - 4 = 11 kWh

Okay great. Now how do we attribute that 11 kWh to the different sources? That's where the problem/ambiguity is.

Here is the problem description:

_Describe the issue you are experiencing On some days 'consumed solar' isn't displayed on the energy distribution graphic on energy dashboard. Consumed solar will be shown in the main energy usage graphic for that day but is absent when looking at the week view.__

To clarify the problem, look at the first screenshot in the original post. You will see that in the main "Energy Usage" graphic consumed solar (coloured orange) for the daylight hours throughout the day. In the adjacent "power distribution" graphic there is no correlating orange shown in the home roundel. The second screenshot shows a good day when the consumed solar for the day does have a correlation and you see orange for consumed solar in the home roundel. The problem I reported is a that the two displays. Can this display discrepancy be attributed to the problem you describe?

langestefan commented 5 months ago

Can this display discrepancy be attributed to the problem you describe?

Yes it would. Because those dark yellow bars are calculated based on the calculation that I described. The second one is probably also wrong, but less obviously so. How it fail depends on the kWh figures for each sensor.

tbrasser commented 4 months ago

I believe I am facing the same issue. I have no solar, just a (simulated) battery and dynamic grid pricing. My energy dashboard makes no sense. Seems it is hardwired to only charge from solar and export to house consumption.

bartowl commented 3 months ago

I have the same problem when I charge battery from grid. Also I have my grid input and output split in 3 phases and from time to time, also in night, where no solar energy is produced instead of individual values for each phase i get "combined from grid" - this shows however only for few hours and I would prefer to always see individual phases. I think the energy card would need general rebuild to include 2 possible battery charge sources. At the moment there is a workaround posted somewhere to create a helper that adds grid-in and solar-in but in my opinion this is rather bad. I had to switch to energy calculated from BMS in/out power, which does not distinguish the source of energy. By doing that i faced the issue described here, where my self-consumed solar does not show at all. Having the battery aware of where the energy came from would solve this. Nowadays there are more and more hybrid systems, where battery can be charged from both sources and I do not see a reason NOT to provide just 2 input sources on the battery. This would also make the energy flow paths calculation significantly easier as it is now. image 1-3pm i charged battery from grid, but it also took some energy from solar at the same time, since this is my solar production. The lighter color solar is offgrid-only, which goes 100% into battery where the darker is ongrid which went partially into battery due to charging from "grid" and partially into my home. A bit of it even got back into grid, as i am having 3-phase ongrid system image I think that my setup is the most complex there can be, with offgrid and on-grid solar and battery with dual charging sources. I have energy meters on both solar sources, on BMS (direct battery in/out) and even on my offgrid inverter which measures output energy and also input energy (used to charge batteries from "grid" by the inverter and when inverter switches to internal bypass powering output directly from "grid" input - when low on battery for example). If the energy card would be able to support this setup, it would be able to support every possible constellation :) I can provide basic circuit diagrams if needed

tbrasser commented 3 months ago

I guess you are spot on! If we have the most complex system as base system/calculation, we can set the rest to 0 (in a way where we keep it updated every time any other energy entity updates to facilitate nice graphs/statistics) when a user doesn't have those components.

That should then fallback to correct graphs/diagrams/calculations for every scenario right?

Hope you can work together with the developer of the current code. (for me, proper energy management would always be higher prio then voice assistant stuff, hope this gets picked up / noticed by core team soon)

purcell-lab commented 3 months ago

1 July was problematic for me: https://github.com/home-assistant/frontend/issues/13701#issuecomment-1669041508

Screenshot_20240310-064402

Home Consumption = Solar Total + Battery Total + Grid Total 13.2 kWh = 50.6 + 8.2 - 45.6

But the energy dashboard shows Home as 43.1 kWh (which is also Battery Export Value, whenever battery export > actual home consumption I get these errors).

With 2024.3 Home is now showing as 10.3 kWh for 1 July so this has greatly improved.

Good work.

I'll update the issue to seek input from others.

With 2024.3, the reported household consumption is dramatically improved. Thanks @karwosts Screenshot_20240310-065101

david-rapan commented 3 months ago

Hi, not sure if it was already mentioned or not, but does it also means that others like for example Self-sufficiency indicator would be wrongly calculated because the system assumes that all battery discharging comes from solar?

I'm trying to better understand the situation cause I also noticed that the numbers don't add up. Our installation is setup in a way where we are daily charging battery during off-peak hours and thus for a lot cheaper price and then discharging in peak hours.

karwosts commented 3 months ago

If you feel you have numbers that don't add up, good idea may be to grab a CSV export (introduced in 2024.3) and upload it here for inspection.

bartowl commented 3 months ago

Great that we have CSV now. I will post the CSV file here together with images and focus on the time period 1-3PM (CET) where you can see the graph does not show solar production and weirdly adds all 3 phases as "Combined from grid" which even does not add up. So here the CSV:

entity_id,type,unit,2024-03-12T23:00:00.000Z,2024-03-13T00:00:00.000Z,2024-03-13T01:00:00.000Z,2024-03-13T02:00:00.000Z,2024-03-13T03:00:00.000Z,2024-03-13T04:00:00.000Z,2024-03-13T05:00:00.000Z,2024-03-13T06:00:00.000Z,2024-03-13T07:00:00.000Z,2024-03-13T08:00:00.000Z,2024-03-13T09:00:00.000Z,2024-03-13T10:00:00.000Z,2024-03-13T11:00:00.000Z,2024-03-13T12:00:00.000Z,2024-03-13T13:00:00.000Z,2024-03-13T14:00:00.000Z,2024-03-13T15:00:00.000Z,2024-03-13T16:00:00.000Z,2024-03-13T17:00:00.000Z,2024-03-13T18:00:00.000Z,2024-03-13T19:00:00.000Z,2024-03-13T20:00:00.000Z,2024-03-13T21:00:00.000Z,2024-03-13T22:00:00.000Z
sensor.l1_in,grid_consumption,kWh,0.2584999999999127,0.7210000000000036,0.6486999999999625,0.0025000000000545697,0.0027000000000043656,0.0028999999999541615,0.06619999999998072,0.13160000000016225,0.1973000000000411,0.213799999999992,0.13169999999990978,0.06420000000002801,0.03999999999996362,0.8703000000000429,0.8016999999999825,0,0,0.0019999999999527063,0.005800000000135697,0.0387999999998101,0.005100000000084037,0.003200000000106229,0.0027999999999792635,0.0029999999999290594
sensor.l2_in,grid_consumption,kWh,0.1069999999999709,0.050200000000131695,0.13249999999970896,0.12879999999995562,0.12760000000025684,0.17799999999988358,0.1950000000001637,0.15239999999994325,0.1226000000001477,0.08919999999989159,0.019800000000032014,0.0007000000000516593,0.012999999999919964,0.0003999999998995918,0.2460999999998421,0.0007000000000516593,0.0808999999999287,0.17160000000012587,0.18760000000020227,0.10140000000001237,0.06179999999994834,0.1317999999996573,0.15120000000024447,0.20010000000002037
sensor.l3_in,grid_consumption,kWh,0.1190999999998894,0.11130000000048312,0.11039999999957217,0.1099000000003798,0.25199999999949796,0.18180000000029395,0.10459999999966385,0.140400000000227,0.19099999999980355,0.3055000000003929,0.28769999999985885,0.11070000000017899,0.065799999999399,0.035899999999855936,0.026500000000851287,0.0020999999997002305,0.15619999999944412,0.2408000000004904,0.2998999999999796,0.18170000000009168,0.1768999999994776,0.15820000000076107,0.17990000000008877,0.20929999999952997
sensor.l1_out,grid_return,kWh,0,0,0,0,0,0,0,0,0,0,0,0.028500000000349246,0.025200000000040745,0.0033999999996012775,0.04370000000017171,0.7878999999998086,0.10290000000031796,0.011899999999968713,0,0,0,0,0,0
sensor.l2_out,grid_return,kWh,0,0,0,0,0,0,0,0,0,0,0.023099999999885767,0.09320000000002437,0.05590000000006512,0.30719999999996617,0.31529999999997926,0.5824000000000069,0.015100000000074942,0,0,0,0,0,0,0
sensor.l3_out,grid_return,kWh,0,0,0,0,0,0,0,0,0,0,0,0.006799999999884676,0.011700000000018917,0.23900000000003274,0.3079999999999927,0.5277000000000953,0.003500000000030923,0,0,0,0,0,0,0
sensor.bms_energy_in,battery_in,kWh,1.673569999999998,0.4139600000000101,0.3474199999999996,0,0,0,0,0,0,0,0.004239999999995803,0.07330000000000325,0.11065999999999576,1.624929999999999,1.592330000000004,0.6151499999999999,0.0037699999999958322,0,0,0,0,0,0,0
sensor.bms_energy_out,battery_out,kWh,0,0,0.4695999999999998,0.15509000000000128,0.16181999999999874,0.17390999999999934,0.11144000000000176,0,0.022839999999995086,0,0,0,0,0,0,0.17000999999999777,0.12139000000000522,0.13494000000000028,0.21470999999999663,0.3108399999999989,0.21247999999999934,0.22666000000000253,0.18999000000000166,0.18015999999999366
sensor.pv_offgrid_energy,solar_production,kWh,0,0,0,0,0,0,0,0.00999999999999801,0.02999999999999403,0.030000000000001137,0.07000000000000739,0.1700000000000088,0.2300000000000182,0.6500000000000128,0.6700000000000017,0.9699999999999847,0.12000000000001876,0.04000000000000625,0,0,0,0,0,0
sensor.pv_ongrid_energy,solar_production,kWh,0,0,0,0,0,0,0,0,0.023999999999432475,0.08799999999973807,0.13900000000103319,0.47699999999895226,0.6419999999998254,1.47400000000016,1.5300000000006548,2.375,0.2890000000006694,0.027999999998428393,0,0,0,0,0,0

Now brief description of my setup:

GRID---[grid-in/grid-out 3f meter]-----v----------v------------------------------------- HOME
                                       |          |
                  [PV]----[ongrid-solar(3f)]       \-> [ offgrid inverter/charger ] ---- HOME (dedicated 1f circuit)
                                                          |
                  [PV]-----[solar charging controller]----^---[battery with bms for battery-in/out readings]

As you can see, I have a 3 phase meter on connection point with utility grid. It measures both consumed/returned energy separate for each phase. Then I have an ongrid solar inverter (dedicated pv panels) which reports produced AC energy, that goes wither for self-consumption or can be returned to grid. This is the main power supply for most home devices.

In addition I have an offgrid inverter/charger not able to return energy to grid. It is powering critical appliances like fridge, surveillance, central heating pumps etc. It uses grid-in only for optional battery charging from grid and in case it switches into bypass mode powering its output from grid instead of battery. There is also a dedicated PV array connected directly to the battery through solar charge controller. Battery BMS can register power-in coming from either inverter charger and/or solar charge controller. On the given time frame (12:00Z and 13:00Z slots) I have manually switched the inverter into bypass mode (loads powered from GRID) and turned on charging from "grid" as my battery was really low, and there was not much sun to charge it alone from offgrid array. Due to the fact, that I had low self-consumption on l1 phase it was powered rather from on-grid array than grid-in as I would have otherwise return the excess of energy to the grid. By that i increased self-consumption factor. This is however not shown on the graphs:

image image image

My energy configuration is straight forward, 3f meter as grid-consumption and grid-production, BMS energy meters for charging/discharging attached to battery panel and both solar energies (from ongrif inverter and solar charge controller) attached as solar.

Now for the actual values for 12:00Z as calculated based on the CSV:

grid-in (l1+l2+l3): 2,53153
solar-in: 0,65(offgrid, goes directly into battery)+1,474(ongrid)=2,124
total-in: 3,0306 (from grid and solar)

grid-out: 0,5496 (this goes only from ongrid, but there are setups where it can also go from battery)

battery-in: 1,62493 (charged from solar-offgrid + solar-ongrid/grid-in)
battery-out: 0

..and for the data on the Chart for the same period:

above-0:
Combined from grid: 0,86 (blueish color)
below-0:
l1-out: -0 (purple)
l2-out: -0,31 (purple)
l3-out: -0,24 (purple)
battery-in: -1,62 (pink)

I guess I know where the error is - if you take all the produced solar (2,124), substract what was returned to grid (0,5496) and what went into battery (1,62) you end up with negative number. This seems to break things.

One could easily calculate this this way: solar-produced(total): 2,124 grid-out: 0,5496 (this may also in some scenarios go out from battery! for me this is however not the case) consumed-solar=solar-produced - grid-out = 2,124-0,5496 = 1,5744 battery-in/out has direct metrics, no calculation needed home consumed = grid-in + consumed-solar - battery-in + battery-out = 2,53153 + 1,5744 - 1,62 = 248593

It would be ideal if battery would allow to define 2 charging sources, as I have also an energy meter on grid-in at my offgrid inverter/charger and offgrid-out on the inverter AC output. Currently I calculate the battery energy on DC side based on BMS readings, without compensating of energy losses due to <100% efficiency of inverter/charger circuits. Would this all be calculated based on ac energy meters, it would be even more precise. But even that would be "precise enough" for me :)

tabascoz commented 2 months ago

Hi There, been trying to have "self-consumed solar" to display something for a long time. i think it might be related to this report. it is missing at energy dashboard, it never shows up. I inserted it manually in the home dashboard and i get the message: "self-consumed solar couldn't be calculated"

My setup:

I have Battery power charge/discharge series by using Riemann sum. Grid import values are using Energy meter, which i have two series per inverter to control peak/offpeak values.

In Energy dashboard, all other values seems OK, as so it they are in Energy Usage.

I read many times about the Last_reset values, they are present in Growatt Grid series. I took care of them by using customize_glob and setting them to 1970-01-01T00:00:00+z00:00. Tried setting to null, but nothing really made any difference.

I appreciate the support and pointing me to the right direction, as i believe it might be a bug.

Screenshot from 2024-04-05 22-30-12

Screenshot from 2024-04-05 22-30-30 Screenshot from 2024-04-05 22-30-58

energy(2).csv

Ben00793 commented 2 months ago

@tabascoz

I'm no expert, but i think the problem here is that you don't have a grid return sensor configured. If you don't have that sensor available from the mqtt, you need to create a sensor in the configuration.yaml that is just 0 all the time. Like this:

template:        
- sensor:
      - name: "grid_energy_out"
        unit_of_measurement: "kWh"
        state_class: total_increasing
        device_class: energy
        state: 0

Let me know if it works!

tabascoz commented 2 months ago

@tabascoz

I'm no expert, but i think the problem here is that you don't have a grid return sensor configured. If you don't have that sensor available from the mqtt, you need to create a sensor in the configuration.yaml that is just 0 all the time. Like this:

template:        
- sensor:
      - name: "grid_energy_out"
        unit_of_measurement: "kWh"
        state_class: total_increasing
        device_class: energy
        state: 0

Let me know if it works!

Yep you got it! Many thanks! so easy and yet I was struggling, sometimes when it's easier we try to find complicated solutions (lol).

Still some advice it would be nice to have the documentation describing it. I am not sure if this entity should really be required to show this card.

There are an increasing number of people going to hybrid generation and they might struggle with this as well.

Many thanks once more !!!!

Cheers, Fernando

gurmukhp commented 2 months ago

I'm also having the issue where battery charged from the grid is shown incorrectly in the graph.

Given this has been open for a while, do we have an idea of who might fix it and when?

langestefan commented 2 months ago

I'm also having the issue where battery charged from the grid is shown incorrectly in the graph.

Given this has been open for a while, do we have an idea of who might fix it and when?

There has been an update to the calculation logic recently, have you updated to the most recent version of HA?

gurmukhp commented 2 months ago

I'm also having the issue where battery charged from the grid is shown incorrectly in the graph. Given this has been open for a while, do we have an idea of who might fix it and when?

There has been an update to the calculation logic recently, have you updated to the most recent version of HA?

Thanks, I didn't have the April update, I've now installed and will monitor over the next few days.

Ben00793 commented 2 months ago

I'm also having the issue where battery charged from the grid is shown incorrectly in the graph. Given this has been open for a while, do we have an idea of who might fix it and when?

There has been an update to the calculation logic recently, have you updated to the most recent version of HA?

Thanks, I didn't have the April update, I've now installed and will monitor over the next few days.

I have the April update. Nothing changed. Screenshot_20240415-155359

david-rapan commented 2 months ago

0410_250324

Why it says "Total returned"? What does that mean? It is from charging the battery.

Edit: I'm using the latest version of HA.

gurmukhp commented 2 months ago

I'm also having the issue where battery charged from the grid is shown incorrectly in the graph. Given this has been open for a while, do we have an idea of who might fix it and when?

There has been an update to the calculation logic recently, have you updated to the most recent version of HA?

Gave it a whirl, I'm not sure it makes sense. For the first bar, it says Day Grid Import 0.3kwh, Day battery charge 1.3kwh. That to me means that I took 1.6kwh from the grid. However the chart says I returned 1.3kwh to grid. I didn't, I exported nothing during that time period.

Screenshot_20240415-223110

Ben00793 commented 2 months ago

I'm also having the issue where battery charged from the grid is shown incorrectly in the graph. Given this has been open for a while, do we have an idea of who might fix it and when?

There has been an update to the calculation logic recently, have you updated to the most recent version of HA?

Gave it a whirl, I'm not sure it makes sense. For the first bar, it says Day Grid Import 0.3kwh, Day battery charge 1.3kwh. That to me means that I took 1.6kwh from the grid. However the chart says I returned 1.3kwh to grid. I didn't, I exported nothing during that time period.

Screenshot_20240415-223110

Any negative value on the chart is either returned to the grid or returned to the battery. If it is purple it went back to the grid, if pink it went back to the battery. It can either came from the solar or from the grid.

gurmukhp commented 2 months ago

I'm also having the issue where battery charged from the grid is shown incorrectly in the graph. Given this has been open for a while, do we have an idea of who might fix it and when?

There has been an update to the calculation logic recently, have you updated to the most recent version of HA?

Gave it a whirl, I'm not sure it makes sense. For the first bar, it says Day Grid Import 0.3kwh, Day battery charge 1.3kwh. That to me means that I took 1.6kwh from the grid. However the chart says I returned 1.3kwh to grid. I didn't, I exported nothing during that time period. Screenshot_20240415-223110

Any negative value on the chart is either returned to the grid or returned to the battery. If it is purple it went back to the grid, if pink it went back to the battery. It can either came from the solar or from the grid.

That's where it's broken. It didn't "return to the battery", it got it from the grid and charged the battery. Because of this, the bar should be above the x axis. It's exactly how the SunSynk and Victron apps show energy consumption in their apps.

langestefan commented 2 months ago

I'm also having the issue where battery charged from the grid is shown incorrectly in the graph. Given this has been open for a while, do we have an idea of who might fix it and when?

There has been an update to the calculation logic recently, have you updated to the most recent version of HA?

Gave it a whirl, I'm not sure it makes sense. For the first bar, it says Day Grid Import 0.3kwh, Day battery charge 1.3kwh. That to me means that I took 1.6kwh from the grid. However the chart says I returned 1.3kwh to grid. I didn't, I exported nothing during that time period. Screenshot_20240415-223110

Any negative value on the chart is either returned to the grid or returned to the battery. If it is purple it went back to the grid, if pink it went back to the battery. It can either came from the solar or from the grid.

That's where it's broken. It didn't "return to the battery", it got it from the grid and charged the battery. Because of this, the bar should be above the x axis. It's exactly how the SunSynk and Victron apps show energy consumption in their apps.

I wouldn't call that broken. It's a choice, it doesn't make the numbers wrong. But I understand that charging the battery can be seen as consumption and hence it should be positive. My guess why battery consumption was made negative is to separate it from house consumption.

tbrasser commented 2 months ago

that just doesn't make sense, if that's the reasoning then we still need a distinction between house and 'total'.

this will allow for all setups and all calculations (like solar being dc connected to battery and the inverter sitting between grid and house load)

langestefan commented 2 months ago

I dont see how that doesnt make sense. You want to see what the house is doing

david-rapan commented 2 months ago

I think I understand the reasoning behind it all now and why is it made like that but it really is hella confusing for anyone seeing the numbers for the first time. That does not make it wrong or not making sense just that it should be explained. Just saying.

langestefan commented 2 months ago

I think I understand the reasoning behind it all now and why is it made like that but it really is hella confusing for anyone seeing the numbers for the first time. That does not make it wrong or not making sense just that it should be explained. Just saying.

Sure. But that discussion is derailing this entire issue, they are different problems and not related to wrong calculations.

nickwinger commented 3 weeks ago

+1