From ffa5cd811249a44238c4483cb18951bc9a86e27b Mon Sep 17 00:00:00 2001 From: "belevo\\dh" Date: Mon, 24 Nov 2025 11:22:40 +0100 Subject: [PATCH] no message --- Shelly_Parser_MQTT/module.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Shelly_Parser_MQTT/module.php b/Shelly_Parser_MQTT/module.php index ce4d793..d2775fb 100644 --- a/Shelly_Parser_MQTT/module.php +++ b/Shelly_Parser_MQTT/module.php @@ -243,12 +243,36 @@ class Shelly_Parser_MQTT extends IPSModule IPS_SetParent($vid, $folder); } - // OUTPUT → Switch-UI + Action + // OUTPUT: Switch-Profil + ActionScript if (str_contains($ident, '_output_')) { + IPS_SetVariableCustomProfile($vid, '~Switch'); - IPS_SetVariableCustomAction($vid, $this->InstanceID); + + // Action Script suchen / erstellen + $scriptIdent = $ident . "_action"; + $scriptID = @IPS_GetObjectIDByIdent($scriptIdent, $folder); + + if ($scriptID === false) { + $scriptID = IPS_CreateScript(0); // 0 = PHP Script + IPS_SetParent($scriptID, $folder); + IPS_SetIdent($scriptID, $scriptIdent); + IPS_SetName($scriptID, $name . " Action"); + + $code = << + EOF; + + IPS_SetScriptContent($scriptID, $code); + } + + // Variable zeigt auf dieses Action-Script + IPS_SetVariableCustomAction($vid, $scriptID); } + return $vid; }