TapHome
Community Beta Energy & metering

Shelly EM Mini Gen4 MQTT

Shelly EM Mini Gen4 compact single-phase Wi-Fi energy meter over MQTT. TapHome reads power demand, total consumption, returned energy, voltage, current, frequency, power factor and apparent power from status messages — metering only, no relay.

ShellyPacket Parser → MQTT1 deviceRevision 1.0 Last updated: November 30, 2026

Submitted by Martin Keller

Shelly EM Mini Gen4 MQTT

Import into the TapHome appHardware › Packet Parser › Add from template

Download Template
On this page

Network address

With the MQTT broker built into TapHome, it is one broker reached from two places. The template runs directly in the TapHome Core, so in TapHome the broker address is 127.0.0.1 (this computer). The device runs elsewhere in the network, so in the device enter the IP address of the TapHome Core and give the Core an IP reservation in the router — if the Core’s address changes, the device can no longer reach the broker.

Network Preparation

Integration guide

The Shelly EM Mini Gen4 (S4EM-001PXCEU16) is a compact single-phase smart energy meter (29 x 34 x 16 mm) that measures the consumption of one circuit or appliance up to 16 A / 3840 W at 240 V~. It has no relay — it measures only and cannot switch the load. The measured current flows directly through the device, so no current transformer is needed.

TapHome receives the readings over MQTT: the device publishes its status to an MQTT broker on the local network — typically the broker built into the TapHome Core — and the template subscribes to it. No cloud connection is required. The device also supports Zigbee and Matter, but this template needs it connected to Wi-Fi. For reading the same device over HTTP instead of MQTT, see Shelly EM Mini Gen4; for the previous-generation power monitor, see Shelly PM Mini Gen3.

Hardware connection

The device fits into an in-wall box or a wall console and is powered from the measured line (110–240 V~, below 1 W).

TerminalFunction
LLive wire (110–240 V~)
NNeutral wire
OOutput to the measured load — two terminals, bridged internally
  1. Connect the live wire to the L terminal.
  2. Connect the neutral wire to the N terminal.
  3. Connect the load to one of the O terminals and to the neutral wire. The whole load current passes through the device, which is how it is measured.

Strip the wires to 6–7 mm, tighten the screw terminals to max. 0.4 Nm and do not put more than one wire into a single terminal.

Installation on the power grid must be done by a qualified electrician. Switch the circuit breakers off and check with a suitable tester that the wires are dead before connecting. The device and the connected load must be protected by a circuit breaker according to EN 60898-1 — characteristic B or C, max. 16 A rated current. Do not connect a load above 16 A. The device is for indoor use only.

Configuration

Connecting to Wi-Fi

The template needs the device connected to a 2.4 GHz Wi-Fi network.

  1. Press and hold the button on the device for 5 seconds. This turns on its access point and Bluetooth; the access point appears as ShellyEMMiniG4-XXXXXXXX.
  2. Add the device to your Wi-Fi network in one of two ways:
    • in the Shelly Smart Control mobile app, add a new device and follow the app, or
    • connect a phone or computer to the ShellyEMMiniG4-XXXXXXXX network, open http://192.168.33.1 in a browser and enter your Wi-Fi name and password in the device web interface.
  3. After the device joins the network, the manufacturer recommends turning off or password-protecting the device access point.

Holding the button for 10 seconds performs a factory reset — release it at 5 seconds when you only want to enable the access point.

The device ships with Matter firmware by default. Pressing the button five times switches it to Zigbee mode, where its access point is off by default. If the device was switched to Zigbee, return it to Wi-Fi operation as described in the manufacturer’s knowledge base before using this template.

Enabling MQTT

  1. Open the device web interface (http://<device-ip>/) or the device settings in the Shelly Smart Control app.
  2. Go to Settings → MQTT and enable MQTT.
  3. Set Server to the IP address of the TapHome Core and port 1883 (for example 192.168.1.10:1883). If you use another MQTT broker, enter its address instead.
  4. Note the Client ID — by default it is the device ID in the format shellyemminig4-<MAC> (for example shellyemminig4-aabbccddee00). The template uses it as the topic prefix. Leave the MQTT prefix at its default value, or use your own prefix as the device ID in TapHome.
  5. Enable Generic status update over MQTT — it is off by default. Without it the device does not publish <device-id>/status/em1:0 and <device-id>/status/em1data:0, and the template receives no readings.
  6. Click Save and restart the device.

To check that MQTT works, subscribe to <device-id>/# with an MQTT client (for example MQTT Explorer). You should see the topics status/em1:0, status/em1data:0, status/sys, status/wifi and online.

Import in TapHome

When importing the template, fill in three parameters:

ParameterValue
MQTT Broker IP addressAddress of the MQTT broker — 127.0.0.1 (default) is the broker built into the TapHome Core
MQTT Broker port1883 (default)
Shelly device IDTopic prefix of the device, the Client ID from the Shelly MQTT settings, for example shellyemminig4-aabbccddee00

Replace the example device ID with the ID of your device. While the example value shellyemminig4-aabbccddee00 is set, the module shows the error “Set the correct Shelly device ID in module variable ‘deviceId’” and reads nothing; the ID is stored in the deviceId module variable, where you can change it later.

Device capabilities

The template creates one read-only device. The values update whenever the device publishes a new status message.

DeviceName in templateUnitWhat it shows
Energy meterEnergy MeterkWh, kWTotal consumption and current power demand of the measured circuit

Service attributes

The Energy Meter also shows these values as service attributes:

ValueName in templateUnit
Voltageshown in the app languageV
Currentshown in the app languageA
Frequencyshown in the app languageHz
Power factorshown in the app language—
Apparent powershown in the app languageVA
Returned energyReturned energykWh

The module shows the connection details of the device as service attributes:

ValueName in templateWhat it shows
Wi-Fi signal strengthWi-Fi RSSISignal strength in dBm
Wi-Fi networkWi-Fi SSIDName of the Wi-Fi network the device is connected to
IP addressshown in the app languageCurrent IP address of the device
UptimeUptimeTime since the last device restart, in hours

When the device reports that it needs a restart to apply a configuration change, the module shows the warning “Device restart required to apply configuration change.” Restart the Shelly in the device web interface or in the Shelly Smart Control app.

Energy metering

The Energy Meter shows the total consumption in kWh and the current power demand in kW.

The device measures energy in both directions. Returned energy is the energy delivered back to the grid through the measured circuit — for example from a photovoltaic system — and is counted separately from consumption.

Additional capabilities

The device also reports over- and under-limit flags for voltage, current and power, keeps per-minute energy history (available over HTTP with the EM1Data.GetData method, not over MQTT) and can relay Bluetooth (BTHome) sensor data. The template does not use these functions.

Troubleshooting

No readings in TapHome

  1. Check that Generic status update over MQTT is enabled in the Shelly MQTT settings (status_ntf is true in http://<device-ip>/rpc/MQTT.GetConfig). Without it the status/em1:0 and status/em1data:0 topics are never published.
  2. Check that the Server in the Shelly MQTT settings points to the broker set in the template, and that the Core and the Shelly are in the same network or the router allows traffic on port 1883 between them.
  3. Check that the device ID in the template matches the Client ID (topic prefix) of the Shelly exactly.
  4. Subscribe to <device-id>/# with an MQTT client and check that the device publishes messages.

“Set the correct Shelly device ID” error

The deviceId module variable still contains the example value shellyemminig4-aabbccddee00. Set it to the Client ID of your Shelly, which you find in the device web interface under Settings → MQTT → Client ID.

Device shows as offline

The device announces its connection state on the <device-id>/online topic. When it disconnects unexpectedly, the broker publishes false there and the module shows the error “Device is offline (LWT false).” Check the power supply and the Wi-Fi connection of the device, and the Wi-Fi signal strength in the Wi-Fi RSSI service attribute of the module.

Values change only rarely

The Shelly publishes status/em1:0 only when the measured values change noticeably. With a steady load the power value therefore updates rarely. No energy is lost — the total consumption is counted in the device and is updated with every status/em1data:0 message.

How to install in TapHome

Prerequisites

  • Shelly device connected to Wi-Fi (2.4 GHz), e.g. through the Shelly app or the device’s own access point
  • MQTT broker running on your local network (e.g., Mosquitto, Home Assistant, or TapHome built-in broker)
  • TapHome CCU on the same network as the broker

On Gen1 devices, enabling MQTT disables Shelly Cloud. Both cannot run simultaneously. On Gen2/Plus devices this limitation does not apply.

Step 1 — Enable MQTT on the Shelly device

Gen1 devices (Shelly 1, 1PM, 2.5, EM, 3EM, Plug S, RGBW2, Dimmer, TRV…)

  1. Open the Shelly web UI: http://<device-ip>/
  2. Navigate to Internet & Security → Advanced — MQTT
  3. Enable MQTT
  4. Set MQTT Server: <broker-ip>:<port> (e.g., 192.168.1.10:1883)
  5. Optionally set MQTT User and MQTT Password if your broker requires authentication
  6. Click Save — the device will reboot and connect to the broker

Gen2 / Plus devices (Shelly Plus 1, Plus 1PM, Plus 2PM, Plus Plug S, Plus H&T, Pro 3EM…)

  1. Open the Shelly web UI: http://<device-ip>/
  2. Navigate to Settings → MQTT
  3. Enable MQTT
  4. Set Server: <broker-ip>:<port> (e.g., 192.168.1.10:1883)
  5. The Client ID is pre-filled with the device ID (e.g., shellyplus1pm-AABBCCDDEE) — leave as-is unless you have a specific reason to change it
  6. Click Save and reboot the device

With the TapHome built-in broker, <broker-ip> is the IP address of the TapHome Core. Give the Core an IP reservation in the router, otherwise the device loses the broker when the router changes the address → Network Preparation.

To verify MQTT is working, use an MQTT client (e.g., MQTT Explorer) and subscribe to shellies/# (Gen1) or <device-id>/# (Gen2). You should see status messages from the device.

Step 2 — Find the Device ID / MQTT Client ID

Some templates require a Device ID or MQTT Client ID parameter. This is the unique identifier used in MQTT topics.

  • Gen1: found on the label as MAC address (e.g., AABBCCDDEE). Device ID = shelly<model>-<mac>, e.g., shelly1pm-AABBCCDDEE
  • Gen2/Plus: found in the Shelly web UI under Settings → Device Info → Device ID, or on the device label

Step 3 — Configure in TapHome

  1. In TapHome, add a new Packet Parser (MQTT) module
  2. IP Address: 127.0.0.1 for the TapHome built-in broker (the control unit connects to itself, the address never changes); for an external broker its IP address (e.g., 192.168.1.10)
  3. Port: 1883 (default; use 8883 for TLS)
  4. Device ID / MQTT Client ID: enter the value from Step 2 (if required by the template)
  5. Import the template — TapHome will subscribe to the device topics automatically

Available devices 1

These devices appear in TapHome after import.

Shelly EM Mini Gen4 MQTT Module
Service Attributes
Wi-Fi RSSI [dBm]
Wi-Fi SSID
${ipAddress}
Uptime [h]
Custom Variables
deviceId (string)
em1Status (string)
em1dataStatus (string)
sysStatus (string)
wifiStatus (string)

Shelly EM Mini Gen4 MQTT

Read (module)
VAR restartReq := PARSEJSON(sysStatus, "restart_required", true);
IF(!ISNULL(restartReq))
    IF(restartReq = true)
        ADDWARNING("Device restart required to apply configuration change.");
    END
END
Listener
IF(INDEXOF(deviceId, "shellyemminig4-aabbccddee00") = 0)
    ADDERROR("Set the correct Shelly device ID in module variable 'deviceId'. Format: shellyemminig4-<mac>.");
    RETURN(-1);
END

IF(RECEIVEDMSG.TOPIC = deviceId + "/status/em1:0")
    em1Status := TOSTRING(RECEIVEDMSG.PAYLOAD);
ELSEIF(RECEIVEDMSG.TOPIC = deviceId + "/status/em1data:0")
    em1dataStatus := TOSTRING(RECEIVEDMSG.PAYLOAD);
ELSEIF(RECEIVEDMSG.TOPIC = deviceId + "/status/sys")
    sysStatus := TOSTRING(RECEIVEDMSG.PAYLOAD);
ELSEIF(RECEIVEDMSG.TOPIC = deviceId + "/status/wifi")
    wifiStatus := TOSTRING(RECEIVEDMSG.PAYLOAD);
ELSEIF(RECEIVEDMSG.TOPIC = deviceId + "/online")
    IF(TOSTRING(RECEIVEDMSG.PAYLOAD) = "false")
        ADDERROR("Device is offline (LWT false).");
    END
END
Service Attributes
Wi-Fi RSSI [dBm]
VAR v := PARSEJSON(wifiStatus, "rssi", true);
RETURN(IF(ISNULL(v), NaN, v));
Wi-Fi SSID
VAR v := PARSEJSON(wifiStatus, "ssid", true);
RETURN(IF(ISNULL(v), "", v));
${ipAddress}
VAR v := PARSEJSON(wifiStatus, "sta_ip", true);
RETURN(IF(ISNULL(v), "", v));
Uptime [h]
VAR v := PARSEJSON(sysStatus, "uptime", true);
RETURN(IF(ISNULL(v), NaN, ROUND(v / 360) / 10));
Energy Meter Electricity Meter
Service Attributes
${electric_voltage} [V]
${electric_current} [A]
${grid_frequency} [Hz]
${power_factor}
${apparent_power} [VA]
Returned energy [kWh]

Energy Meter

Read total consumption
return(To);
Read demand
return(Ed);
Listener
IF(RECEIVEDMSG.TOPIC = deviceId + "/status/em1:0")
    VAR pwr := PARSEJSON(TOSTRING(RECEIVEDMSG.PAYLOAD), "act_power", true);
    Ed := IF(ISNULL(pwr), NaN, pwr / 1000.0);
ELSEIF(RECEIVEDMSG.TOPIC = deviceId + "/status/em1data:0")
    VAR tot := PARSEJSON(TOSTRING(RECEIVEDMSG.PAYLOAD), "total_act_energy", true);
    To := IF(ISNULL(tot), NaN, tot / 1000.0);
END
Service Attributes
${electric_voltage} [V]
VAR v := PARSEJSON(em1Status, "voltage", true);
RETURN(IF(ISNULL(v), NaN, v));
${electric_current} [A]
VAR v := PARSEJSON(em1Status, "current", true);
RETURN(IF(ISNULL(v), NaN, v));
${grid_frequency} [Hz]
VAR v := PARSEJSON(em1Status, "freq", true);
RETURN(IF(ISNULL(v), NaN, v));
${power_factor}
VAR v := PARSEJSON(em1Status, "pf", true);
RETURN(IF(ISNULL(v), NaN, v));
${apparent_power} [VA]
VAR v := PARSEJSON(em1Status, "aprt_power", true);
RETURN(IF(ISNULL(v), NaN, v));
Returned energy [kWh]
VAR v := PARSEJSON(em1dataStatus, "total_act_ret_energy", true);
RETURN(IF(ISNULL(v), NaN, v / 1000.0));
Connection: Packet Parser → MQTT

Import parameters

Enter these values when you import the XML.

Asked in the appDefault
MQTT Broker IP address127.0.0.1
MQTT Broker port1883
Shelly device ID (topic prefix, e.g. shellyemminig4-aabbccddee00)shellyemminig4-aabbccddee00

Found a problem with this device template?

Tell us what's wrong, what's missing, or how the template should behave. We rely on your feedback to keep the catalog accurate.

Template · TapHome portal Shelly EM Mini Gen4 MQTT Open this template in the Customer Portal to apply it to one of your homes, or to draft a refinement and submit it back to the catalog. Packet Parser → MQTT View in TapHome portal