Skip to content

Commit 3a7fee7

Browse files
committed
Fix MQTT topics
The MQTT Gateway doesn't support spaces in topic names. In addition Date and Time values are not forwarded over MQTT anymore as that can lead to problems as it can't be converted to an analog input on loxone.
1 parent 69245c8 commit 3a7fee7

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

bin/wolf_ism8i.pl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ ($)
212212
# Leerzeichen am Ende wird verworfen
213213
$working_string =~ s/\s+$//;
214214

215-
my @tbr = ("/", "_");
215+
my @tbr = ("/", "_", ":", "", " ", "/");
216216

217217
for (my $i=0; $i <= scalar(@tbr)-1; $i+=2)
218218
{
@@ -742,10 +742,11 @@ ($)
742742
#if (scalar(@fields) == 6) { $topic .= "/".getMQTTFriendly($fields[5]); } # Einheit (wenn vorhanden)
743743

744744
my @types = ("DPT_Scaling","DPT_Value_Temp","DPT_Value_Tempd","DPT_Value_Pres",
745-
"DPT_Power","DPT_Value_Volume_Flow","DPT_TimeOfDay",
746-
"DPT_Date","DPT_FlowRate_m3/h","DPT_ActiveEnergy",
745+
"DPT_Power","DPT_Value_Volume_Flow",
746+
,"DPT_FlowRate_m3/h","DPT_ActiveEnergy",
747747
"DPT_ActiveEnergy_kWh","DPT_Value_1_Ucount", "DPT_Value_2_Ucount" );
748748
my @bool_types = ("DPT_Switch","DPT_Bool","DPT_Enable","DPT_OpenClose");
749+
my @ignored_types = ("DPT_TimeOfDay","DPT_Date");
749750
my $datatype = getDatenpunkt($DP_ID, 3);
750751
my $value;
751752
if (grep( /^$datatype$/, @types )) {
@@ -756,6 +757,8 @@ ($)
756757
} else {
757758
$value = "false";
758759
}
760+
} elsif (grep( /^$datatype$/, @ignored_types )) {
761+
goto err;
759762
} else {
760763
$value = $DP_value;
761764
}

webfrontend/htmlauth/index.cgi

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ if ($R::saveformdata2) {
213213

214214
my $linenr = $VIhttp->VirtualInHttpCmd (
215215
Title => "wolfism8_online",
216-
Comment => "ISM8 Online State"
216+
Comment => "ISM8 Online State",
217+
Check => " "
217218
);
218219

219220
my $count = scalar(@datenpunkte);
@@ -223,14 +224,20 @@ if ($R::saveformdata2) {
223224
my $id = sprintf "%03d", $datenpunkte[$i][0];
224225
my $device = $datenpunkte[$i][1];
225226
my $name = encode('UTF-8', $datenpunkte[$i][1]." ".$datenpunkte[$i][2]);
226-
my $topic = encode('UTF-8', "wolfism8_".getMQTTFriendly($datenpunkte[$i][1])."_".getMQTTFriendly($datenpunkte[$i][2]));
227+
my $topic = encode('UTF-8', "wolfism8/".getMQTTFriendly($datenpunkte[$i][1])."/".getMQTTFriendly($datenpunkte[$i][2]));
228+
$topic =~ s/\//_/g;
227229
my $input_output = $datenpunkte[$i][4];
228230
if ($id == '000') {
229231
next;
230232
}
231233
if (!($input_output =~ /Out/)) {
232234
next;
233235
}
236+
my $datatype = $datenpunkte[$i][3];
237+
my @date_types = ("DPT_TimeOfDay","DPT_Date");
238+
if (grep( /^$datatype$/, @date_types )) {
239+
next;
240+
}
234241

235242
foreach $item (@devices) {
236243
if ($item eq $device) {
@@ -490,7 +497,7 @@ sub getMQTTFriendly($)
490497
# Leerzeichen am Ende wird verworfen
491498
$working_string =~ s/\s+$//;
492499

493-
my @tbr = ("/", "_");
500+
my @tbr = ("/", "_", ":", "", " ", "/");
494501

495502
for (my $i=0; $i <= scalar(@tbr)-1; $i+=2)
496503
{

0 commit comments

Comments
 (0)