no message
This commit is contained in:
@@ -30,12 +30,12 @@ class VGT_Sub extends IPSModule
|
|||||||
$this->RegisterVariableFloat('MaxSoc', 'Max SoC', '', 15);
|
$this->RegisterVariableFloat('MaxSoc', 'Max SoC', '', 15);
|
||||||
$this->EnableAction('MaxSoc');
|
$this->EnableAction('MaxSoc');
|
||||||
|
|
||||||
// Eingehende remote-control commands
|
// Eingehende remote-control commands (readonly)
|
||||||
$this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 30);
|
$this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 30);
|
||||||
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0); // readonly
|
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0);
|
||||||
|
|
||||||
$this->RegisterVariableString('Strategy', 'Strategy', '', 31);
|
$this->RegisterVariableString('Strategy', 'Strategy', '', 31);
|
||||||
IPS_SetVariableCustomAction($this->GetIDForIdent('Strategy'), 0); // readonly
|
IPS_SetVariableCustomAction($this->GetIDForIdent('Strategy'), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ApplyChanges()
|
public function ApplyChanges()
|
||||||
@@ -53,6 +53,7 @@ class VGT_Sub extends IPSModule
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Topics zum Abonnieren
|
||||||
$topics = [
|
$topics = [
|
||||||
"feedback-request/$device",
|
"feedback-request/$device",
|
||||||
"remote-control-request/$device"
|
"remote-control-request/$device"
|
||||||
@@ -60,11 +61,12 @@ class VGT_Sub extends IPSModule
|
|||||||
|
|
||||||
foreach ($topics as $topic) {
|
foreach ($topics as $topic) {
|
||||||
$this->SendDebug("Subscribe", $topic, 0);
|
$this->SendDebug("Subscribe", $topic, 0);
|
||||||
|
|
||||||
$this->SendDataToParent(json_encode([
|
$this->SendDataToParent(json_encode([
|
||||||
'DataID' => '{7F7632D9-FA40-4F38-8DEA-C83CD4325A32}',
|
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
|
||||||
'Topic' => $topic,
|
"PacketType" => 8, // SUBSCRIBE
|
||||||
'Payload' => '',
|
"Topic" => $topic,
|
||||||
'Retain' => false
|
"QoS" => 0
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,17 +87,11 @@ class VGT_Sub extends IPSModule
|
|||||||
|
|
||||||
$device = $this->ReadPropertyString('DeviceID');
|
$device = $this->ReadPropertyString('DeviceID');
|
||||||
|
|
||||||
// -----------------------------------------------------
|
|
||||||
// 1) FEEDBACK REQUEST → send FEEDBACK RESPONSE
|
|
||||||
// -----------------------------------------------------
|
|
||||||
if ($topic === "feedback-request/$device") {
|
if ($topic === "feedback-request/$device") {
|
||||||
$this->HandleFeedbackRequest($device);
|
$this->HandleFeedbackRequest($device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------
|
|
||||||
// 2) REMOTE CONTROL REQUEST → write values + respond
|
|
||||||
// -----------------------------------------------------
|
|
||||||
if ($topic === "remote-control-request/$device") {
|
if ($topic === "remote-control-request/$device") {
|
||||||
$this->HandleRemoteControlRequest($device, $payload);
|
$this->HandleRemoteControlRequest($device, $payload);
|
||||||
return;
|
return;
|
||||||
@@ -114,16 +110,17 @@ class VGT_Sub extends IPSModule
|
|||||||
];
|
];
|
||||||
|
|
||||||
$json = json_encode($response);
|
$json = json_encode($response);
|
||||||
|
|
||||||
$topic = "feedback-response/$device";
|
$topic = "feedback-response/$device";
|
||||||
|
|
||||||
$this->SendDebug("TX Feedback", "$topic => $json", 0);
|
$this->SendDebug("TX Feedback", "$topic => $json", 0);
|
||||||
|
|
||||||
$this->SendDataToParent(json_encode([
|
$this->SendDataToParent(json_encode([
|
||||||
'DataID' => '{7F7632D9-FA40-4F38-8DEA-C83CD4325A32}',
|
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
|
||||||
'Topic' => $topic,
|
"PacketType" => 3, // PUBLISH
|
||||||
'Payload' => $json,
|
"Topic" => $topic,
|
||||||
'Retain' => false
|
"Payload" => $json,
|
||||||
|
"QoS" => 0,
|
||||||
|
"Retain" => false
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +132,6 @@ class VGT_Sub extends IPSModule
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Werte aus JSON übernehmen
|
|
||||||
if (isset($json['power_setpoint'])) {
|
if (isset($json['power_setpoint'])) {
|
||||||
SetValue($this->GetIDForIdent('PowerSetpoint'), (int)$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']);
|
SetValueString($this->GetIDForIdent('Strategy'), (string)$json['strategy']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Antwort identisch zurücksenden
|
|
||||||
$topic = "remote-control-response/$device";
|
$topic = "remote-control-response/$device";
|
||||||
|
$payloadOut = json_encode($json);
|
||||||
|
|
||||||
$this->SendDataToParent(json_encode([
|
$this->SendDataToParent(json_encode([
|
||||||
'DataID' => '{7F7632D9-FA40-4F38-8DEA-C83CD4325A32}',
|
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
|
||||||
'Topic' => $topic,
|
"PacketType" => 3, // PUBLISH
|
||||||
'Payload' => json_encode($json),
|
"Topic" => $topic,
|
||||||
'Retain' => false
|
"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)
|
public function RequestAction($Ident, $Value)
|
||||||
@@ -162,5 +160,4 @@ class VGT_Sub extends IPSModule
|
|||||||
SetValue($this->GetIDForIdent($Ident), $Value);
|
SetValue($this->GetIDForIdent($Ident), $Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user