Shelly 3EM + utility_meter + feeding to the grid

I’ve been using Shelly 3EM with more or less success together with utility_meter now for several month. Due to 3EM reporting ZERO kWh several times a day when the 3EM becomes UNAVAILABLE (no idea why, as it got perfectly fine Wifi connection), I had to make quite complicated templates to sort out those ZERO values and filter them so utility_meter sees a growing number all the time and doesn’t freak out.

So far so good.

Now I got a photovoltaik system installed, and it’s feeding BACK into the GRID. This of course would make the total kWh consumed smaller. A no-go for utility meter. And I go some “negative” power shown.

How do ppl solve this? How can I still get daily, weekly, monthly, yearly numbers of energy consumed (and fed back into the grid)?

My single phase Shelly EM (dual CT monitor) has a total kWh counter that does not decrease when power is fed back into the grid. There is another sensor called total_returned that goes up when this happens. Not sure if it is the same for the 3EM.

The sensor name for the returned energy is:

sensor.shelly_em_channel_1_energy_returned

Both of these only go up:
<ipaddress>/status:
Untitled

Thanks. You’re right. I forgot about those entities as I didn’t have a solar system when I installed the 3EM.
Stupid thing is, that the 3EM still doesn’t give TOTAL VALUES and you still need to sum them up separately.

image

Seems I really need to rework my templates as it still reports 0kWh several times a day. :frowning:

If you setup your utility meters net_consumption as false they can’t run backwards.
I use a template to capture anything negative and turn it into a positive value for grid export.

    total_returned_power:
      value_template: >
        {{ (states('sensor.total_utility_power')|float 
        * (-1)|float)| round(2) }}
      friendly_name: 'Total Returned Power'
      unit_of_measurement: 'W'

I use HA to track energy consumption/production. Only using ShellyEM for power and voltage readings.

If you share the template sensor configuration you are using to sum the three phases I think I can fix the zeros with an availability template.

Not just add, I’m quite sure that you have to divide the result with SQRT(3) to get the actual amount that the electrical company registers (note that this is a good thing, less energy spent!).

Pretty sure the EM3 voltage is measured with respect to neutral, so the powers can just be summed. No SQRT(3) required.

Pø = Vø Iø cosθ

If it measures line to line voltage then SQRT(3) is required.

Wye:

Wye-connected-load-formula

I noted that the values I got was way higher than what the meter said when I just added the 3 phases energy output. Found an answer on Shelly´s own forum that they cannot just be summed up (Total Kwh in Phases - Shelly 3EM - Offizielles Shelly Support Forum).

Dividing them with SQRT(3) makes the output within a few percent from what I’m invoiced but please if someone can confirm it or not do so. I will for sure keep my settings since the sum doesn’t really give me any valuable info at all. However it could be that my neutral isn’t any neutral at all…

Then they must be doing this:

If it helps somebody, here’s my calculation and it will also take care of the “unavailble” problem that the thread starter had (been there to :slight_smile: ):

        consumed_energy:
          friendly_name: "Total Consumption"
          device_class: energy
          unit_of_measurement: 'kWh'
          value_template: "{{ ((states('sensor.em_channel_a_energy')|float + states('sensor.em_channel_b_energy')|float + states('sensor.em_channel_c_energy')|float)/sqrt(3))|round(2) }}"
          availability_template: "{{ not ( is_state('sensor.em_channel_a_energy', 'unavailable') or is_state('sensor.em_channel_b_energy', 'unavailable') or is_state('sensor.em_channel_c_energy', 'unavailable') ) }}"

Excellent. Thanks. I’ll try it out. And can compare to the simply sum up of all three.

Yes, please do, it would be very interesting if you are able to get the actual values from your meter and compare.

I noticed that you have installed solar panels and as you probably know you have different sensors for energy feed back to the grid. Depending on where your clamps are mounted you might be able to see the produced energy (ie you must have the clamps mounted directly to the grid phases).

I installed my clamps directly between the external power company’s meter and my house. So everything that comes in/out is counted. My PV inverter has it’s own API and spits out numbers, as well as the little battery.
With all this installed there is a little more brain needed to show correct numbers and configure the sensors correctly.

Hmmmmm. Added Spitfire’s sensor, and results are completely different!!
The simple sum up gives around 9.800kWh and the new sensor is 5.700kWh. That’s a difference of 170% (!!). Can that be possible?

I’ll get a smart meter installed in 2 weeks, so will be able to check “real” kWh used more easily.

Yes, the difference is 73% (since it’s divided with SQRT(3)) so you got the numbers right. I guess since you have mounted the clamps as you did it should be easypeasy to enter the values in the energy integration. Just make one sensor for consumed and one for produced.

So returned capacity will be 70% less as well, right?
Using the Shelly app: Does the app sum up capacity correctly? You got all the statistics there, but as Shelly is not pushing out sums it’s hard to compare.

Yup, sorry for that :wink:

I have no clue about the Shelly app, have not made any comparison myself. I use the data my electrical company delivers back to me and compare with those . With this calculation it’s around 3% difference, by adding the value’s as they where…you guessed it…70% wrong.

1 Like

It does actually have a total.

Go to this address in your web browser and scroll down and look for total_power:

<shelly_ip_address>/status

That would be amazing as it would reduce my bill by - you guess it - 70% (almost, as there’s monthly fees etc as well) :wink:

How are you using the Shelly 3EM?

MQTT?

Because the core integration has this total power value, at least it does for the Shelly EM, I don’t have an EM3.

You can get that total using a rest sensor, but it’s a lot of mucking about. Switch over to using the core integration and make your like easier.