no message

This commit is contained in:
2025-11-28 09:08:48 +01:00
parent 1ff2e06bf8
commit d4aa2b7657
2 changed files with 19 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
"name": "VGT_Sub",
"type": 3,
"vendor": "Belevo",
"aliases": ["VGT MQTT Client"],
"aliases": ["VGT MQTT Device"],
"prefix": "VGT",
"parentRequirements": [],
"childRequirements": [],

View File

@@ -8,13 +8,17 @@ class VGT_Sub extends IPSModule
{
parent::Create();
// DeviceID
$this->RegisterPropertyString('DeviceID', '');
// Eingehende MQTT-Nachrichten
$this->RegisterVariableString("InputJSON", "MQTT Input", "", 1);
$this->EnableAction("InputJSON");
// Ausgehende MQTT-Nachrichten
$this->RegisterVariableString("OutputJSON", "MQTT Output", "", 2);
// Statusvariablen
$this->RegisterVariableFloat('PowerProduction', 'Power Production', '', 10);
$this->EnableAction('PowerProduction');
@@ -33,6 +37,7 @@ class VGT_Sub extends IPSModule
$this->RegisterVariableFloat('MaxSoc', 'Max SoC', '', 15);
$this->EnableAction('MaxSoc');
// Remote-Control
$this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 20);
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0);
@@ -43,6 +48,7 @@ class VGT_Sub extends IPSModule
public function RequestAction($Ident, $Value)
{
if ($Ident === "InputJSON") {
SetValueString($this->GetIDForIdent("InputJSON"), $Value);
$this->ProcessIncoming($Value);
return;
}
@@ -53,7 +59,11 @@ class VGT_Sub extends IPSModule
private function ProcessIncoming($jsonString)
{
$data = @json_decode($jsonString, true);
if (!is_array($data) || !isset($data['topic']) || !isset($data['payload'])) {
if (!is_array($data)) {
return;
}
if (!isset($data['topic']) || !isset($data['payload'])) {
return;
}
@@ -62,12 +72,16 @@ class VGT_Sub extends IPSModule
$device = $this->ReadPropertyString('DeviceID');
// Feedback Request
if ($topic === "feedback-request/$device") {
$this->SendFeedback($device);
return;
}
// Remote Control Request
if ($topic === "remote-control-request/$device") {
$this->ProcessRemote($device, $payload);
$this->ProcessRemoteControl($device, $payload);
return;
}
}
@@ -91,7 +105,7 @@ class VGT_Sub extends IPSModule
);
}
private function ProcessRemote($device, $payload)
private function ProcessRemoteControl($device, $payload)
{
$json = @json_decode($payload, true);
if (!is_array($json)) {