diff --git a/fhem/lib/FHEM/Devices/AMConnect/Common.pm b/fhem/lib/FHEM/Devices/AMConnect/Common.pm index 9f06c8dd0..913dfb695 100644 --- a/fhem/lib/FHEM/Devices/AMConnect/Common.pm +++ b/fhem/lib/FHEM/Devices/AMConnect/Common.pm @@ -2083,21 +2083,36 @@ sub readMap { if ( $filename and -e $filename ) { - open my $fh, '<:raw', $filename or die $!; - my $content = ''; + if ( open my $fh, '<:raw', $filename ) { - while (1) { + my $content = ''; - my $success = read $fh, $content, 1024, length($content); - die $! if not defined $success; - last if not $success; + while (1) { + + my $success = read $fh, $content, 1024, length( $content ); + + if ( not defined $success ) { + + close $fh; + Log3 $name, 1, "$iam read file \"$filename\" with error $!"; + return; + + } + + last if not $success; + + } + + close $fh; + $hash->{helper}{MAP_CACHE} = $content; + Log3 $name, 4, "$iam file \"$filename\" content length: ".length( $content ); + + } else { + + Log3 $name, 1, "$iam open file \"$filename\" with error $!"; } - close $fh; - $hash->{helper}{MAP_CACHE} = $content; - Log3 $name, 5, "$iam file \"$filename\" content length: ".length($content); - } else { Log3 $name, 2, "$iam file \"$filename\" does not exist.";