no message
This commit is contained in:
@@ -231,34 +231,6 @@ class Shelly_Parser_MQTT extends IPSModule
|
||||
/* ---------------------------------------------------------
|
||||
* AUTOMATISCHES ACTION-SCRIPT
|
||||
* ---------------------------------------------------------*/
|
||||
private function EnsureActionScript(): int
|
||||
{
|
||||
$scriptName = "ShellyMQTT_Action_" . $this->InstanceID;
|
||||
|
||||
// existiert bereits?
|
||||
foreach (IPS_GetChildrenIDs($this->InstanceID) as $cid) {
|
||||
$obj = IPS_GetObject($cid);
|
||||
if ($obj['ObjectType'] === OBJECTTYPE_SCRIPT && $obj['ObjectName'] === $scriptName) {
|
||||
return $cid;
|
||||
}
|
||||
}
|
||||
|
||||
// neues Script erzeugen
|
||||
$scriptID = IPS_CreateScript(0);
|
||||
IPS_SetName($scriptID, $scriptName);
|
||||
IPS_SetParent($scriptID, $this->InstanceID);
|
||||
|
||||
$php = '<?php
|
||||
$inst = ' . $this->InstanceID . ';
|
||||
$ident = IPS_GetObject($_IPS["VARIABLE"])["ObjectIdent"];
|
||||
$value = $_IPS["VALUE"];
|
||||
IPS_RequestAction($inst, $ident, $value);
|
||||
?>';
|
||||
|
||||
IPS_SetScriptContent($scriptID, $php);
|
||||
|
||||
return $scriptID;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------
|
||||
* BOOLEAN VARIABLE
|
||||
@@ -271,9 +243,9 @@ IPS_RequestAction($inst, $ident, $value);
|
||||
$o = IPS_GetObject($cid);
|
||||
if ($o['ObjectIdent'] === $ident) {
|
||||
|
||||
// OUTPUT → direkte Modulinstanz als Action
|
||||
if (str_contains($ident, '_output_')) {
|
||||
$actionScript = $this->EnsureActionScript();
|
||||
IPS_SetVariableCustomAction($cid, $actionScript);
|
||||
IPS_SetVariableCustomAction($cid, $this->InstanceID);
|
||||
|
||||
$var = IPS_GetVariable($cid);
|
||||
if ($var['VariableProfile'] === '' && $var['VariableCustomProfile'] === '') {
|
||||
@@ -292,14 +264,14 @@ IPS_RequestAction($inst, $ident, $value);
|
||||
IPS_SetParent($varID, $folderID);
|
||||
|
||||
if (str_contains($ident, '_output_')) {
|
||||
$actionScript = $this->EnsureActionScript();
|
||||
IPS_SetVariableCustomAction($varID, $actionScript);
|
||||
IPS_SetVariableCustomAction($varID, $this->InstanceID);
|
||||
IPS_SetVariableCustomProfile($varID, '~Switch');
|
||||
}
|
||||
|
||||
return $varID;
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------
|
||||
* FLOAT VARIABLE
|
||||
* ---------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user