no message
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
"name": "VGT_Sub",
|
"name": "VGT_Sub",
|
||||||
"type": 3,
|
"type": 3,
|
||||||
"vendor": "Belevo",
|
"vendor": "Belevo",
|
||||||
"aliases": ["VGT MQTT Client"],
|
"aliases": ["VGT MQTT Device"],
|
||||||
"prefix": "VGT",
|
"prefix": "VGT",
|
||||||
"parentRequirements": [],
|
"parentRequirements": [],
|
||||||
"childRequirements": [],
|
"childRequirements": [],
|
||||||
|
|||||||
@@ -8,13 +8,17 @@ class VGT_Sub extends IPSModule
|
|||||||
{
|
{
|
||||||
parent::Create();
|
parent::Create();
|
||||||
|
|
||||||
|
// DeviceID
|
||||||
$this->RegisterPropertyString('DeviceID', '');
|
$this->RegisterPropertyString('DeviceID', '');
|
||||||
|
|
||||||
|
// Eingehende MQTT-Nachrichten
|
||||||
$this->RegisterVariableString("InputJSON", "MQTT Input", "", 1);
|
$this->RegisterVariableString("InputJSON", "MQTT Input", "", 1);
|
||||||
$this->EnableAction("InputJSON");
|
$this->EnableAction("InputJSON");
|
||||||
|
|
||||||
|
// Ausgehende MQTT-Nachrichten
|
||||||
$this->RegisterVariableString("OutputJSON", "MQTT Output", "", 2);
|
$this->RegisterVariableString("OutputJSON", "MQTT Output", "", 2);
|
||||||
|
|
||||||
|
// Statusvariablen
|
||||||
$this->RegisterVariableFloat('PowerProduction', 'Power Production', '', 10);
|
$this->RegisterVariableFloat('PowerProduction', 'Power Production', '', 10);
|
||||||
$this->EnableAction('PowerProduction');
|
$this->EnableAction('PowerProduction');
|
||||||
|
|
||||||
@@ -33,6 +37,7 @@ class VGT_Sub extends IPSModule
|
|||||||
$this->RegisterVariableFloat('MaxSoc', 'Max SoC', '', 15);
|
$this->RegisterVariableFloat('MaxSoc', 'Max SoC', '', 15);
|
||||||
$this->EnableAction('MaxSoc');
|
$this->EnableAction('MaxSoc');
|
||||||
|
|
||||||
|
// Remote-Control
|
||||||
$this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 20);
|
$this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 20);
|
||||||
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0);
|
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0);
|
||||||
|
|
||||||
@@ -43,6 +48,7 @@ class VGT_Sub extends IPSModule
|
|||||||
public function RequestAction($Ident, $Value)
|
public function RequestAction($Ident, $Value)
|
||||||
{
|
{
|
||||||
if ($Ident === "InputJSON") {
|
if ($Ident === "InputJSON") {
|
||||||
|
SetValueString($this->GetIDForIdent("InputJSON"), $Value);
|
||||||
$this->ProcessIncoming($Value);
|
$this->ProcessIncoming($Value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -53,7 +59,11 @@ class VGT_Sub extends IPSModule
|
|||||||
private function ProcessIncoming($jsonString)
|
private function ProcessIncoming($jsonString)
|
||||||
{
|
{
|
||||||
$data = @json_decode($jsonString, true);
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,12 +72,16 @@ class VGT_Sub extends IPSModule
|
|||||||
|
|
||||||
$device = $this->ReadPropertyString('DeviceID');
|
$device = $this->ReadPropertyString('DeviceID');
|
||||||
|
|
||||||
|
// Feedback Request
|
||||||
if ($topic === "feedback-request/$device") {
|
if ($topic === "feedback-request/$device") {
|
||||||
$this->SendFeedback($device);
|
$this->SendFeedback($device);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remote Control Request
|
||||||
if ($topic === "remote-control-request/$device") {
|
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);
|
$json = @json_decode($payload, true);
|
||||||
if (!is_array($json)) {
|
if (!is_array($json)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user