TotalKWH on Shelly 3EM Pro?

Hi all

Installed a Shelly Pro 3EM and integrated it. I’m a bit surprised but it looks like there is no channel totalKWH, only a returnedKWH.
What is returnedKWH exactly?
How can I record the totalKWH consumed?

In the end, I would like to record the number of KWH consumed today, this month, this year.

Thanks a lot

When activating MQTT, I get more detailed information from the Shelly, but it’s a bit cryptic to me. Usually, the events/rpc topic returns the usual values for all 3 phases like power, voltage etc.:

  "params": {
    "ts": 1715444140.64,
    "em:0": {
      "id": 0,
      "a_act_power": 242.5,
      "a_aprt_power": 320.3,
      ...

But once in a while, a different message appears:

"params": {
    "ts": 1715443980.67,
    "events": [
      {
        "component": "emdata:0",
        "id": 0,
        "event": "data",
        "ts": 1715443920,
        "data": {
          "ts": 1715443920,
          "period": 60,
          "values": [
            [
              3.7814,
              3.7826,
              0,
              0,
              0,
              2.5151
              ...

A long list of values follows. The first one (3.7814) i.e. is the “Energy last minute” I can see on the web interface of the Shelly:
image

So I could listen to these messages once a minute, extract the correct values from the array and use that to accumulate the total energy used. And hope, the array structure never changes…

Think there has to be a better solution I haven’t found yet :thinking:

I installed 4.2.0.202405241838 as mentioned in
https://community.openhab.org/t/shelly-binding/56862/3771
on April 1st on my Openhab 4.1.2.
with

update org.openhab.binding.shelly https://github.com/markus7017/myfiles/blob/master/shelly/org.openhab.binding.shelly-4.2.0-SNAPSHOT.jar?raw=true
in the console.

You have to activate “Show advanced” in the channel section to see accumulatedWatts, accumulatedWTotal and accumulatedReturned

Thanks! I see the three channels you mention, but they still don’t make any sense to me.
i.e. accumulatedReturned is currently at 2.419 kWh.
What does that mean? Accumulated over which period?
Now it just changed to 2.402 kWh. :thinking:

And in some other threads / GitHub Issues I saw the mention of a channel called “totalKWH” but I can’t find that one.

I am having the same problem.

accumulatedWatts makes sense, it seems to be the sum of the power of the three phases, taking into account the phase shifts.

My 3EM measures the total power used by our heat pump. Yesterday I was heating the buffer.

All three peaks showed more or less the same shape, ranges were:
accumulatedWatts starting with 1700 W going down to 1200 W
accumulatedWTotal starting with 0,007 kWh down to 0,005 kWh
accumulatedReturn starting with 1,8 kWh down to 1,3 kWh

It seems to me that the two values show energies averaged over a period of time, maybe 1 min. accumulatedReturn is used if you want to regulate “Nulleinspeisung” and “Netzbezug” in PV-systems.

It seems that if you want to have a real accumulated energy starting from the beginning you either have to use shelly cloud or you have to monitor the shelly regularly (e.g. via modbus) an aggregate on your own.

I solved the problem by using MQTT.
I enabled MQTT on my pro 3EM with
MQTT prefix SH3em
and activated Generic status update over MQTT

In MQTT Explorer you find:

Sh3em:status:emdata:0

total_act shows the total energy in Wh.

Then I configured MQTT Broker and MQTT-client in Openhab,
in MQTT-Client added a channel

3EM_Totalact

with State topic

SH3em/status/emdata:0

and after activating “Show advanced”
Incoming value transformation

JSONPATH:$.total_act

You have to install JSON Path Transformation via App Store to use that.

Then you can add an Item to this channel.

YES! Thanks a lot for that, looks promising!

Because it’s Wh, you have to define the unit on the item. Took me a moment to figure out:

Number:Energy Shellypro3EmTotalAct  "Shellypro3em total act"   {unit="Wh", channel="mqtt:topic:localbroker:shellypro3em:3EM_Totalact"}

At first glance, the values make sense :slight_smile: Will check the coming days and compare them with the Shelly App.

Hey guys any update on this should be nice to have an total increasing value in Shelly.

Hi,

Unfortunately, Shelly doesn’t provide the actual consumption/generation totals (cumulative) directly, provided energy generation is taking place.

I’ve gone the route of integrating the values ​​from the power values ​​provided by Shelly myself. To do this, I call a rule every second, and after calculating the totals for the three phases, a decision is made based on the sign to sum either the consumption total or the generation total.

It works quite well, but of course there are slight deviations from the energy supplier’s consumption meter.

If you measure, you measure wrong (wer misst misst mist!).