Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGED
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
2026-04-30 - Fix SIGNALduino protocol loader
2026-04-28 - Support schema-wrapped protocol JSON
2026-04-28 - Bugfix link "check it" (#160)

Expand Down
30 changes: 22 additions & 8 deletions FHEM/88_SIGNALduino_TOOL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1177,12 +1177,19 @@ sub SIGNALduino_TOOL_Get {
## create one list in csv format to import in other program ##
if ($cmd eq 'TimingsList') {
Log3 $name, 4, "$name: Get $cmd - check (1)";
my %ProtocolListSIGNALduino = SIGNALduino_LoadProtocolHash("$attr{global}{modpath}/lib/FHEM/Devices/SIGNALduino/SD_Protocols/Data.pm");
if (exists($ProtocolListSIGNALduino{error}) ) {
Log3 "SIGNALduino", 1, "Error loading Protocol Hash. Module is in inoperable mode error message:($ProtocolListSIGNALduino{error})";
delete($ProtocolListSIGNALduino{error});
my $protocolObject = FHEM::Devices::SIGNALduino::SD_Protocols->new();
my $protocolFile = "$attr{global}{modpath}/lib/FHEM/Devices/SIGNALduino/SD_Protocols/Data.pm";
my $protocolLoadError = $protocolObject->LoadHash($protocolFile);
if (defined $protocolLoadError && $protocolLoadError ne '') {
Log3 "SIGNALduino", 1, "Error loading Protocol Hash. Module is in inoperable mode error message:($protocolLoadError)";
return;
}
my $protocolList = $protocolObject->getProtocolList();
if (!defined $protocolList || ref($protocolList) ne 'HASH') {
Log3 "SIGNALduino", 1, "Error loading Protocol Hash. Module is in inoperable mode error message:(protocol list is not available)";
return;
}
my %ProtocolListSIGNALduino = %{$protocolList};

my $file = 'timings.txt';
my @value; # for values from hash_list
Expand All @@ -1197,7 +1204,11 @@ sub SIGNALduino_TOOL_Get {
### max Werte von value_name array ###
for my $i (0..scalar(@value_name)-1) {
if (not exists $value_max[$i]) { $value_max[$i] = 0; }
if (exists $ProtocolListSIGNALduino{$timings_protocol}{$value_name[$i]} && scalar(@{$ProtocolListSIGNALduino{$timings_protocol}{$value_name[$i]}}) > $value_max[$i]) { $value_max[$i] = scalar(@{$ProtocolListSIGNALduino{$timings_protocol}{$value_name[$i]}}); }
if (exists $ProtocolListSIGNALduino{$timings_protocol}{$value_name[$i]} && defined $ProtocolListSIGNALduino{$timings_protocol}{$value_name[$i]}) {
my $timing_value = $ProtocolListSIGNALduino{$timings_protocol}{$value_name[$i]};
my $timing_value_count = ref($timing_value) eq 'ARRAY' ? scalar(@{$timing_value}) : 1;
if ($timing_value_count > $value_max[$i]) { $value_max[$i] = $timing_value_count; }
}
}
}

Expand All @@ -1222,9 +1233,12 @@ sub SIGNALduino_TOOL_Get {
}
### ENDE ###

foreach my $e(@{$ProtocolListSIGNALduino{$timings_protocol}{$value_name[$i]}}) {
$value[$valuecount] = $e;
$valuecount++;
if (exists $ProtocolListSIGNALduino{$timings_protocol}{$value_name[$i]} && defined $ProtocolListSIGNALduino{$timings_protocol}{$value_name[$i]}) {
my $timing_value = $ProtocolListSIGNALduino{$timings_protocol}{$value_name[$i]};
foreach my $e (ref($timing_value) eq 'ARRAY' ? @{$timing_value} : ($timing_value)) {
$value[$valuecount] = $e;
$valuecount++;
}
}

if ($i == 0) {
Expand Down
2 changes: 1 addition & 1 deletion controls_SD_TOOL.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
UPD 2026-04-28_23:20:13 285940 FHEM/88_SIGNALduino_TOOL.pm
UPD 2026-04-30_20:18:18 286778 FHEM/88_SIGNALduino_TOOL.pm
UPD 2026-04-27_22:55:13 362979 FHEM/lib/SD_Device_ProtocolList.json
29 changes: 29 additions & 0 deletions t/FHEM/88_SIGNALduino_TOOL/10_load.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main;
use strict;
use warnings;

use File::Spec;
use File::Temp qw(tempdir);
use Test2::V1 qw(-ipP);

my $tool_name = 'SIGNALduino_TOOL';
Expand All @@ -23,6 +25,33 @@ ok(!FhemTestUtils_gotLog('Unknown module SIGNALduino_TOOL'), 'No unknown-module
ok(!FhemTestUtils_gotLog('SIGNALduino_TOOL:.*ERROR'), 'No SIGNALduino_TOOL error was logged during startup');
ok(!FhemTestUtils_gotLog('Cannot load module SIGNALduino_TOOL'), 'FHEM loaded the module successfully');

my $timings_dir = tempdir(CLEANUP => 1);
CommandAttr(undef, "$tool_name Path $timings_dir/");

my $timings_result = eval { CommandGet(undef, "$tool_name TimingsList") };
my $timings_error = $@;

is($timings_error, '', 'TimingsList get command did not die');
like(
$timings_result,
qr/New TimingsList \(timings\.txt\) are created!/,
'TimingsList get command reports success'
);
is(ReadingsVal($tool_name, 'state', undef), 'TimingsList created', 'TimingsList updates the state reading');

my $timings_file = File::Spec->catfile($timings_dir, 'timings.txt');
ok(-e $timings_file, 'TimingsList created timings.txt');

my $timings_content = do {
open my $fh, '<', $timings_file or die "Unable to open $timings_file: $!";
local $/;
<$fh>;
};

like($timings_content, qr/^id;typ;clockabs;/, 'TimingsList writes a CSV header');
like($timings_content, qr/(?:^|;)2DD4(?:;|\n)/m, 'TimingsList writes scalar sync values');
ok(!FhemTestUtils_gotLog(q[Can't use string .* as an ARRAY ref]), 'TimingsList did not log scalar-as-array errors');

done_testing;
exit(0);

Expand Down
1 change: 1 addition & 0 deletions t/load_protocol_package.t
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ my $module_source = do {

like($module_source, qr/use FHEM::Devices::SIGNALduino::SD_Protocols;/, 'Module uses the new protocol package');
like($module_source, qr{lib/FHEM/Devices/SIGNALduino/SD_Protocols/Data\.pm}, 'Module references the new protocol data path');
unlike($module_source, qr/SIGNALduino_LoadProtocolHash/, 'Module no longer calls the removed protocol loader');

done_testing;
Loading