no message
This commit is contained in:
@@ -10,7 +10,7 @@ class VGT_Sub extends IPSModule
|
||||
|
||||
$this->RegisterPropertyString('DeviceID', '');
|
||||
|
||||
// Status Variablen (editable)
|
||||
// Status Variablen (bearbeitbar)
|
||||
$this->RegisterVariableFloat('PowerProduction', 'Power Production', '', 10);
|
||||
$this->EnableAction('PowerProduction');
|
||||
|
||||
@@ -29,7 +29,7 @@ class VGT_Sub extends IPSModule
|
||||
$this->RegisterVariableFloat('MaxSoc', 'Max SoC', '', 15);
|
||||
$this->EnableAction('MaxSoc');
|
||||
|
||||
// Remote control readonly variables
|
||||
// Remote-Control Variablen (readonly)
|
||||
$this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 30);
|
||||
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0);
|
||||
|
||||
@@ -41,8 +41,8 @@ class VGT_Sub extends IPSModule
|
||||
{
|
||||
parent::ApplyChanges();
|
||||
|
||||
// Correct Parent: MQTTClientSplitter
|
||||
$this->ConnectParent('{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}');
|
||||
// RICHTIGER Parent: Offizieller MQTT Client
|
||||
$this->ConnectParent('{3CFF0FD9-A6AF-4A9A-8C41-62E71D93AF40}');
|
||||
|
||||
$this->SubscribeTopics();
|
||||
}
|
||||
@@ -60,11 +60,12 @@ class VGT_Sub extends IPSModule
|
||||
];
|
||||
|
||||
foreach ($topics as $topic) {
|
||||
|
||||
$this->SendDebug("SUBSCRIBE", $topic, 0);
|
||||
|
||||
$this->SendDataToParent(json_encode([
|
||||
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
|
||||
"PacketType" => 8, // SUBSCRIBE
|
||||
"DataID" => "{3CFF0FD9-A6AF-4A9A-8C41-62E71D93AF40}",
|
||||
"PacketType" => 8, // Subscribe
|
||||
"Topic" => $topic,
|
||||
"QoS" => 0
|
||||
]));
|
||||
@@ -75,14 +76,10 @@ class VGT_Sub extends IPSModule
|
||||
{
|
||||
$data = json_decode($JSONString, true);
|
||||
|
||||
if (!isset($data['Topic'])) {
|
||||
return;
|
||||
}
|
||||
$topic = $data['Topic'] ?? '';
|
||||
$payload = $data['Payload'] ?? '';
|
||||
|
||||
$topic = $data['Topic'];
|
||||
$payload = $data['Payload'];
|
||||
|
||||
$this->SendDebug("RX TOPIC", $topic, 0);
|
||||
$this->SendDebug("RX TOPIC", $topic, 0);
|
||||
$this->SendDebug("RX PAYLOAD", $payload, 0);
|
||||
|
||||
$device = $this->ReadPropertyString('DeviceID');
|
||||
@@ -113,8 +110,8 @@ class VGT_Sub extends IPSModule
|
||||
$this->SendDebug("TX FEEDBACK", $json, 0);
|
||||
|
||||
$this->SendDataToParent(json_encode([
|
||||
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
|
||||
"PacketType" => 3, // PUBLISH
|
||||
"DataID" => "{3CFF0FD9-A6AF-4A9A-8C41-62E71D93AF40}",
|
||||
"PacketType" => 3, // Publish
|
||||
"Topic" => $topic,
|
||||
"Payload" => $json,
|
||||
"QoS" => 0,
|
||||
@@ -126,7 +123,7 @@ class VGT_Sub extends IPSModule
|
||||
{
|
||||
$json = @json_decode($payload, true);
|
||||
if (!is_array($json)) {
|
||||
$this->SendDebug("ERROR", "Ungültiges JSON", 0);
|
||||
$this->SendDebug("ERROR", "Ungültiges JSON empfangen!", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,16 +135,16 @@ class VGT_Sub extends IPSModule
|
||||
SetValueString($this->GetIDForIdent('Strategy'), (string)$json['strategy']);
|
||||
}
|
||||
|
||||
$payloadOut = json_encode($json);
|
||||
$topic = "remote-control-response/$device";
|
||||
$replyTopic = "remote-control-response/$device";
|
||||
$replyPayload = json_encode($json);
|
||||
|
||||
$this->SendDebug("TX REMOTE", $payloadOut, 0);
|
||||
$this->SendDebug("TX REMOTE", $replyPayload, 0);
|
||||
|
||||
$this->SendDataToParent(json_encode([
|
||||
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
|
||||
"PacketType" => 3,
|
||||
"Topic" => $topic,
|
||||
"Payload" => $payloadOut,
|
||||
"DataID" => "{3CFF0FD9-A6AF-4A9A-8C41-62E71D93AF40}",
|
||||
"PacketType" => 3, // Publish
|
||||
"Topic" => $replyTopic,
|
||||
"Payload" => $replyPayload,
|
||||
"QoS" => 0,
|
||||
"Retain" => false
|
||||
]));
|
||||
|
||||
Reference in New Issue
Block a user