Shelly 3EM 3-phases Energy sensor

I wasn’t able to bring the energy integration back to work after the upgrade. I decided to restore a full backup. :frowning:
It started to work within seconds with the old version of HA

Even changing to “total_increasing” didn’t help.

  - sensor:
    - name: "Hausanschluss"
      unique_id: energy_total
      state: >-
        {{ states('sensor.shelly3em_hausanschluss_channel_a_energy')|float + 
           states('sensor.shelly3em_hausanschluss_channel_b_energy')|float + 
           states('sensor.shelly3em_hausanschluss_channel_c_energy')|float }}
      unit_of_measurement: kWh
      device_class: energy
      state_class: measurement
      attributes:
        last_reset: "1970-01-01T00:00:00+00:00"

My power sensor was not affected… :woozy_face:
Anyone else facing similiar problems?

I think that “total_increasing” is a better choice.
You might need to wait a few hours after making the change (the statistics engine has a built-in latency).
A good post which explains the difference between “total_increasing” and “measurement” can be found here. Based on this post, it seems that “measurement” is not an option anymore, but maybe “total” can be used in a combination with “last_reset” (but I didn’t test it as we use “total_increasing”.)
(BTW, we use the sensor as it’s defined at the top of this thread, here, and it’s working well with 2022.2.2.)

1 Like

:thinking:

  - sensor:

space,space

  - sensor:
      - name: "Hausanschluss"
        unique_id: energy_total
        state: >-
          {{ states('sensor.shelly3em_hausanschluss_channel_a_energy')|float + 
             states('sensor.shelly3em_hausanschluss_channel_b_energy')|float + 
             states('sensor.shelly3em_hausanschluss_channel_c_energy')|float }}
        unit_of_measurement: kWh
        device_class: energy
        state_class: measurement
        attributes:
          last_reset: "1970-01-01T00:00:00+00:00"

I had no issue, but i used before 2020.9 and use state_class: total_increasing

Thank you very much for your advice.
Your sensor is working with 2022.2.3 without any problems.
I still have a lot to learn and read :slight_smile:

1 Like

Hi,

I have created new Net metering templates using the power sensors that update every second for best accuracy!

1 Like

Hi! I am in the same boat as you, we have a delta connection as well. Although I can count the the amperages to be correct. Shelly shows a negative power factor (-0.59) on the 3rd phase, a 0.2 on the 1st and .99 on the 2nd. Voltages are A - 123, B - 120, C - 207.

Got it powered on by connecting neutral to a ground wire.

Hope i got something wrong that somebody here can tell me, but as far as i can tell, all wires and clamps were correctly installed. A to A, B to B, C to C.

I also have solarman integration and it works perfectly with the same setup. (inverter also has to be connected to a neutral - where i used the same ground wire as shelly 3em)

1 Like

Thanks a lot for the feedback. So you are indeed getting strange readings.
According to the drawing Neutral wire seems to be optional. So strange that you had to connect it to a ground wire. I wouldn’t be surprised if that creates the problem.

The Neutral Clamp is optional, not the Neutral wire!!!

See here for more info on how to connect using the 2 watt meter method

Yes, that’s correct. Shelly won’t turn on without a neutral wire, or in my case the ground wire. Clamp readings are accurate though as far as i can tell. Will be replacing it with vue soon anyway. Hope they can fix this through software - the negative readings.

Also, here’s hoping emporia vue will cooperate with Home Assistant soon.

The Emporia vue does not support Delta!!
They have no plans to support anything other than the cloud.
I have just been down this path, the shelly is the best supported 3 phase with HA.
Use the 2 watt meter method for Delta.

Just wired up vue, it seems to be running ok (same with shelly using ground as neutral). Can’t see voltages but can see consumption in amps. Interface leaves a lot to be desired. Would be happy with a bigger web interface than the app, specially as i’m monitoring 18 clamps.

Today made a simple energy dashboard - can’t get decent metrics on HA Energy because shelly showing my consumption as a negative. I now use amperes to see usage instead of kwh - then use influxdb, maybe i can then just multiply by fixed voltage to get my total consumption.

I agree, although Emporia vue is really cheap, can measure a lot with 1 device, and easy to wire, but shelly 3em can integrate with HA, which i really need since it’s makes it easy to see and compare everything in one glance.

Newbie question.
How do I calculate total energy consumed by my house if I have Solar panels?

 a + b + c + (-a returned) + (-b returned) + (-c returned) + solar energy.

Is that correct? Because if my shelly sits before all appliances, the energy a+b+c readings from shelly do not include energy consumed by the house which was produced with solar?

Hi @gerasalus,

HA can calculate that for you.
You have L1, L2 and L3 for energy consumption and the same for “energy_return” in the entities. (L… are the phases)
You can set all in the energy dash and then you are good to go.
Or maybe I missunderstood you and you are looking for a code?

In my case for example, I summarize all three phases together using that code in a template.yaml file:

- sensor:
    - name: "Energy Total"
      unique_id: energy_total
      state: >-
        {{ states('sensor.phase_1_energy')|float(0) + 
           states('sensor.phase_2_energy')|float(0) + 
           states('sensor.phase_3_energy')|float(0) }}
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing
      attributes:
        last_reset: "1970-01-01T00:00:00+00:00"
      availability: >
          {{ not 'unavailable' in 
             [ states('sensor.phase_1_energy'), 
               states('sensor.phase_2_energy'),
               states('sensor.phase_3_energy') ] }}
    - name: "Power Total"
      unique_id: power_total
      state: >-
        {{ (states('sensor.phase_1_power')|float(0) + 
            states('sensor.phase_2_power')|float(0) + 
            states('sensor.phase_3_power')|float(0)) }}
      unit_of_measurement: W
      device_class: power
      state_class: measurement
      availability: >
          {{ not 'unavailable' in 
             [ states('sensor.phase_1_power'), 
               states('sensor.phase_2_power'),
               states('sensor.phase_3_power') ] }}


Info: My WIFI gets deactivated during nighttime. Therefore there is no recording and a “peak” at the beginning of each day.

The only thing I am wondering is, that even I generate more energy than I am currently using, I still can see a consumption. I thougt, this might be because of a peak but I can´t see any:

Solar Panel feed (Shelly Plug S):

Summarized power consumption (Shelly 3EM):

Maybe somenbody has an idea what the issue might be here :wink:

Cheers and enjoy your weekend guys.

4 Likes

Hi,
I am quite new to HA (3-4- weeks) and I still have very limited skills even if I have read tons of posts.
I have photovoltaic panels and an electric car with bidirectional charging capacity. So my car is used as a battery for my home.
I have just installed 2 Shelly 3EM: The first one measures the energy imported/exported from the grid and the second one measures the energy flow between the car (battery) and my home.
I also have access to the energy values from the inverter.
My question is about the total (3 phases) energy measured by the Shelly devices.
The calculation kindly provided in this thread is: Total Energy = Energy L1 + Energy L2 + Energy L3. So far so good.
Shelly 3EM provides two sensors per phase according to the direction of the energy flow. One sensor is “imported energy” and the other one is “exported energy”. OK.
Now my real concern:
My understanding is that these sensors always have positive (or increasing as they are sums) values.
Now imagine the following caricatural situation:
My home consumes 2kW during 1 hour, ie 2kWh, exclusively from phase L1.
My battery provides this energy but exclusively on phase L2.
So, formally I have imported 2 kWh from the grid on L1 and exported 2 kWh to the grid on L2.
The net flow is zero kWh and (I hope) my electricity provider will charge 0$.
But the calculated energy measured by Shelly will be: 2kWh imported and 2kWh exported.
As I pay 25 cts/kWh for imported energy and I receive only 8 cts/kWh for exported energy, the cost calculation in HA will be 2x25-2x8 = 34 cts, which is wrong.
Besides, I am interested by the net instant flow of energy.

Did I miss anything?

I hope my text was understandable despite my limited english.

1 Like

I live in a very old house and the wiring is not the newest.

I found out that the power supply system is a TN-C system. Does the shelly 3em work with this kind of system?

Since the most complete version is somewhere in this thread, here is my solution after going through the whole discussion:

template:
  - sensor:
    - name: "Energy Total"
      unique_id: energy_total
      state: >-
          {{ 
            [ states('sensor.shellyem3_channel_a_energy'), 
              states('sensor.shellyem3_channel_b_energy'),
              states('sensor.shellyem3_channel_c_energy'),
            ] | map('float') | sum
          }}
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing
      attributes:
        last_reset: "1970-01-01T00:00:00+00:00"
      availability: >-
          {{ 
            [ states('sensor.shellyem3_channel_a_energy'), 
              states('sensor.shellyem3_channel_b_energy'),
              states('sensor.shellyem3_channel_c_energy'),
            ] | map('is_number') | min
          }}
    - name: "Power Total"
      unique_id: power_total
      state: >-
          {{ 
            [ states('sensor.shellyem3_channel_a_power'), 
              states('sensor.shellyem3_channel_b_power'),
              states('sensor.shellyem3_channel_c_power'),
            ] | map('float') | sum
          }}
      unit_of_measurement: W
      device_class: power
      state_class: measurement
      availability: >-
          {{ 
            [ states('sensor.shellyem3_channel_a_power'), 
              states('sensor.shellyem3_channel_b_power'),
              states('sensor.shellyem3_channel_c_power'),
            ] | map('is_number') | min
          }}
    - name: "Current Total"
      unique_id: current_total
      state: >-
          {{ 
            [ states('sensor.shellyem3_channel_a_current'), 
              states('sensor.shellyem3_channel_b_current'),
              states('sensor.shellyem3_channel_c_current'),
            ] | map('float') | sum
          }}
      unit_of_measurement: A
      device_class: current
      state_class: measurement
      availability: >-
          {{ 
            [ states('sensor.shellyem3_channel_a_current'), 
              states('sensor.shellyem3_channel_b_current'),
              states('sensor.shellyem3_channel_c_current'),
            ] | map('is_number') | min
          }}

6 Likes

When copying and pasting exactly this, I get “Unavailable” for all sensors. Anybody an idea why?
I don’t see anything related to that anywhere (Logbook, History etc). The Shelly 3EM itself is working fine in HA, also the energy board.

Hope you solved it by now. If not: Did you make sure to adjust sensor.shellyem3_channel_ to your setup? Search the entities for 3em to find the correct naming.

1 Like

Thanks, yes. It took me a while but I solved it.
What was it? My Shelly 3em sensors were named slightly different than the above :roll_eyes::roll_eyes:
So one really has to pay attention and not just assume that all will be named identical

1 Like