Metering · Meter cabinet
Energy metering in the distribution board
Direct or transformer measurement, how much room the board needs and why reconciling against the meter matters.
Read article →Technical article · Home Assistant · Energy
Adding the Shelly Pro 3EM to Home Assistant takes minutes. Whether the numbers are right afterwards is decided in three places: which sensors end up in the Energy dashboard, whether the current transformers are fitted the right way round, and whether the Shelly counts the way the utility meter does. On the last point it does not, as soon as a PV system feeds in within the house. This page shows the setup and the correction.
From this article on Amazon (Germany):
Shelly Pro 3EM-3CT63*
Marked *: affiliate links. As an Amazon Associate I earn from qualifying purchases.
The Energy dashboard sorts everything into consumption, production and storage. For electricity there are sources for the grid connection, the solar system, the home battery and individual devices. Each source is a sensor with fixed properties, and only sensors that have them appear in the selection at all:
| Quantity | device_class | state_class |
|---|---|---|
| Energy (kWh) | energy | total or total_increasing |
| Power (W) | power | measurement |
| Battery state of charge (%) | battery | measurement |
Power sensors can be configured alongside energy sensors. With them the dashboard shows not only what flowed in a period but also what is flowing right now. Everything is read from long-term statistics only: what the recorder does not record cannot be selected. How these statistics are created and what they keep is covered in Long-term data in Home Assistant.
The Pro 3EM sits in the meter cabinet or in a sub-distribution board downstream of the meter and measures via three current transformers placed around the phase conductors. That is work for an electrician; space, transformer measurement and the choice of measuring point are covered in Energy metering in the distribution board.
| Variant | Range per phase | Transformers |
|---|---|---|
| Pro 3EM | 0 to 120 A, ±1 % from 2 to 120 A | three individual 120 A transformers |
| Pro 3EM-3CT63 | 0 to 63 A, ±1 % from 2 to 63 A | combined three-phase transformer, mounted over a circuit breaker |
| Pro 3EM-400 | 0 to 400 A, ±1 % from 5 to 400 A | three 400 A transformers |
Which variant fits depends on the current that can flow at the measuring point; above its range the device no longer measures. All three store measurement data even without a network connection, the Pro 3EM for at least 45 days according to Shelly. Which version fits which connection, also compared with the 3EM-63 Gen3 and the Pro EM-50, is covered in the article Shelly Pro 3EM, 3EM-63 or Pro EM-50: which one fits?
Search on Amazon.de: Shelly Pro 3EM-3CT63*
Home Assistant classifies the Shelly integration as “Local Push”: it talks to the device on the local network, and the device reports changes by itself. For devices from the second generation onwards, which includes the Pro 3EM, the documentation says: “By default, no additional configuration is required.” Two things are still worth knowing:
The Pro 3EM has two profiles. In the default triphase profile it is a single three-phase meter with per-phase values and totals across all phases. In the monophase profile it becomes three separate single-phase meters, for example for three individual circuits. For the grid connection, triphase is correct.
In the triphase profile the integration creates three total sensors alongside the per-phase values, and those are the ones that belong in the dashboard:
| Sensor | Value in the device | In the Energy dashboard |
|---|---|---|
| Energy (kWh) | total_act | energy from the grid |
| Energy returned (kWh) | total_act_ret | energy to the grid |
| Power (W) | total_act_power, “Sum of the active power on all phases” | power measurement of the grid connection |
This is set under Settings › Dashboards › Energy, under Electricity grid
with Add grid connection. Home Assistant expects power to be positive when importing
and negative when exporting; that is how the Shelly delivers it when the transformers are fitted
the right way round. For devices that count the other way, there is the Inverted
setting. Anyone who needs to split by tariff periods uses the utility_meter
integration.
This is the difference the dashboard does not notice on its own. A German utility meter counts on a netted basis. The specification for the basic meter, to which modern metering devices in Germany are built, puts it briefly: “The measurement is always made as the sum across all phase conductors.” If phase L1 is drawing 2 kW while a balcony PV system on L2 feeds in 600 W, the meter counts 1.4 kW of import and no export.
The Shelly, on the other hand, keeps its energy counters per phase, separately for import and
return: for phases A, B and C one counter each for imported and one for returned energy, plus the
totals across all phases. For netted values Shelly offers a separate query,
EMData.GetNetEnergies, with periods of 5 to 60 minutes. So the normal counters are not
netted. In the example, both rise on the Shelly: the import counter with 2 kW, the export
counter with 600 W.
In the dashboard this looks harmless, but it is not. Grid import and export come out higher than what is billed, the PV system's self-consumption too low and the costs too high. It only does not matter as long as no phase flows in the opposite direction, that is, in a house without generation.
The good news: the Shelly's total power is already netted; it is the sum of the active power of all phases. From it, Home Assistant can build two counters that count the way the utility meter does. First two template sensors that split power by direction:
template:
- sensor:
- name: "Grid import power"
unique_id: grid_import_power
unit_of_measurement: "W"
device_class: power
state_class: measurement
availability: "{{ has_value('sensor.pro3em_power') }}"
state: "{{ [states('sensor.pro3em_power') | float(0), 0] | max }}"
- name: "Grid export power"
unique_id: grid_export_power
unit_of_measurement: "W"
device_class: power
state_class: measurement
availability: "{{ has_value('sensor.pro3em_power') }}"
state: "{{ [0 - states('sensor.pro3em_power') | float(0), 0] | max }}"
Then an energy counter from each with the integration integration, the Riemann sum.
It is also available as a helper in the interface:
sensor:
- platform: integration
source: sensor.grid_import_power
name: Grid import netted
unit_prefix: k
method: left
round: 3
max_sub_interval:
minutes: 1
- platform: integration
source: sensor.grid_export_power
name: Grid export netted
unit_prefix: k
method: left
round: 3
max_sub_interval:
minutes: 1
sensor.pro3em_power stands for your own device's total power sensor. The two new
counters have device class energy and state class total and are entered in
the dashboard instead of the Shelly counters; the total power remains the Shelly's.
On the choice of method: the Shelly reports a new power value as soon as it has changed by 5 %
or by 10 W. In between, the old value applies. That is exactly what the left method
assumes; the documentation recommends it for sources that hold their value for long periods.
max_sub_interval makes sure the calculation continues regularly even when power is
constant.
A Riemann sum is an approximation, as the documentation itself says: “intrinsically inaccurate”. How well it matches only shows when you reconcile against the meter. Newly created counters start at zero; the statistics of the Shelly counters remain alongside.
The step that makes the numbers reliable: note the meter readings for import and export, wait a fixed period, read again and compare with the totals in the dashboard. According to Shelly, the Pro 3EM measures with ±1 % from 2 A; at small currents it becomes less accurate. If the deviation is clearly larger, the usual suspects are a transformer fitted the wrong way round, a transformer on the wrong phase or the missing netting. How to reconcile in practice is described in Energy metering in the distribution board.
At the grid connection the Shelly only sees what flows across the connection. What the PV system produces therefore comes from a separate source, usually the inverter's integration, as do the battery's charge and discharge. Only with both can the dashboard work out what the house actually consumed. How battery and inverter get into Home Assistant is covered in Controlling a home battery with Home Assistant.
Individual devices, for example via smart plugs or sub-meters, are entered under Individual devices. If one meter measures a whole circuit and a second one a device on it, the Upstream device setting prevents consumption being counted twice. If a device only provides power, the Riemann sum above turns it into an energy counter. What a single device costs per year can be estimated beforehand with the electricity cost calculator on xmoo.app (in German); the measurement in the dashboard then shows whether the estimate holds.
Showing the energy flow needs no extra card. Home Assistant comes with several, and all of them can be placed on any other page outside the Energy dashboard too:
| Card | Shows | Time reference |
|---|---|---|
Energy distribution (energy-distribution) | flow between grid, solar, battery and house | selected period |
Sankey energy graph (energy-sankey) | flow from sources to consumers, grouped by floors and areas | selected period |
Power flow Sankey graph (power-sankey) | current power as a flow | now, independent of the date picker |
Power sources graph (power-sources-graph) | power of the sources over time | history |
Power consumption badge (power-total) | current total power of the house from grid, solar and battery | now |
Which cards the Energy dashboard itself shows can be set under Settings › Dashboards › Energy › Edit dashboard › Customize cards. The selection applies to the whole system, not just your own browser.
reverse),
after which the device restarts. With an even load, a single reversed transformer hardly shows in
the total; so look at each phase individually.Three for the grid connection: the total counter for imported energy (“Energy” in the English interface), the one for returned energy (“Energy returned”) and the total power across all phases (“Power”). The per-phase sensors do not belong there. If a PV system feeds in within the house, self-built netted counters are the more accurate choice.
Because the utility meter nets across all phases, whereas the Shelly's energy counters count import and return per phase. If one phase exports while another imports, both Shelly counters rise, while the utility meter only counts the difference. The remedy is counters that Home Assistant builds from the Shelly's netted total power.
No. The Shelly integration talks to the device locally, and devices from the second generation onwards push their values to Home Assistant by themselves. Mains-powered devices need no additional settings for this.
Yes. The energy distribution card shows how energy flowed between grid, solar, battery and house in the selected period. For the present moment there is the power-sankey card, which shows current power as a flow and is independent of the date picker.
The measuring range and the current transformers. The Pro 3EM measures up to 120 A per phase with three individual transformers, the Pro 3EM-3CT63 up to 63 A with a combined three-phase transformer mounted over a circuit breaker. There is also the Pro 3EM-400 for up to 400 A.
Usually a current transformer is fitted the wrong way round. The measuring direction can be reversed per phase in the device configuration, after which the device restarts. Whether all three phases are right is shown by the per-phase power values under a known load.
All statements come from the documentation of Home Assistant and Shelly, the source code of the Shelly integration and the specification for the German basic meter, each with the date it was checked. Quotations from German documents are my translation.
Home Assistant and the Shelly firmware change continuously. The current documentation is what counts. Work in the meter cabinet is reserved for a qualified electrician.
Links marked with an asterisk are affiliate links. As an Amazon Associate I earn from qualifying purchases; the price is unchanged for you. What I recommend does not depend on it.
Your Energy dashboard shows different numbers from the utility meter, and you want to know why? I can take a look at your system – the first conversation is free.