no message
This commit is contained in:
@@ -11,7 +11,7 @@ class VGT_Sub extends IPSModule
|
|||||||
// Konfiguration
|
// Konfiguration
|
||||||
$this->RegisterPropertyString('DeviceID', '');
|
$this->RegisterPropertyString('DeviceID', '');
|
||||||
|
|
||||||
// Eigene Status-Variablen (schreibbar)
|
// Eigene Status Variablen (schreibbar)
|
||||||
$this->RegisterVariableFloat('PowerProduction', 'Power Production', '', 10);
|
$this->RegisterVariableFloat('PowerProduction', 'Power Production', '', 10);
|
||||||
$this->EnableAction('PowerProduction');
|
$this->EnableAction('PowerProduction');
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ 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 (readonly)
|
// Remote-Control Werte (readonly)
|
||||||
$this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 30);
|
$this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 30);
|
||||||
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0);
|
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0);
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ class VGT_Sub extends IPSModule
|
|||||||
public function ApplyChanges()
|
public function ApplyChanges()
|
||||||
{
|
{
|
||||||
parent::ApplyChanges();
|
parent::ApplyChanges();
|
||||||
$this->ConnectParent('{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}');
|
$this->ConnectParent('{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}');
|
||||||
|
|
||||||
$this->SubscribeTopics();
|
$this->SubscribeTopics();
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,6 @@ 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"
|
||||||
@@ -62,11 +61,10 @@ class VGT_Sub extends IPSModule
|
|||||||
foreach ($topics as $topic) {
|
foreach ($topics as $topic) {
|
||||||
$this->SendDebug("Subscribe", $topic, 0);
|
$this->SendDebug("Subscribe", $topic, 0);
|
||||||
|
|
||||||
|
// Richtige MQTT Client Struktur
|
||||||
$this->SendDataToParent(json_encode([
|
$this->SendDataToParent(json_encode([
|
||||||
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
|
'DataID' => '{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}',
|
||||||
"PacketType" => 8, // SUBSCRIBE
|
'Topic' => $topic
|
||||||
"Topic" => $topic,
|
|
||||||
"QoS" => 0
|
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,26 +99,24 @@ class VGT_Sub extends IPSModule
|
|||||||
private function HandleFeedbackRequest($device)
|
private function HandleFeedbackRequest($device)
|
||||||
{
|
{
|
||||||
$response = [
|
$response = [
|
||||||
"power_production" => GetValueFloat($this->GetIDForIdent('PowerProduction')),
|
"power_production" => GetValue($this->GetIDForIdent('PowerProduction')),
|
||||||
"state_of_charge" => GetValueFloat($this->GetIDForIdent('StateOfCharge')),
|
"state_of_charge" => GetValue($this->GetIDForIdent('StateOfCharge')),
|
||||||
"is_running" => GetValueBoolean($this->GetIDForIdent('IsRunning')),
|
"is_running" => GetValue($this->GetIDForIdent('IsRunning')),
|
||||||
"is_ready" => GetValueBoolean($this->GetIDForIdent('IsReady')),
|
"is_ready" => GetValue($this->GetIDForIdent('IsReady')),
|
||||||
"min_soc" => GetValueFloat($this->GetIDForIdent('MinSoc')),
|
"min_soc" => GetValue($this->GetIDForIdent('MinSoc')),
|
||||||
"max_soc" => GetValueFloat($this->GetIDForIdent('MaxSoc'))
|
"max_soc" => GetValue($this->GetIDForIdent('MaxSoc'))
|
||||||
];
|
];
|
||||||
|
|
||||||
$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);
|
||||||
|
|
||||||
|
// MQTT Client: Publish
|
||||||
$this->SendDataToParent(json_encode([
|
$this->SendDataToParent(json_encode([
|
||||||
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
|
'DataID' => '{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}',
|
||||||
"PacketType" => 3, // PUBLISH
|
'Topic' => $topic,
|
||||||
"Topic" => $topic,
|
'Payload' => $json
|
||||||
"Payload" => $json,
|
|
||||||
"QoS" => 0,
|
|
||||||
"Retain" => false
|
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,16 +139,14 @@ class VGT_Sub extends IPSModule
|
|||||||
$topic = "remote-control-response/$device";
|
$topic = "remote-control-response/$device";
|
||||||
$payloadOut = json_encode($json);
|
$payloadOut = json_encode($json);
|
||||||
|
|
||||||
|
// MQTT Client: Publish
|
||||||
$this->SendDataToParent(json_encode([
|
$this->SendDataToParent(json_encode([
|
||||||
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
|
'DataID' => '{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}',
|
||||||
"PacketType" => 3, // PUBLISH
|
'Topic' => $topic,
|
||||||
"Topic" => $topic,
|
'Payload' => $payloadOut
|
||||||
"Payload" => $payloadOut,
|
|
||||||
"QoS" => 0,
|
|
||||||
"Retain" => false
|
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$this->SendDebug("TX Remote", "$topic => $payloadOut", 0);
|
$this->SendDebug("TX RemoteControl", "$topic => $payloadOut", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function RequestAction($Ident, $Value)
|
public function RequestAction($Ident, $Value)
|
||||||
|
|||||||
Reference in New Issue
Block a user