.
This commit is contained in:
@@ -29,6 +29,7 @@ class Symcon_Publish_to_Shelly_MQTT extends IPSModule
|
|||||||
|
|
||||||
public function RequestAction($Ident, $Value)
|
public function RequestAction($Ident, $Value)
|
||||||
{
|
{
|
||||||
|
IPS_LogMessage("ShellySwitchSender", " RequestAction: $Ident = $Value");
|
||||||
switch ($Ident) {
|
switch ($Ident) {
|
||||||
case "GetAction":
|
case "GetAction":
|
||||||
$this->GetAction();
|
$this->GetAction();
|
||||||
@@ -40,7 +41,7 @@ class Symcon_Publish_to_Shelly_MQTT extends IPSModule
|
|||||||
|
|
||||||
private function GetAction()
|
private function GetAction()
|
||||||
{
|
{
|
||||||
IPS_LogMessage("ShellySwitchSender", "🚀 Starte GetAction()...");
|
IPS_LogMessage("ShellySwitchSender", " Starte GetAction()...");
|
||||||
// Eigenschaften lesen
|
// Eigenschaften lesen
|
||||||
$broker = GetValue($this->ReadPropertyString("broker_address"));
|
$broker = GetValue($this->ReadPropertyString("broker_address"));
|
||||||
$port = GetValue($this->ReadPropertyInteger("broker_port"));
|
$port = GetValue($this->ReadPropertyInteger("broker_port"));
|
||||||
@@ -53,9 +54,9 @@ class Symcon_Publish_to_Shelly_MQTT extends IPSModule
|
|||||||
$method = GetValue($this->ReadPropertyString("method"));
|
$method = GetValue($this->ReadPropertyString("method"));
|
||||||
$switch_bool = GetValueBoolean($this->ReadPropertyInteger("switch_bool"));
|
$switch_bool = GetValueBoolean($this->ReadPropertyInteger("switch_bool"));
|
||||||
|
|
||||||
IPS_LogMessage("ShellySwitchSender", "📋 Broker: $broker:$port, Topic: $topic");
|
IPS_LogMessage("ShellySwitchSender", "Broker: $broker:$port, Topic: $topic");
|
||||||
IPS_LogMessage("ShellySwitchSender", "📋 src: $src, method: $method, msg_id: $msg_id");
|
IPS_LogMessage("ShellySwitchSender", " src: $src, method: $method, msg_id: $msg_id");
|
||||||
IPS_LogMessage("ShellySwitchSender", "📋 boolVarID: $switch_bool");
|
IPS_LogMessage("ShellySwitchSender", " boolVarID: $switch_bool");
|
||||||
// JSON-Payload erstellen
|
// JSON-Payload erstellen
|
||||||
$payload = [
|
$payload = [
|
||||||
"id" => 0,
|
"id" => 0,
|
||||||
@@ -69,7 +70,7 @@ class Symcon_Publish_to_Shelly_MQTT extends IPSModule
|
|||||||
|
|
||||||
$json = json_encode($payload);
|
$json = json_encode($payload);
|
||||||
|
|
||||||
IPS_LogMessage("ShellySwitchSender", "📦 MQTT Payload: $json");
|
IPS_LogMessage("ShellySwitchSender", " MQTT Payload: $json");
|
||||||
|
|
||||||
// Sende an MQTTClient
|
// Sende an MQTTClient
|
||||||
$clientID = @IPS_GetInstanceIDByName("MQTTClient", 0);
|
$clientID = @IPS_GetInstanceIDByName("MQTTClient", 0);
|
||||||
@@ -79,12 +80,12 @@ class Symcon_Publish_to_Shelly_MQTT extends IPSModule
|
|||||||
|
|
||||||
if ($moduleID == "{C03937E3-5F86-EACA-B4A2-39A24ACF945A}") {
|
if ($moduleID == "{C03937E3-5F86-EACA-B4A2-39A24ACF945A}") {
|
||||||
MQTTClient_Publish($clientID, $topic, $json, 0, false);
|
MQTTClient_Publish($clientID, $topic, $json, 0, false);
|
||||||
IPS_LogMessage("ShellySwitchSender", "✅ Nachricht erfolgreich an '$topic' gesendet.");
|
IPS_LogMessage("ShellySwitchSender", " Nachricht erfolgreich an '$topic' gesendet.");
|
||||||
} else {
|
} else {
|
||||||
IPS_LogMessage("ShellySwitchSender", "❌ Fehler: Instanz 'MQTTClient' hat falsches Modul.");
|
IPS_LogMessage("ShellySwitchSender", " Fehler: Instanz 'MQTTClient' hat falsches Modul.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IPS_LogMessage("ShellySwitchSender", "❌ Kein MQTTClient gefunden oder benannt als 'MQTTClient'.");
|
IPS_LogMessage("ShellySwitchSender", " Kein MQTTClient gefunden oder benannt als 'MQTTClient'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user