---
title: "Shelly 3EM"
description: "Shelly 3EM with three CT clamps: per-phase power, voltage, current, energy and power factor plus contactor relay in TapHome, locally via HTTP or MQTT."
url: "https://taphome.com/en/compatibility/shelly-3em-gen1/"
language: en
lastmod: 2026-03-29
generator: hugo
ai:
  topics: ["http","mqtt","electric-meter","3-phase","wifi","energy-metering","mdns"]
  questions: ["How to integrate Shelly 3EM with TapHome?","What does the Shelly 3EM TapHome template measure per phase?","How to connect Shelly 3EM via HTTP to TapHome?","Can I use the Shelly 3EM MQTT template instead of HTTP?","Does the Shelly 3EM template support bidirectional metering for solar?","How to reset energy counters on the Shelly 3EM from TapHome?"]
---

# Shelly 3EM

Communication: Packet Parser → HTTP

- [Shelly 3EM Product Page](https://www.shelly.com/en/products/shop/shelly-3em)

> Network address
> 
> TapHome reaches this device at the address entered on import. Give the device a fixed address — an IP reservation in the router, or its mDNS name if it supports one — otherwise the integration stops working when the router changes the address.
> 
> [Network Preparation](https://taphome.com/en/docs/setup/network-preparation/)

## Integration guide

The Shelly 3EM is a Wi-Fi 3-phase energy meter with three 120 A CT (current transformer) clamps and a built-in 10 A contactor relay. It monitors active power, voltage, current, power factor, and cumulative energy for each phase independently. TapHome communicates with the device over the local network — no cloud connection is required.

Two TapHome templates are available for this device: an **HTTP template** (default, uses REST API polling) and an **MQTT template** (uses broker-based message subscription). Both templates provide the same set of devices — 3 energy meters (one per phase) and 1 contactor switch. Choose one protocol based on the installation requirements.

## Hardware connection

The Shelly 3EM requires mains power (110–230 V AC) connected to the **L** and **N** terminals. Each of the three included CT clamps connects to the **CT1**, **CT2**, and **CT3** terminals respectively. The contactor relay output is on the **O** terminal (10 A max).

### CT clamp installation

- Each CT clamp clips around the **live wire** of the circuit to monitor — no wire cutting required
- The arrow on the CT clamp must point in the direction of current flow (from source to load)
- CT clamps can monitor a 3-phase system (L1, L2, L3) or three independent mono-phase circuits

> [!WARNING]
> Do NOT connect a CT clamp to the live wire before wiring it to the Shelly 3EM. High voltage may be present across the transformer's connection cables even if only the transformer is connected.

### Contactor control

The relay output (**O** terminal) is rated for 10 A and can directly switch small loads or drive an external contactor coil for switching higher loads.

## Configuration

### HTTP template setup

During template import, enter the device's IP address. The template polls three separate endpoints (`/emeter/0`, `/emeter/1`, `/emeter/2`) for per-phase energy data and `/relay/0` for contactor state. Each phase response is cached in a custom variable (`emeter0`, `emeter1`, `emeter2`) to minimize HTTP calls per poll cycle.

### MQTT template setup

The MQTT template requires three import parameters:

| Parameter | Description | Example |
|-----------|-------------|---------|
| **MQTT Broker IP** | Address of the MQTT broker | `192.168.1.10` |
| **MQTT Broker Port** | Broker port (default 1883) | `1883` |
| **Device ID** | MAC address suffix used in MQTT topics | `B929CC` |

The Device ID (`dID`) is the last 6 characters of the MAC address in uppercase hex. It can be found in the Shelly web UI under **Settings** → **Device Info**, or via `GET http://{ip}/settings` → `mqtt.id` field.

The module subscribes to `shellies/shellyem3-{dID}/#` and listener scripts route per-phase emeter and relay messages to the corresponding devices.

> [!NOTE]
> The MQTT template uses the topic prefix `shellyem3-{dID}` while official API documentation references `shelly3em-{id}`. Both formats work — the `dID` variable is user-configurable. Verify the actual topic prefix by subscribing to `shellies/#` with an MQTT client.

> [!WARNING]
> On Gen1 Shelly devices, enabling MQTT **disables Shelly Cloud**. Both cannot run simultaneously. This is a firmware limitation.

## Device capabilities

### Per-phase energy metering

The template creates three electric meter devices — one for each phase. Each meter reads:

- **Active power** — instantaneous power in W, converted to kW by the template (÷ 1000)
- **Total energy consumed** — cumulative energy in Wh, converted to kWh by the template (÷ 1000)

In the HTTP template, each phase is read from its `/emeter/{i}` endpoint. In the MQTT template, the values arrive on `shellies/shellyem3-{dID}/emeter/{i}/power` and `.../total` topics.

### Per-phase electrical parameters

Each energy meter exposes four service attributes:

- **Voltage** — RMS voltage (V)
- **Current** — RMS current (A)
- **Power factor** — ratio of active to apparent power (0.00–1.00)
- **Total returned energy** — energy returned to the grid in Wh, useful for solar/PV installations with bidirectional metering

### Energy counter reset

Each phase has a **Reset total** service action that clears the energy counters for that specific phase. In HTTP mode this calls `/emeter/{i}?reset_totals`; in MQTT mode it publishes `reset_totals` to the `shellies/shellyem3-{dID}/emeter/{i}/command` topic.

### Contactor switch

The template exposes the contactor relay as a switch device. The relay state is read from `/relay/0` → `ison` (HTTP) or the `shellies/shellyem3-{dID}/relay/0` topic (MQTT), and controlled via `/relay/0?turn=on|off` (HTTP) or the `.../relay/0/command` topic (MQTT).

### Additional capabilities

The Shelly 3EM also provides reactive power (VAR), a measurement validity flag per phase (`is_valid`), total 3-phase power sum (`total_power` from `/status`), WiFi signal strength, device uptime, firmware update status, per-phase overpower thresholds, and historical energy data export (CSV). An auto-off timer is available on the contactor relay. These capabilities can be added in a future template update.

## Troubleshooting

### Device not responding (HTTP)

1. Verify the Shelly 3EM is connected to Wi-Fi and has a valid IP address
2. Open `http://{device-ip}/shelly` in a browser — if it responds, the device is reachable
3. Check that TapHome Core and the Shelly 3EM are on the same network / VLAN

### No MQTT messages received

1. Confirm MQTT is enabled in the Shelly web UI (**Internet & Security** → **Advanced — MQTT**)
2. Verify the broker address and port are correct in both the Shelly device and TapHome template
3. Check the `dID` custom variable matches the actual device ID — subscribe to `shellies/#` with an MQTT client to verify the topic prefix the device uses
4. Ensure the MQTT broker is running and accessible from both the Shelly and TapHome Core

### Energy readings show zero or NaN

1. Confirm CT clamps are properly connected to the Shelly 3EM terminals (CT1, CT2, CT3) and clamped around live wires
2. Verify the CT clamp arrow points in the correct direction (source to load)
3. Poll `/emeter/0` manually and check the `is_valid` field — `false` indicates a disconnected or faulty CT clamp
4. Check `power` and `total` values — if both are 0, there may be no load on that circuit

> [!WARNING]
> Gen1 Shelly devices support only **2 concurrent HTTP connections**. If TapHome and another system (e.g., Home Assistant) poll the same device simultaneously, communication may become unreliable. Consider using the MQTT template if multiple systems need to monitor the device.

## How to install in TapHome

### Prerequisites

- Shelly device installed and powered on
- Local Wi-Fi network (2.4 GHz)
- TapHome CCU on the same network

### Step 1 — Connect Shelly to Wi-Fi

**Option A — Shelly app (recommended):**

1. Download the [Shelly app](https://www.shelly.com/en/support/shelly-app) (iOS / Android)
2. Tap **+** → **Add Device** and follow the Bluetooth pairing wizard
3. Enter your Wi-Fi credentials when prompted

**Option B — AP mode (no app):**

1. On first power-up the device creates a hotspot: `ShellyXXX-AABBCCDDEE`
2. Connect your phone/PC to that hotspot
3. Open `http://192.168.33.1` → **Internet & Security** → **Wi-Fi Mode - Client**
4. Enter SSID and password → **Save**

> [!NOTE]
> Shelly only supports **2.4 GHz** networks. 5 GHz networks will not appear in the scan.

### Step 2 — Find the device address

Shelly Gen1 devices support **mDNS** (Zeroconf). You can reach the device using a hostname instead of an IP address:

```
shelly<model>-<MAC>.local
```

For example: `shelly1pm-AABBCCDDEE.local` (MAC address in uppercase hex, no colons).

> [!TIP]
> **Recommended: use the TapHome IP Scanner.** Open the TapHome app and use the **IP Scanner** (Settings → Network → Scan). The scanner will discover devices on your network and show both the IP address and the mDNS hostname. Use the **hostname** instead of the IP address for a more reliable connection — it stays the same even if the device's IP changes after a router reboot.

**Alternative methods** to find the IP address:

- **Shelly app:** Device detail → **Device info** → IP address
- **Shelly web UI:** Connect to the device AP before Wi-Fi setup — the IP is shown after saving
- **Router DHCP table:** Look for a hostname like `shelly1pm-AABBCCDDEE`

### Step 3 — Configure in TapHome

1. In TapHome, add a new **Packet Parser (HTTP)** module
2. **Address:** enter the mDNS hostname (e.g., `shelly1pm-AABBCCDDEE.local`) or IP address from Step 2
3. **Port:** `80` (default, no change needed)
4. Import the template — TapHome will poll `/status` to read device state

> [!NOTE]
> HTTP authentication is disabled by default on Shelly devices. If you have enabled login protection, TapHome does not support HTTP Basic Auth at this time — keep auth disabled for TapHome integration.

## Available devices 4

These devices appear in TapHome after import.

Shelly 3EM Module

Custom Variables

Electric Meter (Phase 1) Electricity Meter Read-only

Phase 1 energy monitoring — active power (kW), cumulative energy (kWh), voltage, current, power factor, and returned energy

numeric Unit: W / kWh

Service Attributes

|                             |                                                                                               |
|-----------------------------|-----------------------------------------------------------------------------------------------|
| Power factor                |                                                                                               |
| Current \[A]                |                                                                                               |
| Voltage \[V]                |                                                                                               |
| Total returned energy \[Wh] | Energy returned to the grid — relevant for solar/PV installations with bidirectional metering |

Service Actions

|             |
|-------------|
| Reset total |

Read total consumption

```taphome
RETURN(todouble(PARSEjson(emeter0, "total"))/1000);
```

Read demand

```taphome
RETURN(todouble(PARSEjson(emeter0, "power"))/1000);
```

Read (module)

```taphome
VAR response := SENDHTTPREQUEST("/emeter/0");
IF response.IsSuccess
 emeter0 := response.Content;
ELSE
 ADDERROR(response.StatusCode + " (" + response.ReasonPhrase + ")");
 RETURN(NaN);
END
```

Service Attributes

power factor

```taphome
RETURN(todouble(PARSEjson(emeter0, "pf")));
```

Current \[A]

```taphome
RETURN(PARSEjson(emeter0, "current"));
```

voltage \[V]

```taphome
RETURN(PARSEjson(emeter0, "voltage"));
```

Total returned energy \[Wh]

```taphome
RETURN(PARSEjson(emeter0, "total_returned"));
```

Service Actions

Reset total

```taphome
sendhttprequest("/emeter/0?reset_totals");
```

Electric Meter (Phase 2) Electricity Meter Read-only

Phase 2 energy monitoring — active power (kW), cumulative energy (kWh), voltage, current, power factor, and returned energy

numeric Unit: W / kWh

Service Attributes

|                             |                                                                                               |
|-----------------------------|-----------------------------------------------------------------------------------------------|
| Power factor                |                                                                                               |
| Current \[A]                |                                                                                               |
| Voltage \[V]                |                                                                                               |
| Total returned energy \[Wh] | Energy returned to the grid — relevant for solar/PV installations with bidirectional metering |

Service Actions

|             |
|-------------|
| Reset total |

Read total consumption

```taphome
RETURN(todouble(PARSEjson(emeter1, "total"))/1000);
```

Read demand

```taphome
RETURN(todouble(PARSEjson(emeter1, "power"))/1000);
```

Read (module)

```taphome
VAR response := SENDHTTPREQUEST("/emeter/1");
IF response.IsSuccess
 emeter1 := response.Content;
ELSE
 ADDERROR(response.StatusCode + " (" + response.ReasonPhrase + ")");
 RETURN(NaN);
END
```

Service Attributes

power factor

```taphome
RETURN(PARSEjson(emeter1, "pf"));
```

current [A[

```taphome
RETURN(PARSEjson(emeter1, "current"));
```

voltage \[V]

```taphome
RETURN(PARSEjson(emeter1, "voltage"));
```

total returned energy \[Wh]

```taphome
RETURN(PARSEjson(emeter1, "total_returned"));
```

Service Actions

reset total

```taphome
sendhttprequest("/emeter/1?reset_totals");
```

Electric Meter (Phase 3) Electricity Meter Read-only

Phase 3 energy monitoring — active power (kW), cumulative energy (kWh), voltage, current, power factor, and returned energy

numeric Unit: W / kWh

Service Attributes

|                             |                                                                                               |
|-----------------------------|-----------------------------------------------------------------------------------------------|
| Power factor                |                                                                                               |
| Current \[A]                |                                                                                               |
| Voltage \[V]                |                                                                                               |
| Total returned energy \[Wh] | Energy returned to the grid — relevant for solar/PV installations with bidirectional metering |

Service Actions

|             |
|-------------|
| Reset total |

Read total consumption

```taphome
RETURN(todouble(PARSEjson(emeter2, "total"))/1000);
```

Read demand

```taphome
RETURN(todouble(PARSEjson(emeter2, "power"))/1000);
```

Read (module)

```taphome
var response := SENDHTTPREQUEST("/emeter/2");
IF response.IsSuccess
 emeter2 := response.Content;
ELSE
 ADDERROR(response.StatusCode + " (" + response.ReasonPhrase + ")");
 RETURN(NaN);
END
```

Service Attributes

power factor

```taphome
RETURN(PARSEjson(emeter2, "pf"));
```

current \[A]

```taphome
RETURN(PARSEjson(emeter2, "current"));
```

voltage \[V]

```taphome
RETURN(PARSEjson(emeter2, "voltage"));
```

Total returned energy \[Wh]

```taphome
RETURN(PARSEjson(emeter2, "total_returned"));
```

Service Actions

reset total

```taphome
sendhttprequest("/emeter/2?reset_totals");
```

Contactor Switch Switch Read and write

Built-in 10 A contactor relay for load switching or external contactor control

boolean

Values / States: ON · OFF

Read switch state

```taphome
VAR response := SENDHTTPREQUEST("/relay/0");
IF response.IsSuccess
 VAR content := response.Content;
 VAR responseHeaders := response.Headers;
 RETURN(PARSEjson(content, "ison"));
ELSE
 ADDERROR(response.StatusCode + " (" + response.ReasonPhrase + ")");
 RETURN(NaN);
END
```

Write switch state

```taphome
VAR response := SENDHTTPREQUEST("/relay/0?turn=" + switch(St,1,"on","off"));
IF response.IsSuccess = false
 ADDERROR(response.StatusCode);
END
```

**Connection:** Packet Parser → HTTP • Hostname: `shelly3em-{MAC}.local`

Possible improvements (10)

- Reactive Power — Per-phase reactive power in VAR; available in /emeter/ response and via MQTT topic .../emeter/{i}/reactive\_power
- Measurement Validity — Boolean flag indicating whether CT clamp measurement is valid; useful for detecting disconnected CT
- Total Power (3-phase sum) — Sum of active power across all 3 phases in W; available in /status but not in per-phase /emeter/ endpoints
- WiFi Signal Strength — WiFi RSSI in dBm
- Uptime — Device uptime in seconds; available in /status but template only polls /emeter/ endpoints, not /status
- FW Update Available — Firmware update flag from /status
- Auto-off Timer — Auto-off timer in seconds on contactor relay
- Per-phase Power Protection — Per-phase overpower threshold; could be exposed as service attribute + action
- Historical Energy Data (CSV) — Per-phase historical data export as CSV; not applicable for real-time integration
- Reset All Energy History — Clears ALL stored energy history across all 3 phases; more destructive than per-phase reset\_totals

## Import parameters

Enter these values when you import the XML.

| Asked in the app | Default       |
|------------------|---------------|
| IP address       | `192.168.0.1` |

## Sources

- Shelly Gen1 API Reference
  
  [shelly-api-docs.shelly.cloud](https://shelly-api-docs.shelly.cloud/gen1/) 2026-03-12
- Home Assistant Shelly Integration
  
  [www.home-assistant.io](https://www.home-assistant.io/integrations/shelly/) 2026-03-12
- Shelly 3EM API — emeter endpoints
  
  [shelly-api-docs.shelly.cloud](https://shelly-api-docs.shelly.cloud/gen1/#shelly-3em) 2026-03-29
- Shelly 3EM Knowledge Base — specs & wiring
  
  [kb.shelly.cloud](https://kb.shelly.cloud/knowledge-base/shelly-3em) 2026-03-29

## Related Documentation

- [Packet Parser Integration](https://taphome.com/en/compatibility/packet-parser-guide/)
- [Packet Parser (HTTP, TCP, UDP, FTP, MQTT)](https://taphome.com/en/docs/integration/packet-parser/)
- [Packet parser functions](https://taphome.com/en/docs/script/packet-parser/)
- [Parsing functions](https://taphome.com/en/docs/script/parsing-functions/)

