2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 01:09:47 +00:00

PRESENCE: use getlogin and getpwuid to obtain FHEM username; use usleep instead of sleep.

git-svn-id: https://svn.fhem.de/fhem/trunk@5188 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2014-03-10 16:58:36 +00:00
parent 260b576037
commit ece3afa80f

View File

@ -30,7 +30,7 @@ package main;
use strict; use strict;
use warnings; use warnings;
use Blocking; use Blocking;
use Time::HiRes qw(gettimeofday sleep); use Time::HiRes qw(gettimeofday usleep sleep);
use DevIo; use DevIo;
@ -62,7 +62,7 @@ PRESENCE_Define($$)
my ($hash, $def) = @_; my ($hash, $def) = @_;
my @a = split("[ \t]+", $def); my @a = split("[ \t]+", $def);
my $dev; my $dev;
my $username = (getpwuid($<))[0]; my $username = getlogin || getpwuid($<) || "[unknown]";
if(defined($a[2]) and defined($a[3])) if(defined($a[2]) and defined($a[3]))
{ {
@ -582,7 +582,7 @@ PRESENCE_ExecuteFritzBoxCMD($$)
qx(touch /var/tmp/fhem-PRESENCE-cmd-lock.tmp); qx(touch /var/tmp/fhem-PRESENCE-cmd-lock.tmp);
$status = qx($cmd); $status = qx($cmd);
usleep 200000;
unlink("/var/tmp/fhem-PRESENCE-cmd-lock.tmp") if(-e "/var/tmp/fhem-PRESENCE-cmd-lock.tmp"); unlink("/var/tmp/fhem-PRESENCE-cmd-lock.tmp") if(-e "/var/tmp/fhem-PRESENCE-cmd-lock.tmp");
return $status; return $status;
@ -668,7 +668,7 @@ PRESENCE_DoLocalFritzBoxScan($)
} }
$number++; $number++;
sleep 0.2;
} }
return ($status == 0 ? "$name|$local|absent" : "$name|$local|present").($number <= $max ? "|$number" : ""); return ($status == 0 ? "$name|$local|absent" : "$name|$local|present").($number <= $max ? "|$number" : "");