Configuring Shelly EM Energy Meter

Mine arrived today. Holey shit that app is bad.

I cant even get my Shelly EM to connect to a local wifi network.

I connected to the EM’s local network.
Under user settings in the app I filled in the batch wifi update settings (2.4GHz network SSID and PWD) and selected both power meters that appear. Hit update but nothing appears in my DHCP server.

EDIT: I deleted the app and just used the web settings.

EDIT 2: Also if anyone is looking for an RSSI sensor, this works:

- platform: rest
  name: Shelly EM Wifi
  resource: http://10.1.1.24/status ### Edit to use the IP of your Shelly EM
  username: !secret shelly_usr ### Only required if you have set a password
  password: !secret shelly_pwd ###  "    "              "            "
  authentication: basic        ###  "    "              "            "
  value_template: '{{ value_json.wifi_sta.rssi }}'
  scan_interval: 180  ### Feel free to make faster, 30 or 60 sec would be fine
  unit_of_measurement: dB

Edit 3:

Another trap for players, who the flock uses Watt-minutes? Ugh. Fix:

- platform: mqtt
  name: "Tariff 31 Energy"
  state_topic: "shellies/shellyem-B9E940/emeter/0/energy"
  value_template: "{{ value|float / 60000 }}" # Fix for Watt-minutes
  qos: 1
  unit_of_measurement: "kWh"
  icon: mdi:chart-bar

- platform: mqtt
  name: "Tariff 41 Energy"
  state_topic: "shellies/shellyem-B9E940/emeter/1/energy"
  value_template: "{{ value|float / 60000 }}" # Fix for Watt-minutes
  qos: 1
  unit_of_measurement: "kWh"
  icon: mdi:chart-bar

EDIT 4:

But ignore those sensors because they wont work with the Utility meter if you want a daily energy used sensor (they reset to 0 if no power is used for a minute). You need to use a rest sensor to interrogate the yearly totals like this:

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

- platform: rest
  name: Tariff 41 Total Energy
  resource: http://10.1.1.24/status
  username: !secret shelly_usr
  password: !secret shelly_pwd
  authentication: basic
  value_template: '{{ value_json.emeters.1.total | float /1000 }}'
  scan_interval: 300
  unit_of_measurement: kWh

Used in the Utility meter:

utility_meter:
  daily_light_and_power:
    source: sensor.tariff_31_total_energy
    cycle: daily
    tariffs:
      - peak
  daily_heating:
    source: sensor.tariff_41_total_energy
    cycle: daily
    tariffs:
      - offpeak

You can omit the tariff configuration. I only needed it as you cant use the reset service without them and testing required a bit of resetting.

All of this shenanigans could have been avoided if Shelly provided a daily energy used total. Like every other freaking smart power meter on the market.

5 Likes

Mine arrived today and I’ve just connected it up. I skipped the app, and just connected to its wifi network and used the web interface, which allowed me to connect it to my main network.

I enabled MQTT, and I can see that it’s publishing nice values – perhaps because I’ve just updated the firmware? But anyway, I get

shellies/shellyem-B9F368/online

shellies/shellyem-B9F368/relay/0

shellies/shellyem-B9F368/emeter/0/power
shellies/shellyem-B9F368/emeter/0/reactive_power
shellies/shellyem-B9F368/emeter/0/voltage
shellies/shellyem-B9F368/emeter/0/energy
shellies/shellyem-B9F368/emeter/0/returned_energy

and the same for channel 1.

The power values seem to be in watts - at least, they look plausible and correspond to those shown as watts in the web interface.

Thanks for the hints about the REST interface…

1 Like

Yeah power units are ok. It’s the energy units that are weird.

https://shelly-api-docs.shelly.cloud/#shelly-em

I think the conversion factor from [W/min] to [KWh] is 60000, and not 6000 as scripted some post above.
Indeed the value template should be:

value_template: "{{ value|float / 60000 }}" # Fix for Watt-minutes
2 Likes

Yeah you’re right but I didn’t end up using those sensors anyway.

Have tried to make rest sensor with utility meter from a shelly plug s.

All validates but the rest sensor has status unknown. I don´t use username and password on mina.

Anyone that has some tips.

What do you see when you visit this web page:

http://[shelly_ip_address]/status

If i just want to one sensor with utility meter shall I use

value_template: ‘{{ value_json.emeters.1.total | float /1000 }}’

or

value_template: ‘{{ value_json.emeters.0.total | float /1000 }}’

Neither of them. Those templates are for the shelly EM.

This is the information for the shelly plug s:

https://shelly-api-docs.shelly.cloud/#shelly-plug-plugs-settings

“wifi_sta”:{“connected”:true,“ssid”:“Michaels Wi-Fi-nätverk”,“ip”:“10.0.1.225”,“rssi”:-75},“cloud”:{“enabled”:false,“connected”:false},“mqtt”:{“connected”:true},“time”:“08:44”,“serial”:1,“has_update”:false,“mac”:“2CF432267F9D”,“relays”:[{“ison”:true,“has_timer”:false,“overpower”:false}],“meters”:[{“power”:0.00,“is_valid”:true,“timestamp”:1576831462,“counters”:[0.000, 0.000, 0.000],“total”:19258}],“temperature”:34.63,“overtemperature”:false,“tmp”:{“tC”:34.63,“tF”:94.34, “is_valid”:“true”},“update”:{“status”:“idle”,“has_update”:false,“new_version”:“20191216-090549/v1.5.7@c30657ba”,“old_version”:“20191216-090549/v1.5.7@c30657ba”},“ram_total”:50792,“ram_free”:38840,“fs_size”:233681,“fs_free”:174445,“uptime”:140317}

value_template: '{{ value_json.meters.0.total | float /1000 }}'

Tried exactly that but not luck. It validates but sensors don´t show anything.

Post your whole (correctly formatted) sensor config here.

First a rest sensor

'- platform: rest
name: “tvattmaskin_energy”
resource: http://10.0.1.225/status
value_template: ‘{{ value_json.meters.total | float /1000 }}’
scan_interval: 300 # no point updating faster than this. The Shelly only updates this every 5 minutes
unit_of_measurement: kWh´

Then the daily and mountly

'utility_meter:
daily_energy:
source: sensor.element_loft_kwh
cycle: daily

monthly_energy:
source: sensor.element_loft_kwh
cycle: monthly

daily_energy_tvattmaskin:
source: sensor.tvattmaskin_energy
cycle: daily

monthly_energy_tvattmaskin:
source: sensor.tvattmaskin_energy
cycle: monthly’

Never mind the other one its a z-wave and its working

Hi all

I’m trying too to have the Shelly plug S work with utility meter, but with no success.
The Shelly power sensor is based on mqtt and it works.

I’m using sensor.shelly_plug_s_041662_power_0

Then I have added the configuration as @Michael_Roxin but the utility meter sensor are not created.

  frigo_daily:
    source: sensor.shelly_plug_s_041662_power_0
    cycle: daily
    tariffs:
      - day
      - night

  frigo_monthly:
    source: sensor.shelly_plug_s_041662_power_0
    cycle: monthly
    tariffs:
      - day
      - night

Any suggestion?

Thanks

I have not figured this out, my daily and mounthly sensor always just shows 0.

Shelly EM latest firmware now send the Total via MQTT in Wh

Thanks so much.

One question.

How can reboot value “total” API REST Shelly EM???
thanks

There is no option for resetting the Shelly total energy counter. Unless you want to factory reset it and lose all your settings. You can monitor this sensor with a the utility meter and that can be reset at any interval (cycle) you want:

Yes, exactly, I am using a utility_meter with a time hourly cycle next to the so called API rest of shelly to value “total” accumulated.

Your answer helped me.

But of course, I wondered, if it would be possible to reset that accumulated value.
Since when does that accumulated value work?
since I bought shelly em?

Until what value will it reach?
I may have a limit, and in the future the counter will stop working: -S

Thanks

1 Like