no message

This commit is contained in:
dh
2025-11-28 07:29:13 +01:00
parent 99e65337ef
commit 6332a98ed6
+5 -35
View File
@@ -34,39 +34,19 @@ class VGT_Sub extends IPSModule
$this->ConnectParent('{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}'); $this->ConnectParent('{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}');
} }
public function ApplyChanges() public function ApplyChanges()
{ {
parent::ApplyChanges(); parent::ApplyChanges();
// Child darf NICHT subscriben!
$this->ConnectParent('{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}'); $this->ConnectParent('{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}');
$device = $this->ReadPropertyString("DeviceID");
$topics = [
"feedback-request/" . $device,
"remote-control-request/" . $device
];
foreach ($topics as $topic) {
$this->SendDataToParent(json_encode([
"DataID" => "{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}",
"PacketType" => 8, // SUBSCRIBE
"QualityOfService" => 0,
"Retain" => false,
"Topic" => $topic,
"Payload" => "" // <-- WICHTIG !!!
]));
}
} }
public function RequestAction($Ident, $Value) public function RequestAction($Ident, $Value)
{ {
SetValue($this->GetIDForIdent($Ident), $Value); SetValue($this->GetIDForIdent($Ident), $Value);
} }
public function ReceiveData($JSONString) public function ReceiveData($JSONString)
{ {
$data = json_decode($JSONString); $data = json_decode($JSONString);
@@ -89,7 +69,6 @@ class VGT_Sub extends IPSModule
} }
} }
private function HandleFeedbackRequest() private function HandleFeedbackRequest()
{ {
$response = [ $response = [
@@ -101,11 +80,9 @@ class VGT_Sub extends IPSModule
"max_soc" => GetValue($this->GetIDForIdent("MaxSOC")) "max_soc" => GetValue($this->GetIDForIdent("MaxSOC"))
]; ];
$topic = "feedback-response/" . $this->ReadPropertyString("DeviceID"); $this->SendToMQTT("feedback-response/" . $this->ReadPropertyString("DeviceID"), json_encode($response));
$this->SendToMQTT($topic, json_encode($response));
} }
private function HandleRemoteControlRequest(string $payload) private function HandleRemoteControlRequest(string $payload)
{ {
$data = json_decode($payload, true); $data = json_decode($payload, true);
@@ -121,16 +98,14 @@ class VGT_Sub extends IPSModule
SetValue($this->GetIDForIdent("RC_Strategy"), $data["strategy"]); SetValue($this->GetIDForIdent("RC_Strategy"), $data["strategy"]);
} }
$topic = "remote-control-response/" . $this->ReadPropertyString("DeviceID"); $this->SendToMQTT("remote-control-response/" . $this->ReadPropertyString("DeviceID"), json_encode($data));
$this->SendToMQTT($topic, json_encode($data));
} }
private function SendToMQTT(string $topic, string $payload) private function SendToMQTT(string $topic, string $payload)
{ {
$this->SendDataToParent(json_encode([ $this->SendDataToParent(json_encode([
"DataID" => "{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}", "DataID" => "{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}",
"PacketType" => 3, // PUBLISH "PacketType" => 3,
"QualityOfService" => 0, "QualityOfService" => 0,
"Retain" => false, "Retain" => false,
"Topic" => $topic, "Topic" => $topic,
@@ -138,16 +113,11 @@ class VGT_Sub extends IPSModule
])); ]));
} }
public function GetConfigurationForm() public function GetConfigurationForm()
{ {
return json_encode([ return json_encode([
"elements" => [ "elements" => [
[ [ "type" => "ValidationTextBox", "name" => "DeviceID", "caption" => "Device ID" ]
"type" => "ValidationTextBox",
"name" => "DeviceID",
"caption" => "Device ID"
]
] ]
]); ]);
} }