Shelly Pro 3EM with PV = confusing energy dashboard results

Hello there, we got a balcony PV station and yesterday got the Shelly Pro 3EM and installed it.
But now the energy configuration seems a bit wrong…
As you can see in the picture below, there are massive energy returns to the grid, according to the shelly, but the shelly also counted used energy from the grid up… should it not have used the available solar energy for that?
Is this just a UI error, or is our connection messed up somewhere…
We have double-checked the clamps yesterday already, and they all seem to point into the right directions


Here are some more screenshots of the energy dashboard config and the Shelly Pro 3EM device view

Any help is appreciated :smile:

That is, sadly, to be expected in this scenario.

The import and export measures are not summed up in the Shelly and the inverter trying to match the grid will cause energy to flow back and forth on a by-halfwave basis all the time.

You need a measuring solution that combines the export and import over time, like your grid meter does. This can be done based on the data the Shelly reports, but there’s nothing in HA that does it out-of-the-box.

As much as I recommend Shelly devices, they are not suitable to duplicate a grid meter. Get an IR reading head for your meter instead, that will give you way better results. There will still be some oddities as the meter will report in delayed bursts instead of continuously, but the result will be much better.

Hey, thanks for the quick reply :slight_smile:

Can you maybe explain if it would be possible to create a Helper sensor using the Shellly values to get the positive summation of export and usage?
And when i have it, would the sensor be a replacement for “Grid Consumption” and fix the graph issue, or do i need to move a bit more things around?

1 Like

I’m not sure a simple helper can do that, but I don’t claim to be an expert in all HA can do.

What needs to be done is to take the summed up meter values and, at a time interval, calculate their difference to the last reading. Then, that needs to be summed up between those two meters and put either to consumed or exported.

For example, given you have these readings:

09:00 raw_import=463.04kWh raw_export=84.94kWh
09:30 raw_import=464.48kWh raw_export=85.03kWh
10:00 raw_import=464.88kWh raw_export=88.55kWh

If you plug this directly into HA, it will tell you:

09:00-10:00 import=1.84kWh export=3.61kWh

But what you want is:

09:00 import=0kWh export=0kWh
09:30 import=1.35kWh export=0kWh
10:00 import=1.35kWh export=3.12kWh

(I’m using half-hour segments to make it easier for me to calculate the example, in real life you want either 5 or 15 minute segments.)

In pseudo code:

  import_diff = raw_import[now] - raw_import[last]
  export_diff = raw_export[now] - raw_export[last]
  if (import_diff > export_diff) {
    import_diff = import_diff - export_diff
    export_diff = 0
  } else {
    export_diff = export_diff - import_diff
    import_diff = 0
  }
  import[now] = import[last] + import_diff
  export[now] = export[last] + export_diff

As you see, you need to calculate 2 new values based on the current values of 2 sensors and the past values of 4. I don’t think templated helpers can do that, they calculate 1 value based on any number of current values but cannot look into the past.

Maybe someone else reading this has an idea how to do that? (hint, hint, nudge, nudge)