no message

This commit is contained in:
2025-11-28 07:42:58 +01:00
parent a1c2c72386
commit bbb3037fe6

View File

@@ -30,12 +30,12 @@ class VGT_Sub extends IPSModule
$this->RegisterVariableFloat('MaxSoc', 'Max SoC', '', 15);
$this->EnableAction('MaxSoc');
// Eingehende remote-control commands
// Eingehende remote-control commands (readonly)
$this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 30);
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0); // readonly
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0);
$this->RegisterVariableString('Strategy', 'Strategy', '', 31);
IPS_SetVariableCustomAction($this->GetIDForIdent('Strategy'), 0); // readonly
IPS_SetVariableCustomAction($this->GetIDForIdent('Strategy'), 0);
}
public function ApplyChanges()
@@ -53,6 +53,7 @@ class VGT_Sub extends IPSModule
return;
}
// Topics zum Abonnieren
$topics = [
"feedback-request/$device",
"remote-control-request/$device"
@@ -60,11 +61,12 @@ class VGT_Sub extends IPSModule
foreach ($topics as $topic) {
$this->SendDebug("Subscribe", $topic, 0);
$this->SendDataToParent(json_encode([
'DataID' => '{7F7632D9-FA40-4F38-8DEA-C83CD4325A32}',
'Topic' => $topic,
'Payload' => '',
'Retain' => false
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
"PacketType" => 8, // SUBSCRIBE
"Topic" => $topic,
"QoS" => 0
]));
}
}
@@ -77,7 +79,7 @@ class VGT_Sub extends IPSModule
return;
}
$topic = $data['Topic'];
$topic = $data['Topic'];
$payload = $data['Payload'];
$this->SendDebug("RX Topic", $topic, 0);
@@ -85,17 +87,11 @@ class VGT_Sub extends IPSModule
$device = $this->ReadPropertyString('DeviceID');
// -----------------------------------------------------
// 1) FEEDBACK REQUEST → send FEEDBACK RESPONSE
// -----------------------------------------------------
if ($topic === "feedback-request/$device") {
$this->HandleFeedbackRequest($device);
return;
}
// -----------------------------------------------------
// 2) REMOTE CONTROL REQUEST → write values + respond
// -----------------------------------------------------
if ($topic === "remote-control-request/$device") {
$this->HandleRemoteControlRequest($device, $payload);
return;
@@ -113,17 +109,18 @@ class VGT_Sub extends IPSModule
"max_soc" => GetValueFloat($this->GetIDForIdent('MaxSoc'))
];
$json = json_encode($response);
$json = json_encode($response);
$topic = "feedback-response/$device";
$this->SendDebug("TX Feedback", "$topic => $json", 0);
$this->SendDataToParent(json_encode([
'DataID' => '{7F7632D9-FA40-4F38-8DEA-C83CD4325A32}',
'Topic' => $topic,
'Payload' => $json,
'Retain' => false
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
"PacketType" => 3, // PUBLISH
"Topic" => $topic,
"Payload" => $json,
"QoS" => 0,
"Retain" => false
]));
}
@@ -135,7 +132,6 @@ class VGT_Sub extends IPSModule
return;
}
// Werte aus JSON übernehmen
if (isset($json['power_setpoint'])) {
SetValue($this->GetIDForIdent('PowerSetpoint'), (int)$json['power_setpoint']);
}
@@ -144,17 +140,19 @@ class VGT_Sub extends IPSModule
SetValueString($this->GetIDForIdent('Strategy'), (string)$json['strategy']);
}
// Antwort identisch zurücksenden
$topic = "remote-control-response/$device";
$payloadOut = json_encode($json);
$this->SendDataToParent(json_encode([
'DataID' => '{7F7632D9-FA40-4F38-8DEA-C83CD4325A32}',
'Topic' => $topic,
'Payload' => json_encode($json),
'Retain' => false
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
"PacketType" => 3, // PUBLISH
"Topic" => $topic,
"Payload" => $payloadOut,
"QoS" => 0,
"Retain" => false
]));
$this->SendDebug("TX RemoteControl", "$topic => " . json_encode($json), 0);
$this->SendDebug("TX Remote", "$topic => $payloadOut", 0);
}
public function RequestAction($Ident, $Value)
@@ -162,5 +160,4 @@ class VGT_Sub extends IPSModule
SetValue($this->GetIDForIdent($Ident), $Value);
}
}
?>