11 minutes
Monitoring electricity consumption and production with Shelly 3EM and Home Assistant’s Energy Dashboard
Introduction ¶
Next to making our lives easier by automating the boring stuff, many people invest in home automation to save money by reducing energy consumption. These savings are achieved by turning off devices not in use, lowering the temperature in uninhabited rooms, etc.
Another method of saving energy is making us aware of our energy consumption so that we can change our behaviour. This is reflected in many fancy and colourful dashboards displaying the energy consumption of lights, heating, dishwashers, AC, etc. present in the setup of many home automation enthusiasts.
Not only is reducing our energy consumption – and thus our energy bill – healthy for our wallets, it’s a necessary part of combatting the ongoing climate change.
The team behind Home Assistant has decided they wanted to do their part by adding an Energy Dashboard to Home Assistant through which users are able to gain more insights into their own energy consumption and production.
More info on the addition of Home Energy Management in Home Assistant can be found in their blogpost.

A main part of this dashboard is the visualisation of how much energy is produced and consumed, which devices contribute most to this energy consumption, and at what times energy consumption is highest. Next to this, additional graphs can be displayed for energy production/consumption and/or individual devices. The dashboard even allows you to scroll through the data per hour, allowing a detailed view into the energy consumption of your home.

Knowing for example when our solar production is highest allows us to move our energy consumption to those moments. Think about doing the laundry or dishes, turning on the AC or charging an electric vehicle (EV) when we have an abundance of energy. And thanks to home automation, we don’t have to manually plug stuff in or press the button on the dishwasher.
Measuring grid consumption with Shelly 3EM ¶
Before we can visualise our energy consumption and production, we need to collect the data first.
How we do this exactly will depend on what we have available.
Do you have a smart electricity meter in your home and does it have a P1 port? Then SlimmeLezer will allow you to collect the data on consumption and production.
No P1 port? Check Home Assistant Glow out.
Or, if you still have a analog meter, the Shelly 3EM can help you out.
My situation is a follows: My house has 3-phase electricity (3x400V+N) with an analog meter and a photovoltaic (PV/solar) installation with a digital meter. The digital meter of the solar installation only sends updates twice a day to a portal of the installer.
In this blog post I will describe my experiences installing a Shelly 3EM to monitor the energy coming from or flowing to the grid, and using either a phototransistor to read the blinking LED on the digital meter or connecting to its serial port to read the data over modbus.
Wiring in the Shelly 3EM ¶
I will be installing the Shelly 3EM according to the 3-phase wiring diagram found in the manual. More wiring diagrams can be found on the Shelly Knowledge Base page for the 3EM.

A clamp is hooked around the incoming wires for each of the phases. These monitor the current (in Amps) flowing through the wire and its direction.
The Shelly is also connected to each of these phases via connections VA, VB and VC, and Neutral. This is to measure the Voltage.
Multiplying Amps with Volts gives us an energy consumption/production in Watts.
Optionally, a contactor or low-load device can be hooked up to the I and O terminals of the Shelly. For example to disconnect an EV charger when there’s no PV production.
At this moment, the Shelly 3EM does not support electricity theft/leakage detection, which would require an additional clamp around outgoing Neutral wire.

1. De-energize panel ¶
Before installing the Shelly, make sure you de-energize your panel. This is usually done be flipping the main electricity cut-off switch, often located near the meter. Double-check that the inverter of your solar installation also shut off and is not energizing the panel.
Always confirm using an electricity detector or multimeter that there’s no electricity flowing through the panel before doing modifications!
2. Mount Shelly ¶
Attach the Shelly 3EM to the DIN rail of your panel on a location that’ll allow you to easily run the necessary wires.
You’ll also want to take into account the length of wire the clamps have.
I decided to install the Shelly such that the clip to hold it onto the DIN rail is on top. The clamps are then attached to the top of the Shelly and the power wires to the bottom.
3. Attach clamps ¶
Hook the current clamps (split core current transformers) around the incoming wires for each phase.
Note the arrow on the clamps pointing from “K” to “L”.
Where “L” is the grid or the source of the electricity and “K” is the household.
In other words: install the clamps such that the arrow points towards your electricity meter.
The clamps are labeled A, B and C, and must be plugged into the respective connectors on the Shelly.

I hooked up the clamps (marked purple in picture below) on the input side of the main differential.
I would have preferred to hang them on the output side, but multiple wires where leaving on that side (to the subpanel, the 2nd differential and the electric stove) making clamping impossible.
I can still de-energize the wires by flicking the main breaker at the meter.
Never attach a clamp on an energized wire while it’s not connected to the Shelly!
4. Attach wires ¶
Connect wires from the VA, VB and VC terminals to breakers on the different phases. Make sure their order matches the order in which you attached the clamps (VA on same phase as clamp A, etc.).
The terminals fit 2.5mm² solid core wires. I stripped them 10mm on both sides.
These wires are then ran to 3 different fuses (marked orange below) which each are on a different phase. The Neutral wire is connected to the same fuse as the Live wire for Phase A (marked A-live and A-neutral).

5. Turn power back on ¶
After you’ve verified all wires are installed correctly and tightly (pull the wires a few times), you can close the cabinet and re-energize the panel.
The Shelly’s LED will start to flicker, indicating it’s in Access Point mode.

Setting up the Shelly ¶
1. Connecting with WiFi ¶
While standing near the Shelly 3EM, open up the WiFi settings of your smartphone.
You should see a new WiFi network names shellyem3-<device_ID>
pop-up.
Connect to this WiFi network and accept any prompt saying you don’t have internet connectivity.
Browse to http://192.168.33.1 to open the web portal of the Shelly (for more info, see this blogpost).

Open the Internet & Security
tab and open the WiFi Mode - Client
section.
Check the box next to Connect the Shelly device to an existing WiFi Network
, enter your WiFi SSID (network name) and password, and click Save.
The Shelly will no attempt to connect to the WiFi network you’ve entered. The WiFi network of the Shelly will disappear and your phone will connect to your home’s WiFi again.
2. Firmware update & extra config ¶
Find the IP address of your Shelly (e.g. in the router tabel) and browse to it to find the Web UI again.
Under Settings there’s an option to pick the transformer type (50A or 120A). This option appears to have been removed in a later firmware update, so I’m not sure how relevant it is anymore. But it seemed appropriate to me to set it correctly, i.e. 120A.

Still in the Settings Menu, scroll down to Firmware Update
and press the big button to update the firmware of the Shelly.

Once the Shelly’s updated, the webpage should reload and new options will have appeared.
Under Settings
you can now set a Device Name
and Channel # Name
.
These names will be reflected in Home Assistant once we integrate the Shelly, so it’s useful to set a descriptive name here.

While still on the Web UI, you can modify the other settings to fit your needs. You can enable AP Roaming to have the Shelly move to a different Access Point if the signal become too bad. You can enable MQTT or set CoIoT unicast to the IP of your Home Assistant instance.
Integrating Shelly 3EM in Home Assistant ¶
Home Assistant will most likely have already discovered the Shelly 3EM on your network. If it hasn’t, setting CoIoT to the IP of your HA instance and rebooting the Shelly should help.
Click the link in the notification to open the Integrations page which prompt to configure the Shelly.

If HA still didn’t automatically discover the Shelly, you can manually add a new Shelly integration.
Home Assistant will automatically integrate all relevant entities, including the energy meters.

Notice how there are meters for Energy (consumption) and Energy Returned (overproduction) for all three phases. We’ll need these entities for our Energy Dashboard.
Energy dashboard ¶
Now that we have our sensors setup collecting the data we need, we can add them to the Energy Dashboard.
Setup Wizard ¶
To start, go to the energy configuration page and follow the wizard.
1. Electricity Grid ¶
In this first step, we add the sensors that contain the data of the energy flow between our house and the grid. This will be the sensors from the Shelly 3EM.
Add the “Energy” sensors for the 3 phases as “Grid Consumption”.

If you know the cost of your electricity or have an integration that provides you with this data, you can configure this here as well. This will allow you to not only track your electricity consumption, but also how much it’s costing you.
Do the same for the other 2 “Energy” meters and and the “Energy Returned” meters under the “Return to Grid” section. Here you’ll also be able to provide the price you get paid for the electricity you put back on the grid.

2. Solar Panels ¶
In the 2nd part of the wizard, you can add the meter for your solar production.

3. Individual devices ¶
In this final part of the wizard, you can add meters for individual devices for which you want to specifically track their consumption.
For example, a sensor on your Electric Vehicle (EV) charger or your aircondition.

Finish ¶
When you now close the wizard by clicking Show me my energy dashboard
, you’ll notice it’s still pretty empty.
This is, as the message on the graph explains, because data still needs to be imported and parsed. Don’t worry, eventually you’ll see your data appear here, give it some time.


Note that the dashboard above doesn’t include a sensor for my PV installation yet. So data on solar energy production isn’t included in this dashboard yet.
The dashboard does show my ‘overproduction’, which is reflected in ‘Phase B Energy Returned’ as my solar panels are hooked up to Phase B. But at this moment I’m missing how much energy I’m consuming directly from the PV, and thus not asking from the grid.
Adding a meter on my solar systems output line would allow me to see how much energy is produced and how much of it was directly consumed.
This will also give me better insights in the total energy consumption of my house.
That will be food for a new blog post :)
Make changes ¶
To want to make changes to your Energy Dashboard, go to Configuration > Energy. Here you can modify the sensors you’re using for grid consumption/return, solar panel production, individual device tracking and the Grid Carbon Footprint.
To modify the currency used for cost calculations, go to Configuration > General.

Grid Carbon Footprint ¶
You can optionally add a “Grid carbon footprint” sensor as well.
This service will show you how much of your home’s electricity grid comes from Fossil Fuels and what its CO2 intensity is. Based on this data, you can steer your electricity consumption as to use electricity when its carbon footprint is lowest.
To add this service, you’ll need to add your email address to the CO2 Signal mailing list so you can get an API key.

Home Automation Energy Management Electricity Metering Shelly Home Assistant
2157 Words
2021-08-18 (Last updated: 2021-09-10)