diff --git a/fhem/FHEM/00_SIGNALduino.pm b/fhem/FHEM/00_SIGNALduino.pm
index 556ca508d..dc9a59af3 100644
--- a/fhem/FHEM/00_SIGNALduino.pm
+++ b/fhem/FHEM/00_SIGNALduino.pm
@@ -1,5 +1,5 @@
# $Id$
-# v3.5.2 - https://github.com/RFD-FHEM/RFFHEM/tree/master
+# v3.5.3 - https://github.com/RFD-FHEM/RFFHEM/tree/master
# The module is inspired by the FHEMduino project and modified in serval ways for processing the incoming messages
# see http://www.fhemwiki.de/wiki/SIGNALDuino
# It was modified also to provide support for raw message handling which can be send from the SIGNALduino
@@ -14,9 +14,9 @@
package main;
use strict;
use warnings;
-#use version 0.77; our $VERSION = version->declare('v3.5.2');
+#use version 0.77; our $VERSION = version->declare('v3.5.3');
-my $missingModulSIGNALduino = '';
+my $missingModulSIGNALduino = ' ';
use DevIo;
require "99_Utils.pm" if (!defined $modules{"Utils"} || !exists $modules{"Utils"}{"LOADED"} ); ## no critic
@@ -24,8 +24,8 @@ use Carp;
no warnings 'portable';
eval {use Data::Dumper qw(Dumper);1};
-eval {use Digest::CRC;1 or $missingModulSIGNALduino .= 'Digest::CRC '};
-eval {use JSON;1 or $missingModulSIGNALduino .= 'JSON '};
+
+use constant HAS_JSON => defined eval { require JSON; JSON->import; };
eval {use Scalar::Util qw(looks_like_number);1};
eval {use Time::HiRes qw(gettimeofday);1} ;
@@ -38,7 +38,7 @@ use List::Util qw(first);
use constant {
- SDUINO_VERSION => '3.5.2', # Datum wird automatisch bei jedem pull request aktualisiert
+ SDUINO_VERSION => '3.5.3', # Datum wird automatisch bei jedem pull request aktualisiert
SDUINO_INIT_WAIT_XQ => 1.5, # wait disable device
SDUINO_INIT_WAIT => 2,
SDUINO_INIT_MAXRETRY => 3,
@@ -295,15 +295,17 @@ sub SIGNALduino_Initialize {
Log3 'SIGNALduino', 4, qq[SIGNALduino_Initialize: rfmode list: @rfmode];
}
+ $hash->{DefFn} = \&SIGNALduino_Define;
+ $hash->{UndefFn} = \&SIGNALduino_Undef;
+
+
# Provider
$hash->{ReadFn} = \&SIGNALduino_Read;
$hash->{WriteFn} = \&SIGNALduino_Write;
$hash->{ReadyFn} = \&SIGNALduino_Ready;
# Normal devices
- $hash->{DefFn} = \&SIGNALduino_Define;
$hash->{FingerprintFn} = \&SIGNALduino_FingerprintFn;
- $hash->{UndefFn} = \&SIGNALduino_Undef;
$hash->{GetFn} = \&SIGNALduino_Get;
$hash->{SetFn} = \&SIGNALduino_Set;
$hash->{AttrFn} = \&SIGNALduino_Attr;
@@ -1065,7 +1067,7 @@ sub SIGNALduino_Get_FhemWebList {
sub SIGNALduino_Get_availableFirmware {
my ($hash, @a) = @_;
- if ($missingModulSIGNALduino =~ m/JSON/ )
+ if ( !HAS_JSON )
{
$hash->{logMethod}->($hash->{NAME}, 1, "$hash->{NAME}: get $a[0] failed. Please install Perl module JSON. Example: sudo apt-get install libjson-perl");
return "$a[0]: \n\nFetching from github is not possible. Please install JSON. Example:
sudo apt-get install libjson-perl
";
@@ -2940,7 +2942,8 @@ sub SIGNALduino_Parse_MN {
my $method = $hash->{protocolObject}->getProperty($id,'method',undef);
my @methodReturn = defined $method ? $method->($hash->{protocolObject},$rawData) : ($rawData);
if ($#methodReturn != 0) {
- $hash->{logMethod}->($name, 4, qq{$name: Parse_MN, Error! method $methodReturn[1]});
+ my $vl = $methodReturn[1] =~ /missing\smodule/xms ? 1 : 4;
+ $hash->{logMethod}->($name, $vl, qq{$name: Parse_MN, Error! method $methodReturn[1]});
next mnIDLoop;
}
$dmsg = sprintf('%s%s',$hash->{protocolObject}->checkProperty($id,'preamble',''),$methodReturn[0]);
@@ -3958,6 +3961,7 @@ sub SIGNALduino_githubParseHttpResponse {
}
elsif($data ne '' && defined($hardware)) # wenn die Abfrage erfolgreich war ($data enthaelt die Ergebnisdaten des HTTP Aufrufes)
{
+
my $json_array = decode_json($data);
#print Dumper($json_array);
if ($param->{command} eq 'queryReleases') {
diff --git a/fhem/FHEM/lib/SD_Protocols.pm b/fhem/FHEM/lib/SD_Protocols.pm
index b8eae432c..5e890f16b 100644
--- a/fhem/FHEM/lib/SD_Protocols.pm
+++ b/fhem/FHEM/lib/SD_Protocols.pm
@@ -13,7 +13,9 @@ package lib::SD_Protocols;
use strict;
use warnings;
use Carp qw(croak carp);
-use Digest::CRC;
+use constant HAS_DigestCRC => defined eval { require Digest::CRC; };
+use constant HAS_JSON => defined eval { require JSON; };
+
our $VERSION = '2.05';
use Storable qw(dclone);
use Scalar::Util qw(blessed);
@@ -142,7 +144,11 @@ sub LoadHashFromJson {
my $json_text = do { local $/ = undef; <$json_fh> };
close $json_fh or croak "Can't close '$filename' after reading";
- use JSON;
+ if (!HAS_JSON)
+ {
+ croak("Perl Module JSON not availble. Needs to be installed.");
+ }
+
my $json = JSON->new;
$json = $json->relaxed(1);
my $ver = $json->incr_parse($json_text);
@@ -1819,7 +1825,13 @@ sub ConvBresser_6in1 {
my $hexLength = length ($hexData);
return ( 1, 'ConvBresser_6in1, hexData is to short' ) if ( $hexLength < 36 ); # check double, in def length_min set
-
+
+
+ return ( 1,'ConvBresser_6in1, missing module , please install modul Digest::CRC' )
+ if (!HAS_DigestCRC);
+
+
+
my $crc = substr( $hexData, 0, 4 );
my $ctx = Digest::CRC->new(width => 16, poly => 0x1021);
my $calcCrc = sprintf( "%04X", $ctx->add( pack 'H*', substr( $hexData, 4, 30 ) )->digest );
@@ -1858,6 +1870,9 @@ sub ConvPCA301 {
'ConvPCA301, Usage: Input #1, $hexData needs to be at least 24 chars long'
) if ( length($hexData) < 24 ); # check double, in def length_min set
+ return ( 1,'ConvPCA301, missing module , please install modul Digest::CRC' )
+ if (!HAS_DigestCRC);
+
my $checksum = substr( $hexData, 20, 4 );
my $ctx = Digest::CRC->new(
width => 16,
@@ -1980,6 +1995,9 @@ sub ConvLaCrosse {
return ( 1,'ConvLaCrosse, Usage: Input #1, $hexData needs to be at least 8 chars long' )
if ( length($hexData) < 8 ) ; # check number of length for this sub to not throw an error
+ return ( 1,'ConvLaCrosse, missing module , please install modul Digest::CRC' )
+ if (!HAS_DigestCRC);
+
my $ctx = Digest::CRC->new( width => 8, poly => 0x31 );
my $calcCrc = $ctx->add( pack 'H*', substr( $hexData, 0, 8 ) )->digest;
my $checksum = sprintf( "%d", hex( substr( $hexData, 8, 2 ) ) );