Shelly 3EM 3-phases Energy sensor

Try to reset your counters for energy and energy returned. Most likely is the energy that was counted before you fixed the wiring on the shelly (when you had readings of negative power the returned energy counter increased).
Don’t know which loads you have but seems unlikely that you returned > 100 kWh in a day.

1 Like

@gfra Not worked out how to reset yet, but i can see the figures are static so your idea will be the issue, thanks.

1 Like

Hi, i’am a greenhorn, but i think i have with your hint’s add my Shelly 3EM with small PV over Shelly 1PM add to HA.
But how long the default config from HA save the data???
You can have a look at my config, i’m not sure that the last is correct.

- sensor:
  - name: "HSW71 Power Total"
    unique_id: hsw71_power_total
    unit_of_measurement: W
    device_class: power
    state_class: measurement
    state: >-
      {{ (states('sensor.l1_power')|float + 
          states('sensor.shelly1pm_01_power')|float +
          states('sensor.l2_power')|float + 
          states('sensor.l3_power')|float) }}

  - name: "HSW71 Power Factor Total"
    unique_id: hsw71_power_factor_total
    unit_of_measurement: "%"
    device_class: power_factor
    state_class: measurement
    state: >-
      {{ (((states('sensor.l1_power')|float) * (states('sensor.l1_power_factor')|float) +
            (states('sensor.l2_power')|float) * (states('sensor.l2_power_factor')|float) +
            (states('sensor.l3_power')|float) * (states('sensor.l3_power_factor')|float)) /
            (states('sensor.l1_power')|float + states('sensor.l2_power')|float + states('sensor.l3_power')|float)) |int }}

  - name: "HSW71 Energy Total"
    unique_id: hsw71_energy_total
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    attributes:
      last_reset: "2021-01-01T00:00:00+00:00"
    availability: >-
      {{ not 'unavailable' in 
        [ states('sensor.phase_a_energy'), 
          states('sensor.phase_b_energy'),
          states('sensor.phase_c_energy'),
        ] | map('is_number') | min }} 
    state: >-
      {{ states('sensor.l1_energy')|float -
        states('sensor.shelly1pm_01_energy')|float +
        states('sensor.l2_energy')|float + 
        states('sensor.l3_energy')|float }}

  - name: "HSW71 Energy Total returned"
    unique_id: hsw71_energy_total_returned
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    state: >-
      {% set all_ret = states('sensor.l1_energy')|float  + states('sensor.l2_energy')|float + states('sensor.l3_energy')|float %}
      {% if is_number(all_ret)|float > 0 %}
        {{ 0 }}
      {% else %}
        {{ all_ret }}
      {% endif %}

3EM messure all, consumption and feed, when you have PV on L1 and L1 has negative value, 3EM count negative (returned) but at all L1+l2+L3 is positiv… so i have correct this with value from 1PM.
Who do you think is that programmed correctly?

If you are using Shelly cloud you can check the returned energy there as well, on a daily basis.

Hi guys again,
I have two shelly 3em sensors, one outside the inverter of my solar panels, one before the house consumption. I made them defining like posted above, they arr working great. Now, in order to insert the correct values to the energy section of home assistant I need to define the grid consumptions and feed in energy. Infact the shelly 3em which is before the house consumption is not looking the grid consumptions but the grid consumptions plus, eventually the solar production. So basically I need to define two sensors from this equation:

solar panel production - house consumption= if positive, it’s the feed in energy, if negative instead grid consumption.

How can I do?

Thanks for your config.

A quick question:
Can I set my consumption value prior to installing the 3EM to the amount starting value? Or can I add the amount to the sensor values?

1 Like

You don’t need the old value. The consumption calculations are based on the difference between 2 reads of this entity (e.g. the amount consumed in a particular day is the difference between the value in the beginning and end of that day.)

So it’s not possible for the energy integration to show me the overall energy usage and the costs over the last year or so?

Could someone advise whether the Shelly 3EM would work in my house?
I have a special (old) type of electricity configuration coming into my house which looks like this:
image
As you can see I have no Neutral wire in my house.
My devices are not powered by one phase wire and a neutral wire. Instead they are connected to two phase wires that together deliver 230V.
My induction stove in the kitchen needs more power and uses all 3 phases combined to get 400V.

For reference here is a more regular set-up here in Europe where most devices are connected between one phase wire and the neutral wire to get 230V:
image

I have seen the wiring diagram for the Shelly 3EM, but am wondering whether the calculations it will do are correct as it might not expect devices to be connected to 2 phase wires.

Hey everyone.

I installed my shelly 3em and have a problem with one negative phase.
I double checked the clamps and the wires and phase three shows me a negative power consumption…

I live in Germany and I installed the shelly like this:



In Home Assistant I can see all sensors however the current consumption 3, so I’m guessing phase C is negative.

I tried just turning around the clamp on phase C however this led to incorrect readings as shelly 3em tells me I have used 1500 kWh in the last two days which definitely can’t be true.

What can I do?

Are you sure you have the colours right? blue is exclusively neutral. Phases 1-3 are brown / black / grey (or white)…

3 Phase Net Metering with Solar PV Production

Has anyone got three phase net metering with solar PV working with Shelly 3EM?

I located a very comprehensive blog regarding setting up Shelly 3EM on 3 Phase with Solar PV:

Problem for me is in Australia we have net-metering, which means that any energy exports on one phase are cancelled out by imports on the other phases:

Have a look at my Shelly sensors:

My single phase inverter is connected to Phase C, which is showing negative power -201W (which is the solar PV production - Phase C consumption)

My net-meter power is thus Ap+Bp+Cp = 470+1210+(-201) = 1479 W.

But as you can see my Phase C Energy Returned shows some energy being returned.

But my net-meter energy is certainly not Ae+Be+Ce-Aer-Ber-Cer = 74+39+26-16 = 123 kW.

In my case most (but not all) of the Phase C energy return will of been canceled out.

Has anyone else solved?

@anubisg1 does it works as intended? I’m in the middle of integrating Shelly 3EM (shellies discovery so MQTT) + SofarSolar inverter, would be nice to have one total entity rather than 3 phases separated.

yes it works perfectly, but since the auto discovery changed from kwh to wh, i had to had the conversion.
the latest version looks like this

  - name: "House Energy kWh"
    unique_id: sensor.house_energy_kwh
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    state: >
      {% set val1 = ((states('sensor.shelly_3em_meter_total_0')|float(0))/1000)|round(2) %}
      {% set val2 = ((states('sensor.shelly_3em_meter_total_1')|float(0))/1000)|round(2) %}
      {% set val3 = ((states('sensor.shelly_3em_meter_total_2')|float(0))/1000)|round(2) %}
      {{ val1 | float(0) + val2 | float(0) + val3 | float(0) 
        if 
          is_number(val1) and 
          is_number(val2) and 
          is_number(val3)
        else 
          None
      }}
    availability: >- 
      {{ 
        is_number(states('sensor.shelly_3em_meter_total_0')) and 
        is_number(states('sensor.shelly_3em_meter_total_1')) and
        is_number(states('sensor.shelly_3em_meter_total_2'))
      }}

I just set kWh in shellies discovery settings and reset everything so shouldn’t be a problem. You wanted to preserve historical data? Thanks for help

nothing to do with historical data, i updated the script and the sensors changed from kwh to wh, so did that change. that’s all

2 Likes

I have the Shelly 3EM enroute at the moment and have been looking at how to implement it with my 3-phase and 2 x solar single phase inverters (on different phases), with NET metering.

I found the details of the CoIot, which I think the new Shelly native integration uses here:
https://shelly-api-docs.shelly.cloud/gen1/#shelly-3em-coiot

Wondering if it would be better to use the total energy counter, which I think is an inclining counter given:

“Note, that energy and returned_energy do not survive power cycle or reboot – this is how the value is implemented on other Shellies. Shelly 3EM features a persisted version which is not affected by power cycling or lack of connectivity. To get the persisted counters use total and total_returned .”

total, number, Total consumed energy, Wh
total_returned, number, Total returned energy, Wh

So for Net metering: (*concept yaml need to turn into sensor templates once assumptions are verified)

Import:
{if (total - total_returned) > 0}
  {{(total - total_returned)}}
{else } 
  {{0}}

Export:
{if (total - total_returned) < 0 }
  {{(total - total_returned) * -1}} 
{else} 
  {{0}}

Consumption:
{if  (total - total_returned) > 0}   #importing
   {{total + solargen - total_returned}} 
 {else}
   {{solargen - total_retured + total}}   # exporting

This assumes that total does not already have the solar(total_returned) removed, solargen is total solar generation from inverters not form Shelly 3em

if total and total_returned are inclining and don’t reset daily, might have to use a utility sensor template to create one for daily. monthly etc.

Can anyone confirm the following:?
If the total and total_returnred sensors are included as part of the default Shelly core integration?
If there are total and total_returnred sensors, are they incline counters that don’t reset?
How often are the sensors updated using the Shelly core integration?

Thanks.

i can export data for 2 mounth?
i want to calc how many money i need to get bill for example
9.10.2021 - 8.12.2021
how i can do it?

I agree that using the total & total_returned would simplify, they are currently not available via the core Shelly integration, but shouldn’t be too difficult to include with future revisions of the integration. First step is to raise an issue against the current integration and then work out how to access those sensors, as they are persistent across power cycles they are pretty important to include.

I have posted my working configuration for a net metering settlement period here:

That’s an big oversight that they are not in the core integration
I wonder why they didn’t include those, maybe because they are unique to the 3EM?

How often are the sensors updated using the Shelly core integration?

Thinking MQTT might be a better option, as I have read you can get the data every second, that would increase accuracy.

I am also going to see if we can get shelly to add these NET counters to the firmware so they are accurate: total_import, total_export
Have started a thread at shelly, if you could add support that would be great.

1 Like