
The Shelly EM is a single-phase energy meter with two independent metering channels and a 2A relay output for contactor control. Each channel connects to an external CT (current transformer) clamp – available in 50A and 120A variants – allowing non-invasive monitoring of two separate circuits simultaneously. This template connects to the device via an MQTT broker on the local network. No cloud connection is required.
The template exposes three devices: two electric meters (one per CT channel) tracking cumulative energy consumption, and a switch for the contactor relay.
Configuration
Device ID
The Shelly EM uses a Device ID in the format shellyem-XXXXXX, where XXXXXX is the last 6 characters of the MAC address in uppercase hex (e.g., shellyem-B929CC). During template import, enter only the hex part (e.g., B929CC) into the Device ID parameter.
The Device ID can be found:
- In the Shelly web UI: Settings > Device Info
- Via API:
GET http://<device-ip>/settings– themqtt.idfield
This device supports mDNS discovery. You can use the hostname
shellyem-{MAC}.localinstead of an IP address when configuring the MQTT broker. Replace{MAC}with the full MAC address in lowercase hex (e.g.,shellyem-b929cc.local). Using a hostname prevents connectivity issues when the device’s IP address changes.
MQTT setup
Before importing the template, enable MQTT on the Shelly EM:
- Open the Shelly web UI at
http://<device-ip> - Go to Internet & Security > Advanced — Developer Settings
- Tick Enable action execution via MQTT
- In the Server field, enter the MQTT broker address in the format
broker-ip:1883 - Press SAVE
On Gen1 Shelly devices, enabling MQTT disables Shelly Cloud. Both cannot run simultaneously.
Template setup
After importing the template in TapHome:
- Set the MQTT Broker IP to the address of your MQTT broker
- Set the MQTT Broker Port (default
1883) - Set the Device ID to the Shelly EM’s Device ID hex part (e.g.,
B929CC)
The module subscribes to shellies/# and the listener scripts on each device filter messages by the configured Device ID.
Device capabilities
Energy metering (per channel)
Each channel is exposed as an independent Electric Meter device in TapHome. The listener script subscribes to two MQTT topics per channel:
| Topic | Unit | Description |
|---|---|---|
emeter/{i}/energy | watt-minutes | Cumulative energy since last reboot – divided by 60 000 to convert to kWh |
emeter/{i}/total | Wh | Persistent total energy consumed – survives reboots |
The template stores both values: Ed (energy from the watt-minutes topic, converted to kWh) and To (total in Wh from the persistent topic).
The
energytopic resets to zero on device reboot. For persistent energy tracking, the template also reads thetotaltopic which survives reboots.
Each channel also exposes a Voltage service attribute, which reads the RMS line voltage from the emeter/{i}/voltage MQTT topic.
The
readtotalconsumptionandreaddemandscripts are commented-out boilerplate – all energy data comes through the MQTT listener. This means the template does not provide instantaneous power readings (W). Only cumulative energy (kWh) and total consumed (Wh) are tracked. Instantaneous active power is available via theemeter/{i}/powerMQTT topic but is not subscribed to by this template.
Contactor relay
The relay output is exposed as a switch device in TapHome. The relay is rated 2A / 230 VAC – it is designed for contactor control only, not for direct load switching.
- Read: subscribes to
shellies/shellyem-{id}/relay/0– payloadonmaps to ON,offmaps to OFF - Write: publishes
onorofftoshellies/shellyem-{id}/relay/0/command
The relay is rated only 2A. Always use an external contactor for loads exceeding this rating. Direct connection of high-power loads will damage the relay.
Troubleshooting
No energy data
- Verify MQTT is enabled in the Shelly web UI (Internet & Security > Advanced – MQTT)
- Confirm the MQTT broker address and port are correct in both the Shelly device and TapHome module settings
- Check that the Device ID custom variable matches the Shelly’s Device ID exactly (e.g.,
B929CC) - Use an MQTT client (e.g., MQTT Explorer) to subscribe to
shellies/#and verify the device publishesemeter/0/energyandemeter/1/energytopics
Only one channel reporting data
- Verify the CT clamp is connected to the correct 3.5mm jack (channel 0 or channel 1)
- Check that current is flowing through the monitored conductor – the CT clamp must encircle a single conductor, not the entire cable
- Subscribe to
shellies/shellyem-{id}/emeter/0/#andshellies/shellyem-{id}/emeter/1/#separately to confirm both channels publish data
Relay not responding
- Check that the Shelly EM is powered and connected to the MQTT broker
- Publish
onoroffmanually toshellies/shellyem-{id}/relay/0/commandvia an MQTT client to test relay operation independently from TapHome - Verify the relay output is wired correctly (check terminal labels on the device)
Gen1 Shelly devices do not support MQTT over TLS. Communication between the device and the MQTT broker is unencrypted (plain MQTT, port 1883). Ensure the MQTT broker is on a trusted local network.