Utility meter with shelly 3em doesnt seem to be correct

Hi ,

I bought a shelly 3em to collect my energy/power usage. Shelly itself seems to be working and be pretty accurate.

It is installed on my 3 phases but inside HA I just want to see the total energy consumption.

I’ve created the following utility_meter

utility_meter:
  daily_energy:
    source: sensor.power_total
    cycle: daily
    tariffs:
      - mono

And some sensors where
power_total - getting all 3 phases into a single value.
energy_daily_usage - shows the utility_meter daily_energy_mono in kwh.

sensor:
  - platform: template
    sensors:
      power_total:
        friendly_name: 'Strømforbrug lige nu'
        value_template: "{{(
          (
            states('sensor.stue_kokken_vaerelser_power') | float + 
            states('sensor.badevaerelse_gang_power') | float + 
            states('sensor.teknik_kol_vask_power') | float 
          ) 
        )}}"
        unit_of_measurement: "wh"
  - platform: template
    sensors:
      energy_daily_usage: 
        value_template: "{{(( states('sensor.daily_energy_mono') | float * 1 / 1000) | round(1) )}}"
        friendly_name: 'Strømforbrug/Dag'
        unit_of_measurement: 'kwh'

Here are the sensors

unit_of_measurement: W
friendly_name: Stue-Køkken-Værelser Power
device_class: power

unit_of_measurement: W
friendly_name: Badeværelse-Gang Power
device_class: power

unit_of_measurement: W
friendly_name: Teknik-Køl-Vask Power
device_class: power

It’s all great and have been running for some days now , but …
right know at 11’o clock my sensor energy_daily_usage says I’ve used 6KWH - I guess that should be from midnight? so 11 hours of consumption?
shelly however says i’ve used 3KWH the last 24H

the power_total sensor seems to be correct. Says the same as shelly itself.

What am I missing ?

BONUS QUESTION: How do I reset the utility_meter? I’ve been looking at the documentation but I need a little more help.
The “remove it from config, restart, and add it back in” doesnt seem to be working - it remembers

While I was writing the post I was wondering if it is because I specified that power_total is unit_of_measurement: “wh” but the shelly sensors is unit_of_measurement: W ?

The utility meter has to be used with energy sensors, (kWH) not power sensors (W).

hi @tom_l ,

So what you are telling me is that utility meter can calculate the derivative between values stored in ex. sensor.badevaerelse_gang_energy

unit_of_measurement: kWh
friendly_name: Badeværelse-Gang Energy
device_class: energy

So if I create utility meters for each phase’s kwh entity like this:

utility_meter:
  daily_energy_phase1:
    source: sensor.badevaerelse_gang_energy
    cycle: daily
    tariffs:
      - mono
  daily_energy_phase2:
    source: sensor.stue_kokken_vaerelser_energy
    cycle: daily
    tariffs:
      - mono
  daily_energy_phase3:
    source: sensor.teknik_kol_vask_energy
    cycle: daily
    tariffs:
      - mono

and then do like this

- platform: template
    sensors:
      energy_daily_usage: 
        value_template: "{{(
          (
            states('sensor.daily_energy_phase1_mono') | float + 
            states('sensor.daily_energy_phase2_mono') | float + 
            states('sensor.daily_energy_phase3_mono') | float 
          ) 
        )}}"
        friendly_name: 'Strømforbrug/Dag'
        unit_of_measurement: 'kWh'

I should have a correct kWh number each day?

No. All it does is watch the total energy sensor and keeps track how much it increases over the specified cycle. For this you must feed it with a strictly always increasing energy used sensor.

Use the total energy sensor from the EM3, not the daily energy sensor.

1 Like

Using the utility_meter.reset service.

If you go to Developer Tools and pick the Services tab, you can execute the service from there:

1 Like

Thanks for the answer @tom_l - I will try it out and keep an eye on it the next couple of days .

@cvester how did it go? And what configuration did you used? Mind sharing? I have the same issue that Shelly app and HA doesn’t match.

- platform: template
  sensors:
    bv_total_consumption:
      friendly_name: 'BV total consumption'
      value_template: "{{ (states('sensor.shelly_bv1_total_energy')|float + states('sensor.shelly_bv2_total_energy')|float + states('sensor.shelly_bv3_total_energy')|float)|round(3) }}"
      unit_of_measurement: "kWh"

Utility meter:

  bv_daily_consumption:
    source: sensor.bv_total_consumption
    cycle: daily

Hi @TheLordVader ,

here’s my config:

  #Electricity Daily
  daily_energy_phase1:
    source: sensor.badevaerelse_gang_energy
    cycle: daily
    tariffs:
      - mono
  daily_energy_phase2:
    source: sensor.stue_kokken_vaerelser_energy
    cycle: daily
    tariffs:
      - mono
  daily_energy_phase3:
    source: sensor.teknik_kol_vask_energy
    cycle: daily
    tariffs:
      - mono
      energy_daily_usage: 
        value_template: "{{(
          (
            states('sensor.daily_energy_phase1_mono') | float + 
            states('sensor.daily_energy_phase2_mono') | float + 
            states('sensor.daily_energy_phase3_mono') | float 
          ) | round(2)
        )}}"
        friendly_name: 'Strømforbrug/Dag'
        unit_of_measurement: 'kWh'     
      energy_daily_usage_cost: 
        value_template: "{{(( states('sensor.energy_daily_usage') | float * 1 * 2.3)) | round(0) }}"
        friendly_name: 'Pris for strøm idag'
        unit_of_measurement: 'kr'  
1 Like

Thank you, I’m in the middle of getting this to work. I assume it works well for you?

Just a question, why use tariffs: mono? I can’t find any place to read about that mono thing… :wink:

 tariffs:
      - mono

Tariffs can be any string, but it doesn’t really make sense to specify it if you have only one tariff.

I think I just wrote mono because I wanted to reset the utility meter at some point. As far as I can remember is wasn’t possible unless you had some sort of tariff :slight_smile:

1 Like

@cvetser tack för svar!!

I just got everything to work after trying various methods and reading numerous threads; until I found your thread and got your config.

Then I’ll leave tariffs: mono alone, I don’t want to mess things up.

Trevlig sommar / Have a nice summer!

Hey again @TheLordVader , great to hear that . I always try to share my full config’s whenever I manage to get things working :smiley:

Trevlig sommar to you too :grin:

Hmm…I’m quite sure that you can not just add the energy from the 3 phases. 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!). Here’s my calculation.

    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') ) }}"

Hi, interesting. I stumbled accross this when I noticed my 3EM is not reading the same consumption as my energy seller. However, the SQRT(3) does not give me the correct number either… What else can it be?

ugh, nevermind it’s a constant

try dividing by 2 and multiplying by the sqrt(3)

actually multiply the shelly numbers by 0.78 and you’ll be within 10% of the metered numbers.

Can you provide more points?

Hi ,

Sorry I didnt have time to look at it.

I just checked my own sensor and compared it to my energy company…

My own sensor without any SQRT(3)
image

My energy company

Seems fine to me :grin: