no message

This commit is contained in:
2026-05-26 11:33:45 +02:00
parent f26c6886c6
commit faf30d279a
+47 -3
View File
@@ -42,7 +42,16 @@ class MQTTBatterySDL extends IPSModule
{
parent::ApplyChanges();
$this->SetReceiveDataFilter('.*');
$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);
}
@@ -327,9 +336,44 @@ class MQTTBatterySDL extends IPSModule
return $json;
}
public function ReceiveData($JSONString)
public function ReceiveData($JSONString)
{
IPS_LogMessage('MQTTBatterySDL', $JSONString);
$data = json_decode($JSONString, true);
$this->SendDebug('ReceiveData', $JSONString, 0);
if (!is_array($data)) {
return;
}
$topic = $data['Topic'] ?? '';
$payload = $data['Payload'] ?? '';
$suffix = $this->ReadPropertyString('TopicSuffix');
if ($topic === 'feedback-request/' . $suffix) {
$json = $this->BuildReadResponse();
$this->PublishMQTT(
'feedback-response/' . $suffix,
$json
);
return;
}
if ($topic === 'remote-control-request/' . $suffix) {
$json = $this->HandleRemoteControlJSON($payload);
if ($json !== null) {
$this->PublishMQTT(
'remote-control-response/' . $suffix,
$json
);
}
return;
}
}
private function IsValidVariable(int $id)