Configuring Shelly EM Energy Meter

Yes that is what I observed with the restful sensor. The total energy is now also available via mqtt, I don’t know if it follows the same update interval as I have not tried it.

But there is absolutely no need for 1s updates. All you would be doing would be causing needless network traffic and cpu utilisation. The mqtt value is pushed from the Shelly EM whenever an update is available so there is no need to set a scan interval.

I’m using the Shelly integration instead of mqtt and it updates every seconds

How about using availability_template?

- platform: template
  sensors:
    house_energy:
      friendly_name: 'Total Energy'
      value_template: "{{ (states('sensor.l1_energy')|float + states('sensor.l2_energy')|float + states('sensor.l3_energy')|float)|round(3) }}"
      unit_of_measurement: "kWh"
      availability_template: "{{ states('sensor.l1_energy') not in ['unknown','unavailable'] and states('sensor.l2_energy') not in ['unknown','unavailable'] and states('sensor.l3_energy') not in ['unknown','unavailable'] }}"
1 Like

There is:

MQTT:

  • shellies/shellyem3-<deviceid>/emeter/<i>/command accepts message reset_totals to reset total and total_returned energy counters to 0

Same goes via REST, http:///emeter/0/reset_totals.

https://shelly-api-docs.shelly.cloud/#shelly-3em-emeter-index

You cannot affect the update interval. The interval is irregular but approximately 1 data per second.
In the CSV its exactly 1 per second, but not via MQTT.

Go to Configuration / Integration / MQTT / Configure and listen to the topic shellies/<shelly-device/emeter/0/total and you will see how it behaves.

Does this show the total consumed energy? I would guess so, because you are showing it as kWh.

Do people have some more useful template sensors for the 3EM? I don’t even know which ones are particularly relevant.

1 Like

I have my shelly EM connected locally to HA (via the Shelly integration) and it seems like it is updating its value once every 30 seconds.
Can I change that to every 10 seconds and how?

Apparently it can be set to lower but maybe it needs to be removed from the Shelly UI integration and added to the config.yaml file as an mqtt sensor instead so that you can edit mqtt_update_period?

1 Like

Found it, must send a POST request to http://<IPAddressofDevice>/settings?mqtt_update_period=10 but that is not affecting the Shelly integration from the UI.
Anyone managed to get the Shelly integration (not mqtt) to update every 10 seconds? It is updating every 10 when logging into the device locally.

I can confirm this works great to set the MQTT update period. This might not be useful for energy monitoring, but it’s very useful for power monitoring. I’ve set mine to update every 2 seconds and it’s working great.

The Shelly Integration uses the CoIoT protocol. According to the Shelly docs, there is a coiot_update_period REST endpoint, but it only accepts values from 15 seconds to 65535 seconds.

If you’re still using the official integration, you could try and see if POST to http://<IPAddressofDevice>/settings?coiot_update_period=10 works? But it might be limited to a min of coiot_update_period=15

1 Like

Hello all. I have been reading in this topic about Shelly EM, and apparently there are slight mentions to to troubles with the reactive_power sensor. I have just installed my new Shelly EM, and after configuring with MQTT to integrate in HomeAssistant, I see energy/returned_energy/power/voltage sensors for both clamps (apart of other information about the device itself), but no way to see the reactive_power. Does anybody apart of me have this issue? I have read some mentions, but not clear for me the solution (if exist…). Thanks if somebody helps!!
Additional info:


The sensors I see for ShellyEM:

image

no clue abotu reactive_power! :frowning:

I have enabled mqtt on the Shelly, using it with templates as sensors:

- platform: mqtt
  name: "Line Voltage"
  state_topic: "shellies/shellyem-shellyid/emeter/0/voltage"
  unit_of_measurement: 'V'
  device_class: voltage
- platform: mqtt
  name: "Real Power"
  state_topic: "shellies/shellyem-shellyid/emeter/0/power"
  unit_of_measurement: 'W'
  device_class: power
- platform: mqtt
  name: "Reactive Power"
  state_topic: "shellies/shellyem-shellyid/emeter/0/reactive_power"
  unit_of_measurement: 'VAR'


- platform: template
  sensors:
    apparent_power:
      friendly_name: "Apparent Power"
      device_class: power
      value_template: "{{ ((states('sensor.real_power')|float ** 2) + (states('sensor.reactive_power')|float ** 2))|sqrt|round(2) }}"
      unit_of_measurement: 'VA'
    power_factor:
      friendly_name: "Power Factor"
      device_class: power_factor
      value_template: "{{ ((states('sensor.real_power')|float) / (states('sensor.apparent_power')|float))|round(2) }}"
    current_draw:
      friendly_name: "Current Draw"
      device_class: current
      value_template: "{{ ((states('sensor.apparent_power')|float) / (states('sensor.line_voltage')|float))|round(2) }}"
      unit_of_measurement: 'A'

I hope it helps

1 Like

Can you help me how to change steps by step the mqtt_update_period?.

Thanks,

Please, can you help about the steps to reduce the mqtt update?, I tried to send the post command but it not works, continues updating the mqtt messages each minute… thanks,

I hope you put in the ip of your device like so:
http://192.168.0.55/settings?mqtt_update_period=10

Hi sd_dracula,

Thanbks, yes, I changed the parameter, and then, i chucked with "http://192.168.0.55/settings?" and see the new parameter:

But node red continues to show values each minute:

image

Then, it seems that the parameter was changed correctly but any changes from nodered. I use nodered to simulate the invoice of the actual month, and I need to be accurate, then I need more samples than one each minute…

Thanks,

Not sure I just used the mqtt integration directly without nodered.
Also I think you need to navigate to the IP of the device and change it to mqtt there also

Yes, I have activated the mqtt on the device, if not i dont receive the mqtt messages…

Try the HA mqtt directly, without going to nodered.
Also there may be a limit of 15 seconds, so that may be the fastest refresh time you can set.

Hi everyone.
I am looking at getting a Shelly EM. I have solar panels and would like to monitor grid consumption and return to grid.
How do I configure the EM?
Will 1 clamp report a positive and negative value, or will I need 2 clamps on the same cable in opposite directions? Would I need to combine 2 readings on the Shelly, or use them separately in the energy dashboard?

Also, I would like to avoid MQTT. Is there a Rest/other API or should I just flash ESPHome?
Thanks.