no message
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user