Tutorials 10 min read

Measure Your Home Lab's Electricity Consumption in 2026

Measure your homelab's power draw: a Brennenstuhl PM 231 E plug-in meter for single devices, a Shelly EM Gen3 in the electrical panel, readings from its RPC API, and history in Home Assistant on Docker.

See our picks
S By Selfhostr Team · no sponsored content
Measure Your Home Lab's Electricity Consumption in 2026
ⓘ ⓘ This article may contain affiliate links (no extra cost to you, it funds the site). As an Amazon Associate, Selfhostr earns from qualifying purchases. See the disclosure.
⏱️
~45 min
Duration
🎚️
Intermediate
Difficulty
💶
0 € (open-source software)
Cost
📦
Docker installed
Key Prerequisites

👍 What we like

  • ✓Real measurements instead of estimates
  • ✓Runs 100% locally, no cloud required
  • ✓Documented, maintained tools (Shelly RPC API, Home Assistant)
  • ✓Two complementary levels of measurement: device and circuit

👎 What to watch

  • ✕The Shelly EM Gen3 must be wired to 230 V by a qualified electrician
  • ✕The PM 231 E has no network connection: manual readings only
  • ✕The Shelly EM Gen3 measures single-phase power, on two channels only
  • ✕Home Assistant takes some initial setup

🏆 Our picks

Affiliate links · same price for you
Recommended
📦

Shelly EM Gen3

Voir sur Amazon

Amazon · price and availability on the listing

Alternative
📦

Brennenstuhl PM 231 E

Voir sur Amazon

Amazon · price and availability on the listing

See all our recommended gear in the shop.

📑 Contents ▾

To know what your homelab really costs in electricity, you need measurements, not estimates. There are two ways to get them, and they complement each other:

  1. Measure a single device at the outlet with a plug-in power meter such as the Brennenstuhl PM 231 E. It shows voltage, current, power and cumulative energy on its own display. It has no network connection, so it cannot send anything to software.
  2. Measure a whole circuit in the electrical panel with the Shelly EM Gen3. This module is wired to the 230 V supply and measures current with clamp-on current transformers. It does not plug into an outlet. Its readings are available on your local network through its RPC API, so you can record their history in Home Assistant (installed here as a Docker container).

This tutorial covers both methods. It replaces the previous version, which relied on an “Electricity Monitor” application that does not exist: only documented tools are used here.

Prerequisites

  • An up-to-date, supported Linux server: Debian 12 or 13, or Ubuntu 22.04, 24.04 or 26.04 LTS (the versions Docker Engine supports according to its documentation).
  • A user account with sudo.
  • For outlet measurements: a Brennenstuhl PM 231 E. According to its manual, do not plug in any device (or loaded power strip) that draws more than 16 A. Check the manual for your unit.
  • For circuit measurements: a Shelly EM Gen3 (supplied with a 50 A clamp; the 80 A clamp is compatible), 2.4 GHz Wi-Fi, and a qualified electrician to do the wiring in the panel.
  • The curl and jq tools on the server.
  • No ports to open to the Internet: everything stays on the local network (Home Assistant listens on TCP port 8123 by default).

Step-by-step installation

Step 1: Measure a device at the outlet with the Brennenstuhl PM 231 E

Plug the PM 231 E into the wall outlet, then plug the device you want to measure into it (NAS, mini PC, switch, or the rack’s power strip if the total load stays under the manual’s limit). Let it run through a representative usage cycle, for example 24 hours, then read the instantaneous power and the cumulative energy on the display.

Because the meter is not connected, record your readings in a file so you can compare them later. Replace the values in angle brackets with your own readings:

mkdir -p ~/homelab-energie
echo "date,appareil,puissance_W,energie_kWh,duree_h" > ~/homelab-energie/releves.csv
echo "$(date +%F),<nom_appareil>,<puissance_W>,<energie_kWh>,<duree_h>" >> ~/homelab-energie/releves.csv

Check: display the file to confirm the line was saved.

column -s, -t ~/homelab-energie/releves.csv

Step 2: Install the Shelly EM Gen3 in the electrical panel (electrician)

⚠️ 230 V hazard. According to Shelly, installation on the power grid must be done by a qualified electrician. The work is done with the power off: main breaker switched off and absence of voltage verified.

According to Shelly’s documentation, the wiring is as follows:

Alimentation du module : phase -> borne L, neutre -> borne N
Protection amont        : disjoncteur 2 A, courbe B ou C (pouvoir de coupure 6 kA)
Pince A (CT A)          : autour du conducteur de PHASE du circuit à mesurer -> entrée IA
Pince B (CT B)          : autour du conducteur de phase d'un second circuit (optionnel) -> entrée IB
Sens des pinces         : flèche K -> L dans le sens du courant (vers la charge)
Conducteurs             : 0,5 à 4 mm², dénudage 6-7 mm, serrage 0,4 Nm

In plain English: module power from live to terminal L and neutral to terminal N; upstream protection is a 2 A breaker, B or C curve, 6 kA breaking capacity; clamp A goes around the live conductor of the measured circuit and connects to input IA; clamp B (optional) goes around a second circuit’s live conductor and connects to IB; the K → L arrow points in the direction of current flow (towards the load); conductors are 0.5–4 mm², stripped 6–7 mm, tightened to 0.4 Nm.

A clamp must go around a single conductor, the live wire. If it goes around live and neutral together, the two currents cancel out and the reading is wrong. The module also has a relay (2 A max) that you don’t need here.

Check: once power is restored, the Shelly broadcasts a Wi-Fi access point named ShellyEMG3-XXXXXXXXXXXX, visible from a phone or a PC.

Step 3: Connect the Shelly to Wi-Fi and secure it

There are two methods: the Shelly app, or the built-in web interface. For the web interface, connect to the ShellyEMG3-… access point, then open http://192.168.33.1 (the access-point-mode address used in the Shelly API documentation). In the interface:

  • in the Wi-Fi settings, enter your 2.4 GHz network (SSID and password), then disable the access point once the connection is confirmed;
  • in the authentication settings, set an access password;
  • update the firmware from the dedicated section.

Exact menu labels may change between firmware versions: check the documentation for your version. Then create a DHCP reservation on your router so the Shelly always keeps the same IP address.

Check: query the module from the server. The Shelly.GetDeviceInfo method responds even when authentication is enabled:

SHELLY=192.168.1.50   # replace with your Shelly's reserved IP
curl -s "http://$SHELLY/rpc/Shelly.GetDeviceInfo" | jq

You should get a JSON object with the device’s ID and firmware version.

Step 4: Read measurements through the RPC API

Gen2 and Gen3 devices don’t use the old Gen1 /status endpoint; they use the RPC API. The Shelly EM Gen3 exposes two EM1 components (instantaneous readings, id 0 and 1) and two EM1Data components (energy counters, in Wh). If you enabled authentication, add --digest -u admin:YOUR_PASSWORD (the username is admin):

# Instantaneous reading for channel A: voltage (V), current (A), active power (W)
curl -s --digest -u admin:YOUR_PASSWORD \
  "http://$SHELLY/rpc/EM1.GetStatus?id=0" | jq '{voltage, current, act_power, pf}'

# Cumulative active energy for channel A, in Wh
curl -s --digest -u admin:YOUR_PASSWORD \
  "http://$SHELLY/rpc/EM1Data.GetStatus?id=0" | jq '.total_act_energy'

Check: switch a known load on the measured circuit on and then off. The act_power value should change to match. According to Shelly’s spec sheet, the module treats anything below 30 VA per channel as no load.

Step 5: Install Docker Engine from the official repository

Docker’s documentation advises against the get.docker.com script in production. Use the apt repository instead. The commands below detect Debian or Ubuntu automatically:

sudo apt update
sudo apt install -y ca-certificates curl jq
DISTRO=$(. /etc/os-release && echo "$ID")   # debian or ubuntu
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL "https://download.docker.com/linux/$DISTRO/gpg" -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/$DISTRO
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Check:

sudo systemctl status docker --no-pager
sudo docker run --rm hello-world
docker compose version

You can add your user to the docker group (sudo usermod -aG docker $USER). You then need to log out and back in for it to take effect. Be aware that this group grants root-equivalent rights.

Step 6: Deploy Home Assistant (container)

Home Assistant supports Shelly devices natively and includes an Energy dashboard. The file below follows the official compose.yaml example. It does not mount the Docker socket:

mkdir -p ~/homeassistant/config && cd ~/homeassistant
# ~/homeassistant/compose.yaml
services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - ./config:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    restart: unless-stopped
    stop_grace_period: 60s
    privileged: true
    network_mode: host
    environment:
      TZ: Europe/Paris

network_mode: host lets Home Assistant discover devices on the local network. privileged: true is in the official example (for hardware access: USB, Bluetooth).

sudo docker compose up -d

Check:

sudo docker compose ps
curl -sI http://localhost:8123 | head -n 1

The container should be running and the curl command should return an HTTP response. Then open http://SERVER_IP:8123 from your local network and create the owner account.

Step 7: Add the Shelly and set up the Energy dashboard

The Shelly often shows up by itself as a Discovered device. If it doesn’t, go to Settings > Devices & services > Add integration > Shelly, then enter the module’s IP address and password. Mains-powered Gen2+ devices need no extra configuration, and no cloud connection is required. Power measurement depends on time synchronisation (SNTP): the Shelly must be able to reach its SNTP server.

Next, open the Energy configuration (Settings > Dashboards > Energy in recent versions; the path may vary with your version). Add the Shelly’s energy sensors (kWh) under device or circuit consumption. Power-only sensors (W) can be converted to energy with the Integral (Riemann sum) integration.

Check: in Settings > Devices & services > Shelly, open the device and confirm that the power shown matches the value returned by curl in Step 4.

Verification

# The container is running and restarts automatically
sudo docker inspect -f '{{.State.Status}} {{.HostConfig.RestartPolicy.Name}}' homeassistant
# The Shelly responds and is measuring
curl -s --digest -u admin:YOUR_PASSWORD "http://$SHELLY/rpc/EM1.GetStatus?id=0" | jq .act_power

Finally, take a device you measured with the PM 231 E and compare its reading with the power change the Shelly sees when you switch it on. The two values should be consistent, within measurement tolerances.

Security and best practices

  • Never expose Home Assistant or the Shelly web interface to the Internet. For remote access, use a VPN (WireGuard, for example).
  • Restrict port 8123 to the local network. With ufw, allow SSH before enabling the firewall so you don’t lock yourself out:
sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp
sudo ufw allow from 192.168.1.0/24 to any port 8123 proto tcp
sudo ufw enable
sudo ufw status verbose
  • Protect the Shelly with a password, disable its access point, and keep its firmware up to date. If you can, put IoT devices on a separate VLAN.
  • Never mount /var/run/docker.sock in a container that doesn’t need it.
  • Back up the ~/homeassistant/config folder. Update with sudo docker compose pull && sudo docker compose up -d.

Troubleshooting common errors

  • Unexpected negative power: the clamp is installed backwards. Have the electrician check the K → L direction, with the power off.
  • Power reads 0 while devices are running: the load is below the 30 VA threshold, the clamp goes around live and neutral together, or it is on the wrong circuit.
  • curl returns a 401 error: authentication is enabled. Add --digest -u admin:PASSWORD.
  • 404 on /status: that is the Gen1 API. Use /rpc/EM1.GetStatus?id=0.
  • The Shelly is not discovered: add it manually by IP address. Check that the container uses network_mode: host and that the server and the Shelly are on the same network.
  • No energy data: check that the Shelly has the correct time (SNTP server reachable).

FAQ

Can I plug the Shelly EM Gen3 into an outlet?

No. It is wired to L/N terminals in the electrical panel or in an enclosure, and it measures with clamp-on current transformers. To measure at the outlet, use a plug-in power meter such as the PM 231 E.

Can the Brennenstuhl PM 231 E send its readings to Home Assistant?

No: it has no Wi-Fi or other network interface. It is for one-off, precise readings, device by device, which you record yourself.

What should I measure with the Shelly’s two channels?

For example, the circuit feeding your homelab rack on channel A and a second circuit on channel B. The Shelly EM Gen3 measures single-phase power. A three-phase installation needs a three-phase meter model.

Do I need a Shelly Cloud account?

No. Home Assistant and the RPC API work entirely locally.

Read also

Host this yourself

No hardware to manage? This kind of service runs on a managed VPS, ready in minutes. See PlanetHoster plans

Tags: electricity consumptionmonitoringself-hostingbackupsperformance

Related

Tutorials

Add an NVMe SSD Cache to Your NAS in 2026: Boost Performance

Add an NVMe SSD cache to a Linux NAS with lvmcache (dm-cache): install the SSD, attach it to the LVM volume in writethrough mode, benchmark with fio and track cache hits.

Read
Tutorials

Deploy Immich with Docker in 2026: Complete Guide (HTTPS, Reverse Proxy, Backups)

Step-by-step 2026 tutorial to self-host Immich, the Google Photos alternative, using Docker Compose. Features include photo/video gallery, facial recognition, automatic HTTPS via Caddy and Let's Encrypt, backups, and hardening. Ready-to-use configs included.

Read
Tutorials

Automate the opening of a connected garage with Home Assistant in 2026

Connect a motorized garage door to Home Assistant: a Zigbee contact sensor to know its state, a relay module to operate it, and careful automations (alert when it stays open, light at night).

Read