TapHome

Shelly DUO RGBW MQTT

Packet Parser → MQTT
Eingereicht von
Zuletzt aktualisiert: 04. 2026
Shelly DUO RGBW MQTT

Die Shelly DUO RGBW (Modell SHCB-1) ist ein Gen1-Wi-Fi-Smart-LED-Leuchtmittel, erhältlich in den Formfaktoren E27 und GU10. Es unterstützt volle RGB-Farben und einstellbares Weiß (CCT 3000–6500 K) mit sanften Übergangseffekten. Dies ist die MQTT-Variante der TapHome-Integration — die Vorlage kommuniziert mit den Leuchtmitteln über einen gemeinsamen MQTT-Broker im lokalen Netzwerk. Eine HTTP-Variante ist ebenfalls für Einzelleuchten-Setups verfügbar.

Die Vorlage unterstützt bis zu 5 Shelly DUO RGBW Leuchtmittel pro Modul. Jede Leuchtmittel-Instanz wird durch eine bulbNtopic-Variable unterschieden, die auf die MQTT Device ID des Leuchtmittels verweist. Jedes Leuchtmittel stellt ein RGBW-Lichtgerät und einen Stromzähler bereit — insgesamt 10 Geräte.

Konfiguration

Device ID

Jedes Shelly DUO RGBW Leuchtmittel hat eine eindeutige MQTT Device ID im Format shellycolorbulb-<DEVICEID>, wobei <DEVICEID> von der MAC-Adresse abgeleitet wird (z. B. shellycolorbulb-B929CC).

Die Device ID finden Sie:

  • Auf der Geräteverpackung oder dem Etikett (MAC-Adresse)
  • In der Shelly-Weboberfläche: SettingsDevice Info
  • Über die API: GET http://<device-ip>/settings → Feld mqtt.id
Modulvariablen

Konfigurieren Sie nach dem Import der Vorlage in TapHome die Topic-Variablen der Leuchtmittel:

VariableStandardwertBeschreibung
bulb1topicshellycolorbulb-deviceid1MQTT Device ID für Leuchtmittel 1
bulb2topicshellycolorbulb-deviceid2MQTT Device ID für Leuchtmittel 2
bulb3topicshellycolorbulb-deviceid3MQTT Device ID für Leuchtmittel 3
bulb4topicshellycolorbulb-deviceid4MQTT Device ID für Leuchtmittel 4
bulb5topicshellycolorbulb-deviceid5MQTT Device ID für Leuchtmittel 5

Ersetzen Sie den Standard-Platzhalter durch die tatsächliche Device ID jedes Leuchtmittels (z. B. shellycolorbulb-B929CC). Konfigurieren Sie nur die Slots, die Sie tatsächlich verwenden — unbenutzte Slots mit dem Standard-Platzhalter zeigen eine Fehlermeldung an, die zum Setzen des korrekten Topics auffordert.

Das Modul abonniert shellies/# (QoS 0, Port 1883) und die Listener-Skripte filtern Nachrichten nach dem konfigurierten Topic-Präfix für jedes Leuchtmittel.

Bei Gen1-Shelly-Geräten deaktiviert das Einschalten von MQTT die Shelly Cloud. Beides kann nicht gleichzeitig betrieben werden.

Gerätefunktionen

Lichtsteuerung

Jedes Leuchtmittel wird als HSB-Light-Gerät in TapHome abgebildet. Das Leuchtmittel arbeitet in zwei sich gegenseitig ausschließenden Modi:

  • Farbmodus — volle RGB-Steuerung über Rot-, Grün- und Blaukanal (jeweils 0–255) plus Gain (0–100 %). TapHome konvertiert RGB intern zu HSV — Farbton (0–360°), Sättigung und Helligkeit sind als Steuereigenschaften verfügbar. Das Setzen von Farbton oder Sättigung sendet einen color/0/set JSON-Payload mit "mode":"color".
  • Weißmodus — einstellbares Weiß über Farbtemperatur (3000–6500 K) und Helligkeit (0–100 %). Das Setzen eines CCT-Werts in TapHome schaltet das Leuchtmittel automatisch in den Weißmodus um, indem "mode":"white" mit Temperatur und Helligkeit publiziert wird.

Alle Schreibbefehle enthalten eine konfigurierbare Übergangszeit (Standard 300 ms) für sanftes Dimmen zwischen Zuständen. Ein Debounce-Mechanismus verhindert das Lesen veralteter Daten während Übergängen — die Vorlage ignoriert eingehende MQTT-Statusnachrichten für transitionTime + 3000 ms nach jedem Schreibbefehl.

Leistungsmessung

Jede Leuchtmittel-Instanz enthält einen Stromzähler, der zwei Werte liest:

  • Momentanleistung — von shellies/{id}/light/0/power, gemeldet in Watt, konvertiert zu kW (Payload / 1000)
  • Gesamtverbrauch — von shellies/{id}/light/0/energy, gemeldet in Wattminuten, konvertiert zu kWh (Payload / 60 000)

Die Leistungsmessung erfordert die Konfiguration des Gerätemodells in der Shelly-App oder Weboberfläche unter Settings > Device Model. Ohne diese Konfiguration bleiben die Leistungswerte bei null.

Weitere Funktionen

Die Shelly DUO RGBW unterstützt auch Lichteffekte (Meteor Shower, Gradual Change, Breath, Flash, On/Off Gradual, Red/Green Change), einen dedizierten weißen LED-Kanal (0–255) im Farbmodus, MQTT-Verbindungsstatus über LWT-Topic und einen vollständigen JSON-Statusbericht (Firmware ≥1.8.0) mit Wi-Fi RSSI, Uptime und Temperaturdaten. Diese Funktionen können in einem zukünftigen Vorlagenupdate hinzugefügt werden.

Fehlerbehebung

Leuchtmittel reagieren nicht
  1. Überprüfen Sie, ob MQTT in der Weboberfläche jedes Leuchtmittels aktiviert ist (Internet & Security > Advanced — MQTT)
  2. Bestätigen Sie, dass Broker-Adresse und Port sowohl in den Shelly-Geräteeinstellungen als auch in der TapHome-Modulkonfiguration korrekt sind
  3. Prüfen Sie, ob jede bulbNtopic-Variable exakt der Device ID des Leuchtmittels entspricht (z. B. shellycolorbulb-B929CC)
  4. Verwenden Sie einen MQTT-Client (z. B. MQTT Explorer), abonnieren Sie shellies/# und überprüfen Sie, ob jedes Leuchtmittel Nachrichten publiziert
Farben werden falsch angezeigt
  1. Überprüfen Sie, ob das Leuchtmittel im Farbmodus ist — RGB-Farben funktionieren nur im Farbmodus, nicht im Weißmodus
  2. Stellen Sie sicher, dass die Sättigung größer als null ist — eine Sättigung von 0 erzeugt weißes Licht unabhängig vom Farbton
  3. Prüfen Sie, ob der Gain (Helligkeit im Farbmodus) nicht auf null gesetzt ist
Leistungswerte zeigen null
  1. Bestätigen Sie, dass das Gerätemodell in der Shelly-App oder Weboberfläche konfiguriert ist (Settings > Device Model)
  2. Überprüfen Sie, ob das Leuchtmittel eingeschaltet ist — der Zähler liest nur, wenn das Leuchtmittel Strom bezieht

Gen1-Shelly-Geräte unterstützen kein MQTT über TLS. Die Kommunikation zwischen den Leuchtmitteln und dem MQTT-Broker ist unverschlüsselt (Plain MQTT, Port 1883). Stellen Sie sicher, dass der MQTT-Broker in einem vertrauenswürdigen lokalen Netzwerk betrieben wird.

Installation in TapHome

Voraussetzungen

  • Shelly-Gerät mit Wi-Fi verbunden (siehe HTTP-Verbindungsanleitung, falls noch nicht geschehen)
  • MQTT-Broker in Ihrem lokalen Netzwerk aktiv (z. B. Mosquitto, Home Assistant oder der integrierte TapHome-Broker)
  • TapHome CCU im selben Netzwerk wie der Broker

Auf Gen1-Geräten deaktiviert das Aktivieren von MQTT die Shelly Cloud. Beides kann nicht gleichzeitig betrieben werden. Auf Gen2/Plus-Geräten gilt diese Einschränkung nicht.

Schritt 1 — MQTT auf dem Shelly-Gerät aktivieren

Gen1-Geräte (Shelly 1, 1PM, 2.5, EM, 3EM, Plug S, RGBW2, Dimmer, TRV…)

  1. Öffnen Sie die Shelly-Weboberfläche: http://<device-ip>/
  2. Navigieren Sie zu Internet & SecurityAdvanced — MQTT
  3. Aktivieren Sie MQTT
  4. Setzen Sie MQTT Server: <broker-ip>:<port> (z. B. 192.168.1.10:1883)
  5. Optional setzen Sie MQTT User und MQTT Password, falls Ihr Broker eine Authentifizierung erfordert
  6. Klicken Sie auf Save — das Gerät startet neu und verbindet sich mit dem Broker

Gen2 / Plus-Geräte (Shelly Plus 1, Plus 1PM, Plus 2PM, Plus Plug S, Plus H&T, Pro 3EM…)

  1. Öffnen Sie die Shelly-Weboberfläche: http://<device-ip>/
  2. Navigieren Sie zu SettingsMQTT
  3. Aktivieren Sie MQTT
  4. Setzen Sie Server: <broker-ip>:<port> (z. B. 192.168.1.10:1883)
  5. Die Client ID ist mit der Geräte-ID vorausgefüllt (z. B. shellyplus1pm-AABBCCDDEE) — belassen Sie sie so, es sei denn, Sie haben einen bestimmten Grund zur Änderung
  6. Klicken Sie auf Save und starten Sie das Gerät neu

Um zu überprüfen, ob MQTT funktioniert, verwenden Sie einen MQTT-Client (z. B. MQTT Explorer) und abonnieren Sie shellies/# (Gen1) oder <device-id>/# (Gen2). Sie sollten Statusnachrichten vom Gerät sehen.

Schritt 2 — Device ID / MQTT Client ID ermitteln

Einige Vorlagen erfordern einen Parameter Device ID oder MQTT Client ID. Dies ist die eindeutige Kennung, die in MQTT-Topics verwendet wird.

  • Gen1: auf dem Etikett als MAC-Adresse zu finden (z. B. AABBCCDDEE). Device ID = shelly<model>-<mac>, z. B. shelly1pm-AABBCCDDEE
  • Gen2/Plus: in der Shelly-Weboberfläche unter SettingsDevice InfoDevice ID zu finden, oder auf dem Geräteetikett

Schritt 3 — Konfiguration in TapHome

  1. Fügen Sie in TapHome ein neues Modul Packet Parser (MQTT) hinzu
  2. IP Address: Geben Sie die IP-Adresse des MQTT-Brokers ein (z. B. 192.168.1.10)
  3. Port: 1883 (Standard; verwenden Sie 8883 für TLS)
  4. Device ID / MQTT Client ID: Geben Sie den Wert aus Schritt 2 ein (falls von der Vorlage benötigt)
  5. Importieren Sie die Vorlage — TapHome abonniert automatisch die Geräte-Topics

Verfügbare Geräte

Shelly DUO RGBW MQTT Modul
Benutzerdefinierte Variablen
bulb1topic (string) = shellycolorbulb-deviceid1MQTT-Topic-Name von Leuchtmittel 1 — Format ist 'shellycolorbulb-DEVICEID' (Device ID in Shelly Web UI → Settings → Device Info)
bulb2topic (string) = shellycolorbulb-deviceid2MQTT-Topic-Name von Leuchtmittel 2
bulb3topic (string) = shellycolorbulb-deviceid3MQTT-Topic-Name von Leuchtmittel 3
bulb4topic (string) = shellycolorbulb-deviceid4MQTT-Topic-Name von Leuchtmittel 4
bulb5topic (string) = shellycolorbulb-deviceid5MQTT-Topic-Name von Leuchtmittel 5
Stromzähler 1 Stromzähler Nur lesen

Leistungsmessung für Leuchtmittel 1 — Momentanleistung (kW) und kumulativer Energieverbrauch (kWh)

numeric Einheit: kW / kWh

Stromzähler 1

Listener
ADDINFO("To enable power monitoring, open device settings in Shelly app or web browser and configure device model in Settings->Device Model");

IF(INDEXOF(bulb1topic, "shellycolorbulb-deviceid") = 0)
    ADDERROR("Set correct 'bulb1topic' value in module variables. Topic format is 'shellycolorbulb-<deviceid>'. The Device ID can be found by opening url 'http://shellyIpAddress', in Settings -> Device info.");
    RETURN(-1);
END

IF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb1topic + "/light/0/power") = 0
    Ed := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD)) / 1000.0;
ELSEIF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb1topic + "/light/0/energy") = 0
    To := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD)) / 60000.0;
END
RGBW-Licht 1 HSB-Licht

HSB-Licht mit Dualmodus — volle RGB-Farben mit Gain oder einstellbares Weiß (3000–6500 K) mit Helligkeit

json JSON (ison, mode, red, green, blue, white, gain, temp, brightness, effect)

RGBW-Licht 1

Listener
IF(INDEXOF(bulb1topic, "shellycolorbulb-deviceid") = 0)
    ADDERROR("Set correct 'bulb1topic' value in module variables. Topic format is 'shellycolorbulb-<deviceid>'. The Device ID can be found by opening url 'http://shellyIpAddress', in Settings -> Device info.");
    RETURN(-1);
END

VAR now := NOW();
IF now.Ticks < debounceTimestamp
    RETURN(0);
END

IF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb1topic + "/color/0/status") != 0
    RETURN(0);
END

IF RECEIVEDMSG.PAYLOAD.LENGTH = 0
    RETURN(0);
END

BOOL ison := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.ison", 1);
VAR mode := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.mode", 1);

IF ISNULL(mode)
    RETURN(0);
END

INT bright;

IF mode = "color"
    UINT8 red := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.red");
    UINT8 green := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.green");
    UINT8 blue := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.blue");
    bright := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.gain");
    
    VAR hsvColor := RGBTOHSV(red, green, blue);
    
    Hd := ROUND(hsvColor.Hue);
    Sa := ROUND(hsvColor.Saturation * 100.0) / 100.0;
    Ct := NaN;
ELSE
    Ct := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.temp");
    bright := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.brightness");
END

IF ison
    Hb:= bright / 100.0;
    St := isOn;
ELSE
    Hb := 0;
    St := 0;
END
Helligkeit schreiben
VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

IF St > 0.5
    VAR topic := "shellies/" + bulb1topic + "/color/0/set";
    
	IF ISNAN(Ct)
        MQTTPUBLISH(topic, "{\"turn\": \"on\", \"transition\": " + transitionTime + ", \"gain\": " + ROUND(Hb*100.0) + "}");
    ELSE
        MQTTPUBLISH(topic, "{\"turn\": \"on\", \"transition\": " + transitionTime + ", \"brightness\": " + ROUND(Hb*100.0) + "}");
        
    END
ELSE
    MQTTPUBLISH("shellies/" + bulb1topic + "/color/0/command", "off");
END
Farbton schreiben
IF !ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb1topic + "/color/0/set";
VAR rgbColor := HSVTORGB(Hd, Sa, 1);

VAR data := "{\"mode\": \"color\", \"gain\": " + ROUND(Hb*100.0) + ", \"transition\":" + transitionTime + ",\"red\":" + rgbColor.red + ",\"green\":" + rgbColor.green + ",\"blue\":" + rgbColor.blue + "}";

MQTTPUBLISH(topic, data);
Sättigung schreiben
IF !ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb1topic + "/color/0/set";
VAR rgbColor := HSVTORGB(Hd, Sa, 1);

VAR data := "{\"mode\": \"color\", \"gain\": " + ROUND(Hb*100.0) + ", \"transition\":" + transitionTime + ",\"red\":" + rgbColor.red + ",\"green\":" + rgbColor.green + ",\"blue\":" + rgbColor.blue + "}";

MQTTPUBLISH(topic, data);
Farbtemperatur schreiben
IF ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb1topic + "/color/0/set";

MQTTPUBLISH(topic, "{\"mode\": \"white\", \"brightness\": " + ROUND(Hb*100.0) + ", \"transition\": " + transitionTime + ", \"temp\":" + Ct + "}");
Stromzähler 2 Stromzähler Nur lesen

Leistungsmessung für Leuchtmittel 2 — Momentanleistung (kW) und kumulativer Energieverbrauch (kWh)

numeric Einheit: kW / kWh

Stromzähler 2

Listener
ADDINFO("To enable power monitoring, open device settings in Shelly app or web browser and configure device model in Settings->Device Model");

IF(INDEXOF(bulb2topic, "shellycolorbulb-deviceid") = 0)
    ADDERROR("Set correct 'bulb2topic' value in module variables. Topic format is 'shellycolorbulb-<deviceid>'. The Device ID can be found by opening url 'http://shellyIpAddress', in Settings -> Device info.");
    RETURN(-1);
END

IF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb2topic + "/light/0/power") = 0
    Ed := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD)) / 1000.0;
ELSEIF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb2topic + "/light/0/energy") = 0
    To := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD)) / 60000.0;
END
RGBW-Licht 2 HSB-Licht

HSB-Licht mit Dualmodus — volle RGB-Farben mit Gain oder einstellbares Weiß (3000–6500 K) mit Helligkeit

json JSON (ison, mode, red, green, blue, white, gain, temp, brightness, effect)

RGBW-Licht 2

Listener
IF(INDEXOF(bulb2topic, "shellycolorbulb-deviceid") = 0)
    ADDERROR("Set correct 'bulb2topic' value in module variables. Topic format is 'shellycolorbulb-<deviceid>'. The Device ID can be found by opening url 'http://shellyIpAddress', in Settings -> Device info.");
    RETURN(-1);
END

VAR now := NOW();
IF now.Ticks < debounceTimestamp
    RETURN(0);
END

IF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb2topic + "/color/0/status") != 0
    RETURN(0);
END

IF RECEIVEDMSG.PAYLOAD.LENGTH = 0
    RETURN(0);
END

BOOL ison := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.ison", 1);
VAR mode := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.mode", 1);

IF ISNULL(mode)
    RETURN(0);
END

INT bright;

IF mode = "color"
    UINT8 red := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.red");
    UINT8 green := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.green");
    UINT8 blue := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.blue");
    bright := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.gain");
    
    VAR hsvColor := RGBTOHSV(red, green, blue);
    
    Hd := ROUND(hsvColor.Hue);
    Sa := ROUND(hsvColor.Saturation * 100.0) / 100.0;
    Ct := NaN;
ELSE
    Ct := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.temp");
    bright := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.brightness");
END

IF ison
    Hb:= bright / 100.0;
    St := isOn;
ELSE
    Hb := 0;
    St := 0;
END
Helligkeit schreiben
VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

IF St > 0.5
    VAR topic := "shellies/" + bulb2topic + "/color/0/set";
    
	IF ISNAN(Ct)
        MQTTPUBLISH(topic, "{\"turn\": \"on\", \"transition\": " + transitionTime + ", \"gain\": " + ROUND(Hb*100.0) + "}");
    ELSE
        MQTTPUBLISH(topic, "{\"turn\": \"on\", \"transition\": " + transitionTime + ", \"brightness\": " + ROUND(Hb*100.0) + "}");
        
    END
ELSE
    MQTTPUBLISH("shellies/" + bulb2topic + "/color/0/command", "off");
END
Farbton schreiben
IF !ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb2topic + "/color/0/set";
VAR rgbColor := HSVTORGB(Hd, Sa, 1);

VAR data := "{\"mode\": \"color\", \"gain\": " + ROUND(Hb*100.0) + ", \"transition\":" + transitionTime + ",\"red\":" + rgbColor.red + ",\"green\":" + rgbColor.green + ",\"blue\":" + rgbColor.blue + "}";

MQTTPUBLISH(topic, data);
Sättigung schreiben
IF !ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb2topic + "/color/0/set";
VAR rgbColor := HSVTORGB(Hd, Sa, 1);

VAR data := "{\"mode\": \"color\", \"gain\": " + ROUND(Hb*100.0) + ", \"transition\":" + transitionTime + ",\"red\":" + rgbColor.red + ",\"green\":" + rgbColor.green + ",\"blue\":" + rgbColor.blue + "}";

MQTTPUBLISH(topic, data);
Farbtemperatur schreiben
IF ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb2topic + "/color/0/set";

MQTTPUBLISH(topic, "{\"mode\": \"white\", \"brightness\": " + ROUND(Hb*100.0) + ", \"transition\": " + transitionTime + ", \"temp\":" + Ct + "}");
Stromzähler 3 Stromzähler Nur lesen

Leistungsmessung für Leuchtmittel 3 — Momentanleistung (kW) und kumulativer Energieverbrauch (kWh)

numeric Einheit: kW / kWh

Stromzähler 3

Listener
ADDINFO("To enable power monitoring, open device settings in Shelly app or web browser and configure device model in Settings->Device Model");

IF(INDEXOF(bulb2topic, "shellycolorbulb-deviceid") = 0)
    ADDERROR("Set correct 'bulb3topic' value in module variables. Topic format is 'shellycolorbulb-<deviceid>'. The Device ID can be found by opening url 'http://shellyIpAddress', in Settings -> Device info.");
    RETURN(-1);
END

IF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb3topic + "/light/0/power") = 0
    Ed := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD)) / 1000.0;
ELSEIF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb3topic + "/light/0/energy") = 0
    To := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD)) / 60000.0;
END
RGBW-Licht 3 HSB-Licht

HSB-Licht mit Dualmodus — volle RGB-Farben mit Gain oder einstellbares Weiß (3000–6500 K) mit Helligkeit

json JSON (ison, mode, red, green, blue, white, gain, temp, brightness, effect)

RGBW-Licht 3

Listener
IF(INDEXOF(bulb3topic, "shellycolorbulb-deviceid") = 0)
    ADDERROR("Set correct 'bulb3topic' value in module variables. Topic format is 'shellycolorbulb-<deviceid>'. The Device ID can be found by opening url 'http://shellyIpAddress', in Settings -> Device info.");
    RETURN(-1);
END

VAR now := NOW();
IF now.Ticks < debounceTimestamp
    RETURN(0);
END

IF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb3topic + "/color/0/status") != 0
    RETURN(0);
END

IF RECEIVEDMSG.PAYLOAD.LENGTH = 0
    RETURN(0);
END

BOOL ison := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.ison", 1);
VAR mode := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.mode", 1);

IF ISNULL(mode)
    RETURN(0);
END

INT bright;

IF mode = "color"
    UINT8 red := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.red");
    UINT8 green := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.green");
    UINT8 blue := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.blue");
    bright := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.gain");
    
    VAR hsvColor := RGBTOHSV(red, green, blue);
    
    Hd := ROUND(hsvColor.Hue);
    Sa := ROUND(hsvColor.Saturation * 100.0) / 100.0;
    Ct := NaN;
ELSE
    Ct := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.temp");
    bright := PARSEJSON(RECEIVEDMSG.PAYLOADStatus, "$.brightness");
END

IF ison
    Hb:= bright / 100.0;
    St := isOn;
ELSE
    Hb := 0;
    St := 0;
END
Helligkeit schreiben
VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

IF St > 0.5
    VAR topic := "shellies/" + bulb3topic + "/color/0/set";
    
	IF ISNAN(Ct)
        MQTTPUBLISH(topic, "{\"turn\": \"on\", \"transition\": " + transitionTime + ", \"gain\": " + ROUND(Hb*100.0) + "}");
    ELSE
        MQTTPUBLISH(topic, "{\"turn\": \"on\", \"transition\": " + transitionTime + ", \"brightness\": " + ROUND(Hb*100.0) + "}");
        
    END
ELSE
    MQTTPUBLISH("shellies/" + bulb3topic + "/color/0/command", "off");
END
Farbton schreiben
IF !ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb3topic + "/color/0/set";
VAR rgbColor := HSVTORGB(Hd, Sa, 1);

VAR data := "{\"mode\": \"color\", \"gain\": " + ROUND(Hb*100.0) + ", \"transition\":" + transitionTime + ",\"red\":" + rgbColor.red + ",\"green\":" + rgbColor.green + ",\"blue\":" + rgbColor.blue + "}";

MQTTPUBLISH(topic, data);
Sättigung schreiben
IF !ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb3topic + "/color/0/set";
VAR rgbColor := HSVTORGB(Hd, Sa, 1);

VAR data := "{\"mode\": \"color\", \"gain\": " + ROUND(Hb*100.0) + ", \"transition\":" + transitionTime + ",\"red\":" + rgbColor.red + ",\"green\":" + rgbColor.green + ",\"blue\":" + rgbColor.blue + "}";

MQTTPUBLISH(topic, data);
Farbtemperatur schreiben
IF ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb3topic + "/color/0/set";

MQTTPUBLISH(topic, "{\"mode\": \"white\", \"brightness\": " + ROUND(Hb*100.0) + ", \"transition\": " + transitionTime + ", \"temp\":" + Ct + "}");
Stromzähler 4 Stromzähler Nur lesen

Leistungsmessung für Leuchtmittel 4 — Momentanleistung (kW) und kumulativer Energieverbrauch (kWh)

numeric Einheit: kW / kWh

Stromzähler 4

Listener
ADDINFO("To enable power monitoring, open device settings in Shelly app or web browser and configure device model in Settings->Device Model");

IF(INDEXOF(bulb2topic, "shellycolorbulb-deviceid") = 0)
    ADDERROR("Set correct 'bulb4topic' value in module variables. Topic format is 'shellycolorbulb-<deviceid>'. The Device ID can be found by opening url 'http://shellyIpAddress', in Settings -> Device info.");
    RETURN(-1);
END

IF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb4topic + "/light/0/power") = 0
    Ed := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD)) / 1000.0;
ELSEIF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb4topic + "/light/0/energy") = 0
    To := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD)) / 60000.0;
END
RGBW-Licht 4 HSB-Licht

HSB-Licht mit Dualmodus — volle RGB-Farben mit Gain oder einstellbares Weiß (3000–6500 K) mit Helligkeit

json JSON (ison, mode, red, green, blue, white, gain, temp, brightness, effect)

RGBW-Licht 4

Listener
IF(INDEXOF(bulb4topic, "shellycolorbulb-deviceid") = 0)
    ADDERROR("Set correct 'bulb4topic' value in module variables. Topic format is 'shellycolorbulb-<deviceid>'. The Device ID can be found by opening url 'http://shellyIpAddress', in Settings -> Device info.");
    RETURN(-1);
END

VAR now := NOW();
IF now.Ticks < debounceTimestamp
    RETURN(0);
END

IF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb4topic + "/color/0/status") != 0
    RETURN(0);
END

IF RECEIVEDMSG.PAYLOAD.LENGTH = 0
    RETURN(0);
END

BOOL ison := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.ison", 1);
VAR mode := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.mode", 1);

IF ISNULL(mode)
    RETURN(0);
END

INT bright;

IF mode = "color"
    UINT8 red := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.red");
    UINT8 green := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.green");
    UINT8 blue := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.blue");
    bright := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.gain");
    
    VAR hsvColor := RGBTOHSV(red, green, blue);
    
    Hd := ROUND(hsvColor.Hue);
    Sa := ROUND(hsvColor.Saturation * 100.0) / 100.0;
    Ct := NaN;
ELSE
    Ct := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.temp");
    bright := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.brightness");
END

IF ison
    Hb:= bright / 100.0;
    St := isOn;
ELSE
    Hb := 0;
    St := 0;
END
Helligkeit schreiben
VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

IF St > 0.5
    VAR topic := "shellies/" + bulb4topic + "/color/0/set";
    
	IF ISNAN(Ct)
        MQTTPUBLISH(topic, "{\"turn\": \"on\", \"transition\": " + transitionTime + ", \"gain\": " + ROUND(Hb*100.0) + "}");
    ELSE
        MQTTPUBLISH(topic, "{\"turn\": \"on\", \"transition\": " + transitionTime + ", \"brightness\": " + ROUND(Hb*100.0) + "}");
        
    END
ELSE
    MQTTPUBLISH("shellies/" + bulb4topic + "/color/0/command", "off");
END
Farbton schreiben
IF !ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb4topic + "/color/0/set";
VAR rgbColor := HSVTORGB(Hd, Sa, 1);

VAR data := "{\"mode\": \"color\", \"gain\": " + ROUND(Hb*100.0) + ", \"transition\":" + transitionTime + ",\"red\":" + rgbColor.red + ",\"green\":" + rgbColor.green + ",\"blue\":" + rgbColor.blue + "}";

MQTTPUBLISH(topic, data);
Sättigung schreiben
IF !ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb4topic + "/color/0/set";
VAR rgbColor := HSVTORGB(Hd, Sa, 1);

VAR data := "{\"mode\": \"color\", \"gain\": " + ROUND(Hb*100.0) + ", \"transition\":" + transitionTime + ",\"red\":" + rgbColor.red + ",\"green\":" + rgbColor.green + ",\"blue\":" + rgbColor.blue + "}";

MQTTPUBLISH(topic, data);
Farbtemperatur schreiben
IF ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb4topic + "/color/0/set";

MQTTPUBLISH(topic, "{\"mode\": \"white\", \"brightness\": " + ROUND(Hb*100.0) + ", \"transition\": " + transitionTime + ", \"temp\":" + Ct + "}");
Stromzähler 5 Stromzähler Nur lesen

Leistungsmessung für Leuchtmittel 5 — Momentanleistung (kW) und kumulativer Energieverbrauch (kWh)

numeric Einheit: kW / kWh

Stromzähler 5

Listener
ADDINFO("To enable power monitoring, open device settings in Shelly app or web browser and configure device model in Settings->Device Model");

IF(INDEXOF(bulb2topic, "shellycolorbulb-deviceid") = 0)
    ADDERROR("Set correct 'bulb5topic' value in module variables. Topic format is 'shellycolorbulb-<deviceid>'. The Device ID can be found by opening url 'http://shellyIpAddress', in Settings -> Device info.");
    RETURN(-1);
END

IF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb5topic + "/light/0/power") = 0
    Ed := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD)) / 1000.0;
ELSEIF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb5topic + "/light/0/energy") = 0
    To := TODOUBLE(TOSTRING(RECEIVEDMSG.PAYLOAD)) / 60000.0;
END
RGBW-Licht 5 HSB-Licht

HSB-Licht mit Dualmodus — volle RGB-Farben mit Gain oder einstellbares Weiß (3000–6500 K) mit Helligkeit

json JSON (ison, mode, red, green, blue, white, gain, temp, brightness, effect)

RGBW-Licht 5

Listener
IF(INDEXOF(bulb5topic, "shellycolorbulb-deviceid") = 0)
    ADDERROR("Set correct 'bulb5topic' value in module variables. Topic format is 'shellycolorbulb-<deviceid>'. The Device ID can be found by opening url 'http://shellyIpAddress', in Settings -> Device info.");
    RETURN(-1);
END

VAR now := NOW();
IF now.Ticks < debounceTimestamp
    RETURN(0);
END

IF INDEXOF(RECEIVEDMSG.TOPIC, "shellies/" + bulb5topic + "/color/0/status") != 0
    RETURN(0);
END

IF RECEIVEDMSG.PAYLOAD.LENGTH = 0
    RETURN(0);
END

BOOL ison := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.ison", 1);
VAR mode := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.mode", 1);

IF ISNULL(mode)
    RETURN(0);
END

INT bright;

IF mode = "color"
    UINT8 red := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.red");
    UINT8 green := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.green");
    UINT8 blue := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.blue");
    bright := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.gain");
    
    VAR hsvColor := RGBTOHSV(red, green, blue);

    Hd := ROUND(hsvColor.Hue);
    Sa := ROUND(hsvColor.Saturation * 100.0) / 100.0;
    Ct := NaN;
ELSE
    Ct := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.temp");
    bright := PARSEJSON(RECEIVEDMSG.PAYLOAD, "$.brightness");
END

IF ison
    Hb:= bright / 100.0;
    St := isOn;
ELSE
    Hb := 0;
    St := 0;
END
Helligkeit schreiben
VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

IF St > 0.5
    VAR topic := "shellies/" + bulb5topic + "/color/0/set";
    
	IF ISNAN(Ct)
        MQTTPUBLISH(topic, "{\"turn\": \"on\", \"transition\": " + transitionTime + ", \"gain\": " + ROUND(Hb*100.0) + "}");
    ELSE
        MQTTPUBLISH(topic, "{\"turn\": \"on\", \"transition\": " + transitionTime + ", \"brightness\": " + ROUND(Hb*100.0) + "}");
        
    END
ELSE
    MQTTPUBLISH("shellies/" + bulb5topic + "/color/0/command", "off");
END
Farbton schreiben
IF !ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb5topic + "/color/0/set";
VAR rgbColor := HSVTORGB(Hd, Sa, 1);

VAR data := "{\"mode\": \"color\", \"gain\": " + ROUND(Hb*100.0) + ", \"transition\":" + transitionTime + ",\"red\":" + rgbColor.red + ",\"green\":" + rgbColor.green + ",\"blue\":" + rgbColor.blue + "}";

MQTTPUBLISH(topic, data);
Sättigung schreiben
IF !ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb5topic + "/color/0/set";
VAR rgbColor := HSVTORGB(Hd, Sa, 1);

VAR data := "{\"mode\": \"color\", \"gain\": " + ROUND(Hb*100.0) + ", \"transition\":" + transitionTime + ",\"red\":" + rgbColor.red + ",\"green\":" + rgbColor.green + ",\"blue\":" + rgbColor.blue + "}";

MQTTPUBLISH(topic, data);
Farbtemperatur schreiben
IF ISNAN(Ct)
    RETURN(0);
END

VAR now := NOW();
debounceTimestamp := now.Ticks + transitionTime + 3000;

VAR topic := "shellies/" + bulb5topic + "/color/0/set";

MQTTPUBLISH(topic, "{\"mode\": \"white\", \"brightness\": " + ROUND(Hb*100.0) + ", \"transition\": " + transitionTime + ", \"temp\":" + Ct + "}");
Verbindung: Packet Parser → MQTT
Mögliche Verbesserungen (4)
  • Connection Status — LWT topic — true on connect, false on disconnect. Could detect offline bulbs.
  • Full Status JSON — Complete /status as JSON (fw ≥1.8.0). Could parse wifi_sta.rssi, uptime, temperature.
  • Light Effects — Effect index 0–6: off, meteors, gradual change, breath, flash, on/off gradual, red/green change. Not exposed in template.
  • White Channel (RGBW) — Separate white LED channel (0–255) in color mode. Template uses RGB+gain only, white channel not exposed.

Quellen