Hallo,
da bei mir für FHEM eine ausgediente FB 7170 zuständig ist und alle
Geräte sich an der FB 7270 anmelden habe ich folgendes umgesetzt:
Unter fhem/FhemUtils
das folgende Script: lanping.sh ablegen und ausführbar machen ( chmod
755 lanping.sh ):
#!/bin/bash
if [ -n "$1" ]; then
/bin/ping -q -c1 $1 &> /dev/null
else
echo "Ergebnis: $0 <host>"
exit 1
fi
if [ "$?" -gt 0 ]; then
echo $1 Fehler
else
echo $1 Ok
fi
exit 0
In der
99_myutils.pm folgendes eintragen:
sub right{
my ($string,$nr) = @_;
return substr $string, -$nr, $nr;
}
sub left{
my ($string,$nr) = @_;
return substr $string, 0, $nr;
}
#
http://www.somacon.com/p114.php
# Perl trim function to remove whitespace from the start and end of
the string
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
# Left trim function to remove leading whitespace
sub ltrim($)
{
my $string = shift;
$string =~ s/^\s+//;
return $string;
}
# Right trim function to remove trailing whitespace
sub rtrim($)
{
my $string = shift;
$string =~ s/\s+$//;
return $string;
}
sub
FhemLanStat($$)
{
my $net_device=$_[0];
my $attendance="Abwesend";
$net_device=qx(/var/media/ftp/uStor01/fhem/fhem/fhem/FhemUtils/
lanping.sh $net_device);
if(right(trim($net_device), 2) eq "Ok"){
$attendance="Anwesend";
} else {
$attendance="Abwesend";
}
fhem "set $_[1] $attendance";
}
Beispiel fuer Definition in fhem.cfg:
define BinDa dummy
attr BinDa icon icoHouse.png
attr BinDa room WerIstZuHause
attr BinDa setList Anwesend Abwesend
# Netzadresse = ip oder Name
# Name von Dummy hier = BinDa
define SucheBinDa notify SucheBinDa {FhemLanStat("Netzadresse", "Name
von Dummy")}
define TriggerBinDa at +*00:05:00 trigger SucheBinDa
Viele Spaß beim ausprobieren Jörg