---
title: "Shelly Plug S"
description: "Monitoraggio del consumo energetico, controllo relè e lettura della temperatura via MQTT. Template di integrazione TapHome per la presa Shelly Plug S."
url: "https://taphome.com/it/compatibility/shelly-plug-s-mqtt/"
language: it
lastmod: 2026-03-31
generator: hugo
ai:
  topics: ["mqtt","smart-plug","wifi","energy-monitoring","relay-control"]
  questions: ["Come integrare lo Shelly Plug S con TapHome tramite MQTT?","Cosa misura il template Shelly Plug S in TapHome?","Come trovare il Device ID MQTT dello Shelly Plug S?","Perché il mio Shelly Plug S non riporta i dati di potenza?","Come controllare il relè dello Shelly Plug S da TapHome?","Il template Shelly Plug S riporta il consumo energetico in kWh?"]
---

# Shelly Plug S

Comunicazione: Packet Parser → MQTT

- [Pagina prodotto Shelly Plug S](https://www.shelly.com/en/products/shop/shelly-plug-s)

> Indirizzo di rete
> 
> Con il broker MQTT integrato in TapHome, inserisci `127.0.0.1` come indirizzo del broker in TapHome. Nel dispositivo inserisci l’indirizzo IP del TapHome Core e assegna al Core una prenotazione IP nel router.
> 
> [Preparazione della rete](https://taphome.com/it/docs/setup/network-preparation/)

## Guida all'integrazione

Lo Shelly Plug S è una presa Wi-Fi intelligente compatta con monitoraggio energetico integrato, con portata nominale di 12A / 2500W. TapHome comunica con il dispositivo tramite MQTT — la presa si connette a un broker e pubblica lo stato del relè, il consumo energetico, il contatore di energia e i dati sulla temperatura interna.

Il template espone due dispositivi: un Contatore elettrico per il monitoraggio energetico e un Interruttore per il controllo del relè. Un attributo di servizio a livello di modulo riporta la temperatura interna del dispositivo.

## Configurazione

### Device ID

Ogni Shelly Plug S ha un Device ID MQTT univoco nel formato `shellyplug-s-<MAC6>`, dove `<MAC6>` sono gli ultimi 6 caratteri dell'indirizzo MAC in esadecimale minuscolo (es. `shellyplug-s-112233`).

Il Device ID si trova:

- Nell'interfaccia web Shelly: **Settings** → **Device Info** → **Device ID** (usare la prima stringa di caratteri, non quella tra parentesi)
- Tramite API: `GET http://<device-ip>/settings` → campo `mqtt.id`

### Abilitare MQTT

Per abilitare MQTT sullo Shelly Plug S:

1. Aprire l'interfaccia web del dispositivo nel browser (navigare all'indirizzo IP del dispositivo)
2. Andare su **Internet and Security** → **Advanced - Developer Settings**
3. Selezionare **"Enable action execution via MQTT"**
4. Compilare il campo **"Server"** con `{IP broker MQTT}:{porta}` (porta predefinita `1883`)
5. Premere **SAVE**

### Configurazione del template

Dopo aver importato il template in TapHome:

1. Aprire il modulo **Shelly Plug S MQTT**
2. Impostare **MQTT Broker IP** e **Port** (predefinito `1883`)
3. Impostare la variabile **deviceID** sul Device ID dello Shelly Plug S (es. `112233` — solo gli ultimi 6 caratteri esadecimali dell'indirizzo MAC)

Il modulo si iscrive a `shellies/#` e gli script listener filtrano i messaggi in base al prefisso Device ID configurato `shellyplug-s-{deviceID}`.

## Funzionalità del dispositivo

### Monitoraggio energetico

Il dispositivo Contatore elettrico legge due valori dalla presa:

- **Consumo totale** — energia cumulativa dal topic `relay/0/energy`. Il dispositivo riporta l'energia in watt-minuti; il template converte in kWh dividendo per 60000.
- **Potenza istantanea** — assorbimento corrente dal topic `relay/0/power`. Il dispositivo riporta la potenza in Watt; il template converte in kW dividendo per 1000.

Entrambi i valori si aggiornano secondo l'intervallo di reporting MQTT (predefinito 30 secondi, configurabile nell'interfaccia web Shelly tramite `mqtt_update_period`).

> [!TIP]
> Il contatore di energia si azzera al riavvio del dispositivo. Per un monitoraggio energetico persistente, utilizzare il logging energetico integrato di TapHome che memorizza i valori cumulativi indipendentemente dal contatore del dispositivo.

### Controllo relè

Il dispositivo Interruttore controlla il relè della presa:

- **Lettura stato** — ascolta il topic `shellies/shellyplug-s-{deviceID}/relay/0` e mappa `on` → 1, `off` → 0
- **Scrittura stato** — pubblica sul topic `shellies/shellyplug-s-{deviceID}/relay/0/command` con `on` o `off`

Il relè supporta un carico fino a 2500W / 12A.

### Monitoraggio temperatura

Un attributo di servizio a livello di modulo riporta la temperatura interna del dispositivo in °C, letta dal topic `shellies/shellyplug-s-{deviceID}/temperature`. Si tratta della temperatura dell'elettronica della presa, non della temperatura ambiente.

### Funzionalità aggiuntive

Lo Shelly Plug S pubblica anche lo stato online/offline tramite il topic MQTT LWT, avvisi di surriscaldamento (quando il dispositivo supera la temperatura operativa sicura), una classificazione leggibile dello stato della temperatura (Normal/High/Very High) ed eventi del pulsante (pressione breve, lunga, doppia). Queste funzionalità potranno essere aggiunte in un futuro aggiornamento del template.

## Risoluzione dei problemi

### Nessun dato dalla presa

1. Verificare che lo Shelly Plug S sia connesso al Wi-Fi e che MQTT sia abilitato nelle impostazioni del dispositivo (**Internet and Security** → **Advanced - Developer Settings**)
2. Controllare che la variabile **deviceID** corrisponda esattamente al Device ID (es. `112233`)
3. Utilizzare un client MQTT (es. MQTT Explorer) per iscriversi a `shellies/#` e verificare che la presa pubblichi messaggi

### I valori di potenza mostrano zero

1. Confermare che un carico è collegato e il relè è acceso
2. Controllare il topic `relay/0/power` con un client MQTT — il valore dovrebbe essere diverso da zero quando un carico assorbe energia
3. Verificare che il dispositivo Contatore elettrico mostri valori in TapHome — consumo totale in kWh, potenza in kW

### Il relè non risponde ai comandi

1. Verificare che MQTT sia abilitato e l'indirizzo del broker sia corretto nell'interfaccia web Shelly
2. Controllare che TapHome possa raggiungere il broker MQTT (IP e porta corretti nelle impostazioni del modulo)
3. Testare pubblicando `on` o `off` sul topic `shellies/shellyplug-s-{deviceID}/relay/0/command` tramite un client MQTT

> [!WARNING]
> I dispositivi Shelly Gen1 **non** supportano MQTT su TLS. La comunicazione tra la presa e il broker MQTT non è crittografata (plain MQTT, porta 1883). Assicurarsi che il broker MQTT sia su una rete locale affidabile.

## Come installare in TapHome

### Prerequisiti

- Dispositivo Shelly connesso al Wi-Fi (2,4 GHz), ad es. tramite l'app Shelly o l'access point del dispositivo stesso
- Broker MQTT attivo sulla rete locale (es. Mosquitto, Home Assistant o il broker integrato di TapHome)
- TapHome CCU sulla stessa rete del broker

> [!WARNING]
> Sui dispositivi **Gen1**, l'attivazione di MQTT **disabilita Shelly Cloud**. Entrambi non possono funzionare contemporaneamente. Sui dispositivi Gen2/Plus questa limitazione non si applica.

### Passaggio 1 — Abilitare MQTT sul dispositivo Shelly

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

1. Apri l'interfaccia web Shelly: `http://<device-ip>/`
2. Vai su **Internet & Security** → **Advanced — MQTT**
3. Abilita **MQTT**
4. Imposta **MQTT Server**: `<broker-ip>:<port>` (es. `192.168.1.10:1883`)
5. Opzionalmente imposta **MQTT User** e **MQTT Password** se il broker richiede l'autenticazione
6. Clicca su **Save** — il dispositivo si riavvierà e si connetterà al broker

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

1. Apri l'interfaccia web Shelly: `http://<device-ip>/`
2. Vai su **Settings** → **MQTT**
3. Abilita **MQTT**
4. Imposta **Server**: `<broker-ip>:<port>` (es. `192.168.1.10:1883`)
5. Il **Client ID** è precompilato con l'ID del dispositivo (es. `shellyplus1pm-AABBCCDDEE`) — lascialo così a meno che tu non abbia un motivo specifico per cambiarlo
6. Clicca su **Save** e riavvia il dispositivo

Con il broker integrato di TapHome, `<broker-ip>` è l'indirizzo IP del TapHome Core. Assegna al Core una prenotazione IP nel router, altrimenti il dispositivo perde il broker quando il router cambia l'indirizzo → [Preparazione della rete](https://taphome.com/it/docs/setup/network-preparation/).

> [!TIP]
> Per verificare che MQTT funzioni, usa un client MQTT (es. MQTT Explorer) e sottoscrivi `shellies/#` (Gen1) o `<device-id>/#` (Gen2). Dovresti vedere i messaggi di stato dal dispositivo.

### Passaggio 2 — Trovare il Device ID / MQTT Client ID

Alcuni template richiedono un parametro **Device ID** o **MQTT Client ID**. Questo è l'identificatore univoco utilizzato nei topic MQTT.

- **Gen1:** si trova sull'etichetta come indirizzo MAC (es. `AABBCCDDEE`). Device ID = `shelly<model>-<mac>`, es. `shelly1pm-AABBCCDDEE`
- **Gen2/Plus:** si trova nell'interfaccia web Shelly sotto **Settings** → **Device Info** → **Device ID**, oppure sull'etichetta del dispositivo

### Passaggio 3 — Configurazione in TapHome

1. In TapHome, aggiungi un nuovo modulo **Packet Parser (MQTT)**
2. **IP Address:** `127.0.0.1` per il broker integrato di TapHome (l'unità di controllo si connette a sé stessa, l'indirizzo non cambia mai); per un broker esterno il suo indirizzo IP (es. `192.168.1.10`)
3. **Port:** `1883` (predefinito; usa `8883` per TLS)
4. **Device ID / MQTT Client ID:** inserisci il valore dal passaggio 2 (se richiesto dal template)
5. Importa il template — TapHome si sottoscriverà automaticamente ai topic del dispositivo

## Dispositivi disponibili 2

Questi dispositivi compaiono in TapHome dopo l'importazione.

Shelly Plug S MQTT Modulo

Attributi di servizio

|             |                                                                   |
|-------------|-------------------------------------------------------------------|
| Temperatura | Temperatura interna del dispositivo — non la temperatura ambiente |

Variabili personalizzate

|                     |                                                                                                                                                                     |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `deviceID` (string) | Device ID MQTT dello Shelly Plug S — ultimi 6 caratteri dell'indirizzo MAC in esadecimale minuscolo (si trova nell'interfaccia web Shelly → Settings → Device Info) |

Listener

```taphome
VAR whatT := "shellies/shellyplug-s-"+deviceID+"/temperature";
IF (whatT = RECEIVEDMSG.TOPIC)
 temperatureC := TOSTRING(RECEIVEDMSG.PAYLOAD);
END
```

Attributi di servizio

Temperature \[°C ]

```taphome
temperatureC
```

Contatore elettrico Contatore elettrico Solo lettura

Misurazione consumo ed energia — potenza istantanea (kW) ed energia cumulativa (kWh)

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

Lettura consumo totale

```taphome
# 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");
```

Lettura domanda

```taphome
# 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

```taphome
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
```

Interruttore Interruttore Lettura e scrittura

string on→1, off→0 (read); 1→on, 0→off (write)

Valori / Stati: ON · OFF

Lettura stato interruttore

```taphome
# 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");
```

Scrittura stato interruttore

```taphome
# 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

```taphome
VAR whatSt := "shellies/shellyplug-s-"+deviceID+"/relay/0";
IF (whatSt = RECEIVEDMSG.TOPIC)
 IF (TOSTRING(RECEIVEDMSG.PAYLOAD) = "on")
  St := 1;
 ELSE
  St := 0;
 END
END
```

**Connessione:** Packet Parser → MQTT

Possibili miglioramenti (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.

## Parametri di importazione

Inserisci questi valori quando importi l'XML.

| Richiesto nell'app       | Predefinito                  |
|--------------------------|------------------------------|
| Mqtt Broker Indirizzo IP | `192.168.0.1`                |
| Mqtt Broker port         | `1883`                       |
| Device ID                | Da inserire all'importazione |

## Fonti

- 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 Plug S — Device-Specific MQTT API
  
  [shelly-api-docs.shelly.cloud](https://shelly-api-docs.shelly.cloud/gen1/#shelly-plug-plugs-mqtt) 2026-03-31

## Documentazione correlata

- [MQTT Integration](https://taphome.com/it/compatibility/mqtt-guide/)
- [Packet Parser (HTTP, TCP, UDP, FTP, MQTT)](https://taphome.com/it/docs/integration/packet-parser/)
- [Funzioni Packet parser](https://taphome.com/it/docs/script/packet-parser/)
- [Funzioni di parsing](https://taphome.com/it/docs/script/parsing-functions/)
- [Broker MQTT](https://taphome.com/it/docs/integration/packet-parser/mqtt-broker/)
- [Script listener](https://taphome.com/it/docs/script/listener-scripts/)

