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).
| Terminal | Function |
|---|---|
| L | Live wire (110–240 V~) |
| N | Neutral wire |
| O | Output to the measured load — two terminals, bridged internally |
- Connect the live wire to the L terminal.
- Connect the neutral wire to the N terminal.
- 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.
- 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. - 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-XXXXXXXXnetwork, openhttp://192.168.33.1in a browser and enter your Wi-Fi name and password in the device web interface.
- 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
- Open the device web interface (
http://<device-ip>/) or the device settings in the Shelly Smart Control app. - Go to Settings → MQTT and enable MQTT.
- Set Server to the IP address of the TapHome Core and port
1883(for example192.168.1.10:1883). If you use another MQTT broker, enter its address instead. - Note the Client ID — by default it is the device ID in the format
shellyemminig4-<MAC>(for exampleshellyemminig4-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. - Enable Generic status update over MQTT — it is off by default. Without it the device does not publish
<device-id>/status/em1:0and<device-id>/status/em1data:0, and the template receives no readings. - 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 topicsstatus/em1:0,status/em1data:0,status/sys,status/wifiandonline.
Import in TapHome
When importing the template, fill in three parameters:
| Parameter | Value |
|---|---|
| MQTT Broker IP address | Address of the MQTT broker — 127.0.0.1 (default) is the broker built into the TapHome Core |
| MQTT Broker port | 1883 (default) |
| Shelly device ID | Topic 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.
| Device | Name in template | Unit | What it shows |
|---|---|---|---|
| Energy meter | Energy Meter | kWh, kW | Total consumption and current power demand of the measured circuit |
Service attributes
The Energy Meter also shows these values as service attributes:
| Value | Name in template | Unit |
|---|---|---|
| Voltage | shown in the app language | V |
| Current | shown in the app language | A |
| Frequency | shown in the app language | Hz |
| Power factor | shown in the app language | — |
| Apparent power | shown in the app language | VA |
| Returned energy | Returned energy | kWh |
The module shows the connection details of the device as service attributes:
| Value | Name in template | What it shows |
|---|---|---|
| Wi-Fi signal strength | Wi-Fi RSSI | Signal strength in dBm |
| Wi-Fi network | Wi-Fi SSID | Name of the Wi-Fi network the device is connected to |
| IP address | shown in the app language | Current IP address of the device |
| Uptime | Uptime | Time 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
- Check that Generic status update over MQTT is enabled in the Shelly MQTT settings (
status_ntfistrueinhttp://<device-ip>/rpc/MQTT.GetConfig). Without it thestatus/em1:0andstatus/em1data:0topics are never published. - 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.
- Check that the device ID in the template matches the Client ID (topic prefix) of the Shelly exactly.
- 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.
