From a6759ec95e0ab3e4f7e8a1a651bdff682cbcf536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=A4fliger?= Date: Fri, 14 Nov 2025 10:20:13 +0100 Subject: [PATCH] no message --- Shelly_Parser_MQTT/module.php | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/Shelly_Parser_MQTT/module.php b/Shelly_Parser_MQTT/module.php index e794d2d..d6da48d 100644 --- a/Shelly_Parser_MQTT/module.php +++ b/Shelly_Parser_MQTT/module.php @@ -73,32 +73,41 @@ class Shelly_Parser_MQTT extends IPSModule * ---------------------------------------------------------*/ public function RequestAction($Ident, $Value) { - // Output? z.B. BE_1_3_14_output_0 if (str_contains($Ident, '_output_')) { - SetValue(IPS_GetObjectIDByIdent($Ident, $this->FindDeviceFolder($Ident)), $Value); + // Lokale Variable setzen + $varID = $this->FindVariableByIdent($Ident); + if ($varID) { + SetValue($varID, $Value); + } - // Device & Index extrahieren + // device + index ermitteln $parts = explode('_output_', $Ident); $deviceID = $parts[0]; $index = (int)$parts[1]; - $topic = $deviceID . '/rpc/Switch.Set'; + // GEN3 / GEN4 / PRO → Switch.Set muss im rpc-Root gesendet werden + $topic = $deviceID . '/rpc'; $payload = json_encode([ - 'id' => $index, - 'on' => (bool)$Value + "id" => 1, + "src" => "ips", + "method" => "Switch.Set", + "params" => [ + "id" => $index, + "on" => (bool)$Value + ] ]); $this->Publish($topic, $payload); + + IPS_LogMessage("Shelly_Parser_MQTT", "SEND → $topic : $payload"); return; } - - // andere Variablen (falls nötig) - throw new Exception("Unknown Ident $Ident"); } + /* --------------------------------------------------------- * RECEIVE MQTT DATA * ---------------------------------------------------------*/ @@ -295,7 +304,7 @@ class Shelly_Parser_MQTT extends IPSModule return $folderID; } - + private function FindDeviceFolder(string $Ident): int { foreach (IPS_GetChildrenIDs($this->InstanceID) as $folder) {