Reset values of utility_meter

that’s the one I added :slight_smile:

It’s the calibrate service…

I still don’t get it. Let’s say I have these sensors:

utility_meter:
  shelly_hourly_energy:
    source: sensor.shelly_total_power_consumption
    cycle: hourly
  shelly_daily_energy:
    source: sensor.shelly_total_power_consumption
    cycle: daily

and they look like this:

If I now go into Development -> Services and call:

And it does NOTHING.

And the other thing you may note: Power consumption is in “kWh”, and the utility_meter still counts “Wh”. No idea how to REGENERATE those utility sensors. Could someone please tell me how!

Could someone please tell me how to remove the sensors and regenerate them? I googled but didn’t come up with a single reply.

1 Like

Before you do this, can I ask why?

To remove the sensors
Cut the utility meter config from your configuration.yaml file and paste it into a text editor. Save the configuration file. Config check. Restart.

To "regenerate"
Paste the utility meter config back in. Save. Config check. Restart.

Be careful which text editor you paste into. Some like most windows editors will change the end of line characters from line-feed to carriage return + line-feed. This will not make home assistant happy.

A good choice would be whatever you are currently using to edit your yaml files.

Thanks @tom_l. This is what I already tried. Maybe I try once again. I normally use the FILES add-on in hassio, so all should be fine. And if not I’m still using Linux to alter the files.

Why I ask:

and this is what @dgomes suggested:

You will need to recreate the sensors, sorry :frowning:

Ah, I see.

How long is your utility meter cycle (day?, year?)?

You might have to wait that long for the unit to update. Not so bad if it is a day, but a year…

Hehe. No, that doesn’t help. I got sensors for the hour, day, week, month and year. And NONE of them change. It seems the units are taken from the add-on at time of generation and then never touched again. And even removing them seems to leave some residues in the system which it “remembers” when the sensors are added again.

The unit does not update unfortunately

The utility_meter unit is kept indefinitely, when I say “recreate” I mean create a new utility_meter with a different name.

2 Likes

Thanks guys. Works like a breeze (once you do it correctly :wink:)
I made NEW sensors with NEW names, and they were generated correctly.
After that I called utility_meter.calibrate for each of them and set them to the desired value.

Too bad, something’s still wrong. After the next update of the utility_meter cycle it shows up like this, and this just still calculates from the YEARLY totals.
At least i hope i didn’t use ONE MEGAWATTHOUR during the last 60min … :wink:

EDIT: Reading the last report it seems the problem is somewhere else. I guess Shelly still delivers Wh, which i divide by 1000 to show kWh, but utility_meter doesn’t know that.

No, I guess the sensor is correct, must be something else. I’m lost …

- platform: template
  sensors:
    shelly_total_power_consumption:
      friendly_name: 'Verbrauch Gesamt'
      unit_of_measurement: 'kWh'
      value_template: >
        {{ (states('sensor.shelly_shem_3_dc4f227648a6_1_total_consumption') | float +
            states('sensor.shelly_shem_3_dc4f227648a6_2_total_consumption') | float +
            states('sensor.shelly_shem_3_dc4f227648a6_3_total_consumption') | float)
            | round(2) }}

The sensor is showing 1.5MWh. 1591.9kWh == 1.5919MWh

What is the config for your three sensors? for example this one:

sensor.shelly_shem_3_dc4f227648a6_1_total_consumption

That’s from the Shelly components directly. Shelly generates total usage for each phase, and i summed those up.

device_class: power.

That seems to be a power sensor not an energy sensor.

If you want to use that in the Utility meter you have to integrate it.

Which Shelly device are you using?

It’s ENERGY after all. It’s kWh that sum up. Afaik utility_meter can take an value that’s raising.

Making the unit Wh or kWh does not change it from a power meter to an energy meter.

Are you using the Shelly custom component?

Of course the Shelly component is BOTH. It’s a power meter and an energy meter. :wink:
I don’t do anything with the data. That’s as you said, the ShellyforHass custom component https://github.com/StyraHem/ShellyForHASS

The Shelly 3EM measures power, then sends it to the cloud and generates energy values which the custom component uses. IMHO.

I have the Shelly EM (single phase) and it works well with the Utility meter - when you feed it the right sensor.

I had to use a RESTful sensor when I started using this device as Shelly for Hass did not support the Total Consumption sensor. I’ve continued to use it even though this is now available, after a recent firmware update and release of Shelly for Hass.

I’m not about to trawl through the source code to make sure they have it right, but an easy way to check is to point a web browser at http://shelly_ip_address_here/status.

Look a the total consumptions on that page and compare it to your sensors.

{"wifi_sta":{"connected":true,"ssid":"xxxxxx","ip":"192.168.1.115","rssi":-35},"cloud":
{"enabled":true,"connected":true},"mqtt":{"connected":false},"time":"13:54","unixtime":1588082073,"serial":38793,"has_update":false,"
mac":"DC4F227648A6","relays":[{"ison":false,"has_timer":false,"timer_remaining":0,"overpower":false,"is_valid":true}],"emeters":[{"power":463.67,"pf":0.97,"current":2.10,"voltage":228.05,"is_valid":true,"total":693719.3,"total_returned":2.2},
{"power":19.94,"pf":0.21,"current":0.41,"voltage":234.18,"is_valid":true,"total":514824.1,"total_returned":4096.2},{"power":200.91,"pf":0.80,"current":1.08,"voltage":231.94,"is_valid":true,"total":387038.5,"total_returned":237.0}],"fs_mounted":true,"update":
{"status":"idle","has_update":false,"new_version":"20200309-104619/v1.6.0@43056d58","old_version":"20200309-104619/v1.6.0@43056d58"},
"ram_total":48552,"ram_free":29336,"fs_size":233681,"fs_free":160138,"uptime":4242205}

Looking at the data it seems the shelly’s web interface gives Wh and the custom components makes kWh out of it? Could that be the issue?

Looking at this section:

"emeters":[
    {
        "power":463.67,
        "pf":0.97,
        "current":2.10,
        "voltage":228.05,
        "is_valid":true,
        "total":693719.3,
        "total_returned":2.2
    },
    {
        "power":19.94,
        "pf":0.21,
        "current":0.41,
        "voltage":234.18,
        "is_valid":true,
        "total":514824.1,
        "total_returned":4096.2
    },
    {
        "power":200.91,
        "pf":0.80,
        "current":1.08,
        "voltage":231.94,
        "is_valid":true,
        "total":387038.5,
        "total_returned":237.0
    }

Your total energy meters should be 693.7193 kWh, 514.8241 kWh and 387.0385 kWh.

Are they?

if not, then yeah a problem with the config for Shelly for Hass or with Shelly for Hass itself.

According to the API reference ( https://shelly-api-docs.shelly.cloud/#shelly-3em-emeter-index-em_data-csv ) yes the values are in Wh.

Though it would not be the first time that reference was wrong, it does look about right.

If you want to try out rest sensors, this should do it:

- platform: rest
  name: Shelly Total Energy 1
  resource: http://shelly_ip_address_here/status
  username: !secret shelly_usr
  password: !secret shelly_pwd
  authentication: basic
  value_template: '{{ (value_json.emeters.0.total | float /1000)|round(3) }}' # Wh to kWh
  scan_interval: 300 # no point updating faster than this. The Shelly only updates every 5 minutes
  unit_of_measurement: kWh

- platform: rest
  name: Shelly Total Energy 2
  resource: http://shelly_ip_address_here/status
  username: !secret shelly_usr
  password: !secret shelly_pwd
  authentication: basic
  value_template: '{{ (value_json.emeters.1.total | float /1000)|round(3) }}' # Wh to kWh
  scan_interval: 300 # no point updating faster than this. The Shelly only updates every 5 minutes
  unit_of_measurement: kWh

- platform: rest
  name: Shelly Total Energy 3
  resource: http://shelly_ip_address_here/status
  username: !secret shelly_usr
  password: !secret shelly_pwd
  authentication: basic
  value_template: '{{ (value_json.emeters.2.total | float /1000)|round(3) }}' # Wh to kWh
  scan_interval: 300 # no point updating faster than this. The Shelly only updates every 5 minutes
  unit_of_measurement: kWh

that scan interval may no longer be true after the recent firmware update. Keep refreshing the web page and time it to check.

1 Like