TapHome

Shelly Plug S

Packet Parser → MQTT
Submitted by
Last updated: 04. 2026
Shelly Plug S

The Shelly Plug S is a compact Wi-Fi smart plug with built-in energy monitoring, rated at 12A / 2500W. TapHome communicates with the device over MQTT — the plug subscribes to a broker and publishes relay state, power consumption, energy counter, and internal temperature data.

The template exposes two devices: an Electric Meter for energy monitoring and a Switch for relay control. A module-level service attribute reports the internal device temperature.

Configuration

Device ID

Each Shelly Plug S has a unique MQTT Device ID in the format shellyplug-s-<MAC6>, where <MAC6> is the last 6 characters of the MAC address in lowercase hex (e.g., shellyplug-s-112233).

The Device ID can be found:

  • In the Shelly web UI: SettingsDevice InfoDevice ID (use the first string of characters, not in brackets)
  • Via API: GET http://<device-ip>/settingsmqtt.id field
Enabling MQTT

To enable MQTT on the Shelly Plug S:

  1. Open the device web interface in a browser (navigate to the device IP address)
  2. Go to Internet and SecurityAdvanced - Developer Settings
  3. Tick “Enable action execution via MQTT”
  4. Fill the “Server” input with {MQTT broker IP}:{port} (default port 1883)
  5. Press SAVE
Template setup

After importing the template in TapHome:

  1. Open the Shelly Plug S MQTT module
  2. Set the MQTT Broker IP and Port (default 1883)
  3. Set the deviceID custom variable to the Device ID of the Shelly Plug S (e.g., 112233 — just the last 6 hex characters of the MAC address)

The module subscribes to shellies/# and the listener scripts filter messages by the configured device ID prefix shellyplug-s-{deviceID}.

Device capabilities

Energy monitoring

The Electric Meter device reads two values from the plug:

  • Total consumption — cumulative energy from the relay/0/energy topic. The device reports energy in Watt-minutes; the template converts to kWh by dividing by 60000.
  • Instantaneous demand — current power draw from the relay/0/power topic. The device reports power in Watts; the template converts to kW by dividing by 1000.

Both values update according to the MQTT reporting interval (default 30 seconds, configurable in the Shelly web UI via mqtt_update_period).

The energy counter resets on device reboot. For persistent energy tracking, use TapHome’s built-in energy logging which stores cumulative values independently of the device counter.

Relay control

The Switch device controls the plug’s relay:

  • Read state — listens to shellies/shellyplug-s-{deviceID}/relay/0 and maps on → 1, off → 0
  • Write state — publishes to shellies/shellyplug-s-{deviceID}/relay/0/command with on or off

The relay supports up to 2500W / 12A load.

Temperature monitoring

A module-level service attribute reports the internal device temperature in °C, read from the shellies/shellyplug-s-{deviceID}/temperature topic. This is the temperature of the plug’s electronics, not ambient room temperature.

Additional capabilities

The Shelly Plug S also publishes an online/offline status via the MQTT LWT topic, overtemperature alerts (when the device exceeds safe operating temperature), a human-readable temperature status classification (Normal/High/Very High), and button input events (short press, long press, double press). These capabilities can be added in a future template update.

Troubleshooting

No data from the plug
  1. Verify the Shelly Plug S is connected to Wi-Fi and MQTT is enabled in the device settings (Internet and SecurityAdvanced - Developer Settings)
  2. Check that the deviceID custom variable matches the Device ID exactly (e.g., 112233)
  3. Use an MQTT client (e.g., MQTT Explorer) to subscribe to shellies/# and verify the plug publishes messages
Power readings show zero
  1. Confirm a load is connected and the relay is switched on
  2. Check the relay/0/power topic with an MQTT client — the value should be non-zero when a load is drawing power
  3. Verify the Electric Meter device shows values in TapHome — total consumption in kWh, demand in kW
Relay not responding to commands
  1. Verify MQTT is enabled and the broker address is correct in the Shelly web UI
  2. Check that TapHome can reach the MQTT broker (correct IP and port in the module settings)
  3. Test by publishing on or off to shellies/shellyplug-s-{deviceID}/relay/0/command via an MQTT client

Gen1 Shelly devices do not support MQTT over TLS. Communication between the plug and the MQTT broker is unencrypted (plain MQTT, port 1883). Ensure the MQTT broker is on a trusted local network.

How to install in TapHome

Prerequisites

  • Shelly device connected to Wi-Fi (see HTTP connection guide if not done yet)
  • 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 & SecurityAdvanced — 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 SettingsMQTT
  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

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 SettingsDevice InfoDevice ID, or on the device label

Step 3 — Configure in TapHome

  1. In TapHome, add a new Packet Parser (MQTT) module
  2. IP Address: enter the MQTT broker IP (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

Shelly Plug S MQTT Module
Service Attributes
TemperatureInternal device temperature — not ambient room temperature
Custom Variables
deviceID (string)MQTT Device ID of the Shelly Plug S — last 6 characters of the MAC address in lowercase hex (find in Shelly web UI → Settings → Device Info)

Shelly plug S MQTT

Listener
VAR whatT := "shellies/shellyplug-s-"+deviceID+"/temperature";
IF (whatT = RECEIVEDMSG.TOPIC)
 temperatureC := TOSTRING(RECEIVEDMSG.PAYLOAD);
END
Service Attributes
Temperature [°C ]
temperatureC
Electric Meter Electricity Meter Read-only

Power consumption and energy metering — instantaneous power (kW) and cumulative energy (kWh)

numeric Unit: kWh (total), kW (demand) energy: Watt-minutes /60000 = kWh; demand: Watts /1000 = kW

Electric Meter

Read total consumption
# Simple HTTP Request:
# VAR response := SENDHTTPREQUEST("/example/getValue");
# IF response.IsSuccess
#  VAR content := response.Content;
#  VAR responseHeaders := response.Headers;
#  RETURN(PARSEXML(content, "//element1/value1"));
# ELSE
#  ADDERROR(response.StatusCode + " (" + response.ReasonPhrase + ")");
#  RETURN(NaN);
# END
#
# Set Http request method, body and headers
# VAR response := SENDHTTPREQUEST("/example/getValue", "GET", "some data", "header1:value1", "header2:value2", ...);
# OR
# VAR request := HTTPREQUEST("/example/getValue", "POST", "some data");
# request.headers := { "header1:value1", "header2:value2", ...};
# request.method := "GET";
# request.data := null;
# VAR response := SENDHTTPREQUEST(request);
#
#
# Send TCP, UDP data:
# VAR data1 := BYTECOLLECTION("0a bb ea df 01");
# SENDDATA(data1);
# VAR data2 := "{\"name\":\"John\", \"age\":32}";
# SENDDATA(data2);
# VAR data3 := TOBYTES("{\"name\":\"John\", \"age\":32}", "iso-8859-1");
# SENDDATA(data3);
# Process received TCP or UDP data and set device values in the Listener script
#
#
# Download data from FTP:
# FTPDOWNLOAD("filePath");
Read demand
# Simple HTTP Request:
# VAR response := SENDHTTPREQUEST("/example/getValue");
# IF response.IsSuccess
#  VAR content := response.Content;
#  VAR responseHeaders := response.Headers;
#  RETURN(PARSEXML(content, "//element1/value1"));
# ELSE
#  ADDERROR(response.StatusCode + " (" + response.ReasonPhrase + ")");
#  RETURN(NaN);
# END
#
# Set Http request method, body and headers
# VAR response := SENDHTTPREQUEST("/example/getValue", "GET", "some data", "header1:value1", "header2:value2", ...);
# OR
# VAR request := HTTPREQUEST("/example/getValue", "POST", "some data");
# request.headers := { "header1:value1", "header2:value2", ...};
# request.method := "GET";
# request.data := null;
# VAR response := SENDHTTPREQUEST(request);
#
#
# Send TCP, UDP data:
# VAR data1 := BYTECOLLECTION("0a bb ea df 01");
# SENDDATA(data1);
# VAR data2 := "{\"name\":\"John\", \"age\":32}";
# SENDDATA(data2);
# VAR data3 := TOBYTES("{\"name\":\"John\", \"age\":32}", "iso-8859-1");
# SENDDATA(data3);
# Process received TCP or UDP data and set device values in the Listener script
#
#
# Download data from FTP:
# FTPDOWNLOAD("filePath");
Listener
VAR whatTo := "shellies/shellyplug-s-"+deviceID+"/relay/0/energy";
IF (whatTo = RECEIVEDMSG.TOPIC)
 To := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD))/60000;
END
VAR whatEd := "shellies/shellyplug-s-"+deviceID+"/relay/0/power";
IF (whatEd = RECEIVEDMSG.TOPIC)
 Ed := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD))/1000;
END
Switch Switch
string on→1, off→0 (read); 1→on, 0→off (write)
Values / States: ON · OFF

Switch

Read switch state
# Simple HTTP Request:
#VAR response := SENDHTTPREQUEST("/example/getValue");
#IF response.IsSuccess
# VAR content := response.Content;
# VAR responseHeaders := response.Headers;
# RETURN(PARSEXML(content, "//element1/value1"));
#ELSE
# ADDERROR(response.StatusCode + " (" + response.ReasonPhrase + ")");
# RETURN(NaN);
# END
#
# Set Http request method, body and headers
# VAR response := SENDHTTPREQUEST("/example/getValue", "GET", "some data", "header1:value1", "header2:value2", ...);
# OR
# VAR request := HTTPREQUEST("/example/getValue", "POST", "some data");
# request.headers := { "header1:value1", "header2:value2", ...};
# request.method := "GET";
# request.data := null;
# VAR response := SENDHTTPREQUEST(request);
#
#
# Send TCP, UDP data:
# VAR data1 := BYTECOLLECTION("0a bb ea df 01");
# SENDDATA(data1);
# VAR data2 := "{\"name\":\"John\", \"age\":32}";
# SENDDATA(data2);
# VAR data3 := TOBYTES("{\"name\":\"John\", \"age\":32}", "iso-8859-1");
# SENDDATA(data3);
# Process received TCP or UDP data and set device values in the Listener script
#
#
# Download data from FTP:
# FTPDOWNLOAD("filePath");
Write switch state
# Simple HTTP Request:
MQTTPUBLISH("shellies/shellyplug-s-"+deviceID+ "/relay/0/command",if(St = 1, "on","off"));
# IF response.IsSuccess = false
#  ADDERROR(response.StatusCode);
# END
#
# Set Http request method, body and headers
# VAR response := SENDHTTPREQUEST("/example/setValue", "GET", "value=" + St, "header1:value1", "header2:value2", ...);\r
# Or VAR request := HTTPREQUEST("/example/setValue");
# request.Method := "PUT";
# VAR response := SENDHTTPREQUEST(request);
#r
#
# Send TCP, UDP data:
# VAR data1 := "{\"name\":\"John\", \"age\":" + St + "}";
# SENDDATA(data1);
# VAR data2 := TOBYTES("{\"name\":\"John\", \"age\":" + St + "}", "iso-8859-1");
# SENDDATA(data2);
# You can process received TCP or UDP data in the Listener script
#
#
# Upload data to FTP:
# FTPUPLOAD("filePath", "somedata=" + St, "write"); # use "append" mode to append data to existing file






#MQTTPUBLISH(topic + "/relay/0/command",if());
Listener
VAR whatSt := "shellies/shellyplug-s-"+deviceID+"/relay/0";
IF (whatSt = RECEIVEDMSG.TOPIC)
 IF (TOSTRING(RECEIVEDMSG.PAYLOAD) = "on")
  St := 1;
 ELSE
  St := 0;
 END
END
Connection: Packet Parser → MQTT
Possible improvements (6)
  • Connection Status — LWT topic — true on connect, false on disconnect. Could detect offline device.
  • Overtemperature Alert — 1 = overheated, 0 = normal. Could trigger safety alarm when device exceeds safe operating temperature.
  • Temperature Status — String: Normal, High, or Very High. Human-readable temperature classification.
  • Button Input State — 0 or 1 — physical button state on the device.
  • Button Input Event — JSON payload with event type (S=short, L=long, SS=double, SSS=triple) and event counter.
  • Overpower State — Relay topic can report 'overpower' payload when load exceeds rating. Not parsed in listener script.

Sources