no message
This commit is contained in:
@@ -231,75 +231,47 @@ 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
|
||||
* ---------------------------------------------------------*/
|
||||
private function EnsureBooleanVariable(string $deviceID, string $ident, string $name): int
|
||||
{
|
||||
$folderID = $this->GetDeviceFolder($deviceID);
|
||||
private function EnsureBooleanVariable(string $deviceID, string $ident, string $name): int
|
||||
{
|
||||
$folderID = $this->GetDeviceFolder($deviceID);
|
||||
|
||||
foreach (IPS_GetChildrenIDs($folderID) as $cid) {
|
||||
$o = IPS_GetObject($cid);
|
||||
if ($o['ObjectIdent'] === $ident) {
|
||||
foreach (IPS_GetChildrenIDs($folderID) as $cid) {
|
||||
$o = IPS_GetObject($cid);
|
||||
if ($o['ObjectIdent'] === $ident) {
|
||||
|
||||
if (str_contains($ident, '_output_')) {
|
||||
$actionScript = $this->EnsureActionScript();
|
||||
IPS_SetVariableCustomAction($cid, $actionScript);
|
||||
// OUTPUT → direkte Modulinstanz als Action
|
||||
if (str_contains($ident, '_output_')) {
|
||||
IPS_SetVariableCustomAction($cid, $this->InstanceID);
|
||||
|
||||
$var = IPS_GetVariable($cid);
|
||||
if ($var['VariableProfile'] === '' && $var['VariableCustomProfile'] === '') {
|
||||
IPS_SetVariableCustomProfile($cid, '~Switch');
|
||||
}
|
||||
$var = IPS_GetVariable($cid);
|
||||
if ($var['VariableProfile'] === '' && $var['VariableCustomProfile'] === '') {
|
||||
IPS_SetVariableCustomProfile($cid, '~Switch');
|
||||
}
|
||||
|
||||
return $cid;
|
||||
}
|
||||
|
||||
return $cid;
|
||||
}
|
||||
|
||||
// neu
|
||||
$varID = IPS_CreateVariable(0);
|
||||
IPS_SetIdent($varID, $ident);
|
||||
IPS_SetName($varID, $name);
|
||||
IPS_SetParent($varID, $folderID);
|
||||
|
||||
if (str_contains($ident, '_output_')) {
|
||||
$actionScript = $this->EnsureActionScript();
|
||||
IPS_SetVariableCustomAction($varID, $actionScript);
|
||||
IPS_SetVariableCustomProfile($varID, '~Switch');
|
||||
}
|
||||
|
||||
return $varID;
|
||||
}
|
||||
|
||||
// neu
|
||||
$varID = IPS_CreateVariable(0);
|
||||
IPS_SetIdent($varID, $ident);
|
||||
IPS_SetName($varID, $name);
|
||||
IPS_SetParent($varID, $folderID);
|
||||
|
||||
if (str_contains($ident, '_output_')) {
|
||||
IPS_SetVariableCustomAction($varID, $this->InstanceID);
|
||||
IPS_SetVariableCustomProfile($varID, '~Switch');
|
||||
}
|
||||
|
||||
return $varID;
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------
|
||||
* FLOAT VARIABLE
|
||||
* ---------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user