diff --git a/fhem/FHEM/77_SMAEM.pm b/fhem/FHEM/77_SMAEM.pm index 69eba7d4a..e86571802 100644 --- a/fhem/FHEM/77_SMAEM.pm +++ b/fhem/FHEM/77_SMAEM.pm @@ -30,11 +30,14 @@ package main; use strict; use warnings; use IO::Socket::Multicast; +eval "use IO::Interface;1" or my $IOInterfaceAbsent = 1; use Blocking; eval "use FHEM::Meta;1" or my $modMetaAbsent = 1; # Versions History by DS_Starter our %SMAEM_vNotesIntern = ( + "4.2.0" => "14.04.2020 delete 'use bignum' ", + "4.1.0" => "17.03.2020 add define option ", "4.0.1" => "10.02.2020 fix perl warning Forum: https://forum.fhem.de/index.php/topic,51569.msg1021988.html#msg1021988", "4.0.0" => "16.12.2019 change module to OBIS metric resolution, change Readings Lx_THD to Lx_Strom, FirmwareVersion to SoftwareVersion ". "new attribute \"noCoprocess\", many internal code changes ", @@ -166,6 +169,9 @@ sub SMAEM_Define ($$) { my ($success, $gridin_sum, $gridout_sum); my $socket; + my @a = split("[ \t][ \t]*", $def); + my $if = $a[2] ? $a[2] : ""; + $hash->{INTERVAL} = 60; $hash->{HELPER}{FAULTEDCYCLES} = 0; $hash->{HELPER}{STARTTIME} = time(); @@ -185,7 +191,15 @@ sub SMAEM_Define ($$) { Log3 $hash, 3, "SMAEM $name - Multicast socket opened"; - $socket->mcast_add('239.12.255.254'); + if($a[2]) { + eval { $socket->mcast_add('239.12.255.254',$if); }; + if ($@) { + return "Socket error in define ('239.12.255.254',$if): $@"; + } + } else { + $socket->mcast_add('239.12.255.254'); + } + $hash->{TCPDev} = $socket; $hash->{FD} = $socket->fileno(); @@ -194,6 +208,8 @@ sub SMAEM_Define ($$) { $hash->{HELPER}{MODMETAABSENT} = 1 if($modMetaAbsent); # Modul Meta.pm nicht vorhanden + Log3($name, 3, "$name - The perl module \"IO::Interface\" is missing. You should install it.") if($IOInterfaceAbsent); + # Versionsinformationen setzen SMAEM_setVersionInfo($hash); @@ -470,6 +486,7 @@ sub SMAEM_DoParse ($) { my $length; my ($b,$c,$d,$e); # OBIS Klassen + no warnings qw(overflow portable); while (substr($hex,$i,8) ne "00000000" && $i<=($dl*2)) { $b = hex(substr($hex,$i,2)); $c = hex(substr($hex,$i+2,2)); @@ -485,6 +502,7 @@ sub SMAEM_DoParse ($) { $obis->{"1:".$c.".".$d.".".$e} = hex(substr($hex,$i+8,$length)); $i = $i + 8 + $length; } + use warnings; Log3 ($name, 5, "SMAEM $name - OBIS metrics identified:"); my @ui; # Array für "unknown items" @@ -1084,9 +1102,10 @@ return; Define