no message

This commit is contained in:
2026-05-26 12:31:00 +02:00
parent f992fb874d
commit d523990798
+38 -22
View File
@@ -38,24 +38,27 @@ class MQTTBatterySDL extends IPSModule
}
public function ApplyChanges()
{
parent::ApplyChanges();
public function ApplyChanges()
{
parent::ApplyChanges();
$suffix = $this->ReadPropertyString('TopicSuffix');
$suffix = $this->ReadPropertyString('TopicSuffix');
if ($suffix == '') {
$this->SetStatus(IS_INACTIVE);
return;
}
$filter = '.*"Topic":"(feedback-request|remote-control-request)\/' . preg_quote($suffix, '/') . '".*';
$this->SetReceiveDataFilter($filter);
$this->SetStatus(IS_ACTIVE);
if ($suffix == '') {
$this->SetStatus(IS_INACTIVE);
return;
}
$filter =
'.*"Topic":"(feedback-request|remote-control-request)\/'
. preg_quote($suffix, '/')
. '".*';
$this->SetReceiveDataFilter($filter);
$this->SetStatus(IS_ACTIVE);
}
public function RequestAction($Ident, $Value)
{
switch ($Ident) {
@@ -340,19 +343,34 @@ public function ReceiveData($JSONString)
{
$data = json_decode($JSONString, true);
$this->SendDebug('ReceiveData', $JSONString, 0);
if (!is_array($data)) {
return;
}
$topic = $data['Topic'] ?? '';
$payload = $data['Payload'] ?? '';
if (($data['PacketType'] ?? 0) != 3) {
return;
}
$suffix = $this->ReadPropertyString('TopicSuffix');
if (!isset($data['Topic'])) {
return;
}
$topic = $data['Topic'];
if (strpos($topic, 'feedback-response/') === 0) {
return;
}
if (strpos($topic, 'remote-control-response/') === 0) {
return;
}
$this->SendDebug('ReceiveData', $JSONString, 0);
$payload = $data['Payload'] ?? '';
$suffix = $this->ReadPropertyString('TopicSuffix');
if ($topic === 'feedback-request/' . $suffix) {
$json = $this->BuildReadResponse();
$this->PublishMQTT(
@@ -364,7 +382,6 @@ public function ReceiveData($JSONString)
}
if ($topic === 'remote-control-request/' . $suffix) {
$json = $this->HandleRemoteControlJSON($payload);
if ($json !== null) {
@@ -379,7 +396,6 @@ public function ReceiveData($JSONString)
}
private function PublishMQTT(string $topic, string $payload)
{
$this->SendDebug(