diff --git a/fhem/FHEM/73_PRESENCE2.pm b/fhem/FHEM/73_PRESENCE2.pm
index ab13af9a0..6db91cacd 100644
--- a/fhem/FHEM/73_PRESENCE2.pm
+++ b/fhem/FHEM/73_PRESENCE2.pm
@@ -33,7 +33,7 @@ use Blocking;
use Time::HiRes qw(gettimeofday usleep sleep);
use DevIo;
-my $ModulVersion = "01.03b";
+my $ModulVersion = "01.03c";
my %LOG_Text = (
0 => "SERVER:",
1 => "ERROR:",
@@ -295,10 +295,24 @@ sub PRESENCE2_Define($$) {
:($^O =~ m/solaris/) ? "ping $hash->{ADDRESS} 4"
: "ping -c 1 -w 1 $hash->{ADDRESS} 2>&1"
;
+
$hash->{helper}{os}{search} = $^O =~ m/solaris/? 'is alive'
: '(ttl|TTL)=\d+'
;
+ if ($^O !~ m/solaris/ && $^O !~ m/(Win|cygwin)/) {
+ my $pingAttr = "disable:0,1 "
+ . "pingParam "
+ . "thresholdAbsence "
+ . "intervalNormal "
+ . "intervalPresent "
+ . "prGroup:multiple,static,dynamic "
+ . "prGroupDisp:condense,verbose "
+ . "FhemLog3Std:0,1 "
+ . $readingFnAttributes;
+ setDevAttrList($hash->{NAME}, $pingAttr);
+ }
+
}
elsif($a[2] eq "lan-bluetooth") {
delete $attr{$name}{nonblockingTimeOut};
@@ -409,7 +423,7 @@ sub PRESENCE2_Define($$) {
setDevAttrList($hash->{NAME}, $daemonAttr);
}
else {
- my $msg = "unknown mode \"".$a[2]."\" in define statement: Please use lan-ping, daemon, shellscript, function,bluetooth,lan-bluetooth";
+ my $msg = "unknown mode \"".$a[2]."\" in define statement: Please use lan-ping, daemon, shellscript, function, bluetooth, lan-bluetooth";
Log 2, "PRESENCE2 ($name) - ".$msg;
return $msg
}
@@ -430,7 +444,7 @@ sub PRESENCE2_Define($$) {
InternalTimer(2,"PRESENCE2_updateConfig", $hash->{helper}{updateConfig});
}
- PRESENCE2_Log $name, 2, "define gaceful done";
+ PRESENCE2_Log $name, 2, "define done";
return undef;
}
@@ -865,6 +879,23 @@ sub PRESENCE2_Attr(@) {
$hash->{helper}{os}{search} = '([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}';
}
}
+ elsif ($a[2] eq "pingParam" ) {
+ return $a[2] . " only used by ping for Linux" if($hash->{MODE} ne "lan-ping");
+ return $a[2] . " only used by ping for Linux/Windows/CygWin" if($^O =~ m/solaris/ || $^O =~ m/(Win|cygwin)/);
+
+ my $regex = qr/(-[cwi] ?\d{1,3}|-q -[cwi] ?\d{1,3}){0,1} ?(-[cwi] ?\d{1,3}|-q -[cwi] ?\d{1,3}){0,1} ?(-[cwi] ?\d{1,3}|-q -[cwi] ?\d{1,3}|-q){0,1}/ip;
+
+ if ( $a[3] =~ m/$regex/g ) {
+ return $a[2] . " mismatched parameters $a[3]" if length(${^MATCH}) != length($a[3]);
+ } else {
+ return $a[2] . " mismatched parameters $a[3]";
+ }
+
+ $hash->{helper}{os}{Cmd} = ($^O =~ m/(Win|cygwin)/) ? "ping $a[3] $hash->{ADDRESS}"
+ : ($^O =~ m/solaris/) ? "ping $hash->{ADDRESS} 4"
+ : "ping $a[3] $hash->{ADDRESS} 2>&1"
+ ;
+ }
}
@@ -916,6 +947,13 @@ sub PRESENCE2_Attr(@) {
$hash->{helper}{os}{Cmd} .= ' ' . $hash->{helper}{os}{hcitoolParam} . ' ' . $hash->{ADDRESS} . ' 2>/dev/null';
}
+ elsif ($a[2] eq "pingParam" ) {
+
+ $hash->{helper}{os}{Cmd} = ($^O =~ m/(Win|cygwin)/) ? "ping -n 1 -4 $hash->{ADDRESS}"
+ : ($^O =~ m/solaris/) ? "ping $hash->{ADDRESS} 4"
+ : "ping -c 1 -w 1 $hash->{ADDRESS} 2>&1"
+ ;
+ }
}
if($a[2] eq "intervalNormal"){
@@ -1183,7 +1221,7 @@ sub PRESENCE2_daemonScanScheduler($;$) {
, $nonBlockingTimeout
, "PRESENCE2_daemonAbortedScan"
, $hash);
-# $hash->{helper}{RUNNING_PID}->{loglevel} = GetVerbose($name);
+ $hash->{helper}{RUNNING_PID}->{loglevel} = GetVerbose($name);
}
}
}
@@ -1218,17 +1256,19 @@ sub PRESENCE2_daemonScanReply($) {
delete $hash->{helper}{RUNNING_PID};
foreach my $res (@result){
- my ($eName,$eSstate) = split('\|',$res);
+ my ($eName, $eSstate) = split('\|',$res);
+ if ($eName) {
readingsBeginUpdate($defs{$eName});
PRESENCE2_ProcessState($defs{$eName}, $eSstate);
readingsEndUpdate($defs{$eName}, 1);
+ }
}
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "state", "active");
foreach (@result){
- my ($eName,$eSstate) = split('\|',$_);
- readingsBulkUpdate($hash, "pr_".$eName, $eSstate);
+ my ($eName, $eSstate) = split('\|',$_);
+ readingsBulkUpdate($hash, "pr_".$eName, $eSstate) if $eName;
}
readingsBulkUpdate($hash, 'daemonMaxScanTime', $duration)if ($duration > ReadingsVal($name,'daemonMaxScanTime',0));
@@ -1703,26 +1743,25 @@ Options:
set <name> intervalPresent <seconds>
attr <name> intervalPresent <seconds>
set <name> intervalNormal <seconds>
attr <name> intervalNormal <seconds>
nonblockingTimeOut <30..240>
attr <name> nonblockingTimeOut <30..240>>
set <name> bluetoothHciDevice <hci[0..n]>
attr <name> bluetoothHciDevice <hci[0..n]>
set <name> hcitoolParam <name|info>
attr <name> hcitoolParam <name|info>
attr <name> pingParam <params>
set <name> disable <0|1>
attr <name> disable <0|1>
set <name> prGroup <static|dynamic|...>
attr <name> prGroup <static|dynamic|...>
set <name> prGroupDisp <condense|verbose>
attr <name> prGroupDisp <condense|verbose>
attr <name> thresholdAbsence <seconds>
set <name> thresholdAbsence <seconds>
attr <name> presentCycle <seconds>
attr <name> presentReading <name of the reading>
set <name> intervalPresent <Sekunden>
attr <name> intervalPresent <Sekunden>
set <name> intervalNormal <Sekunden>
attr <name> intervalNormal <Sekunden>
nonblockingTimeOut <30..240>
attr <name> nonblockingTimeOut <30..240>
set <name> bluetoothHciDevice <hci[0..n]>
attr <name> bluetoothHciDevice <hci[0..n]>
set <name> hcitoolParam <name|info>
attr <name> hcitoolParam <name|info>
attr <name> pingParam <params>
set <name> disable <0|1>
attr <name> disable <0|1>
set <name> prGroup <static|dynamic|...>
attr <name> prGroup <static|dynamic|...>
set <name> prGroupDisp <condense|verbose>
attr <name> prGroupDisp <condense|verbose>
set <name> thresholdAbsence <Sekunden>
attr <name> thresholdAbsence <Sekunden>
attr <name> presentCycle <Sekunden>
attr <name> presentReading <name des Readings>