mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-20 07:16:03 +00:00
added optional present-check-interval parameter to define a separate check interval if device is present
git-svn-id: https://svn.fhem.de/fhem/trunk@2841 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
be9f58d92a
commit
125f0ce481
@ -63,9 +63,9 @@ PRESENCE_Define($$)
|
|||||||
my @a = split("[ \t]+", $def);
|
my @a = split("[ \t]+", $def);
|
||||||
my $dev;
|
my $dev;
|
||||||
|
|
||||||
if($a[2] ne "lan-bluetooth" and not (@a == 4 or @a == 5))
|
if($a[2] ne "lan-bluetooth" and not (@a == 4 or @a == 5 or @a == 6))
|
||||||
{
|
{
|
||||||
my $msg = "wrong syntax: define <name> PRESENCE <mode> <device-address> [ <check-interval> ]";
|
my $msg = "wrong syntax: define <name> PRESENCE <mode> <device-address> [ <check-interval> [ <present-check-interval> ] ]";
|
||||||
Log 2, $msg;
|
Log 2, $msg;
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
@ -82,16 +82,18 @@ PRESENCE_Define($$)
|
|||||||
my $address = $a[3];
|
my $address = $a[3];
|
||||||
my $timeout = (defined($a[4]) ? $a[4] : 30);
|
my $timeout = (defined($a[4]) ? $a[4] : 30);
|
||||||
|
|
||||||
$timeout = (defined($a[5]) ? $a[5] : 30) if($destination eq "lan-bluetooth");
|
my $presence_timeout = (defined($a[5]) ? $a[5] : $timeout);
|
||||||
|
|
||||||
|
$timeout = (defined($a[5]) ? $a[5] : 30) if($destination eq "lan-bluetooth");
|
||||||
|
$presence_timeout = (defined($a[6]) ? $a[6] : 30) if($destination eq "lan-bluetooth");
|
||||||
|
|
||||||
$hash->{ADDRESS} = $address;
|
$hash->{ADDRESS} = $address;
|
||||||
$hash->{TIMEOUT} = $timeout;
|
$hash->{TIMEOUT_NORMAL} = $timeout;
|
||||||
|
$hash->{TIMEOUT_PRESENT} = $presence_timeout;
|
||||||
|
|
||||||
if(defined($timeout) and not $timeout =~ /^\d+$/)
|
if(defined($timeout) and not $timeout =~ /^\d+$/)
|
||||||
{
|
{
|
||||||
my $msg = "timeout must be a number";
|
my $msg = "check-interval must be a number";
|
||||||
Log 2, "PRESENCE: ".$msg;
|
Log 2, "PRESENCE: ".$msg;
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
@ -99,7 +101,23 @@ PRESENCE_Define($$)
|
|||||||
|
|
||||||
if(defined($timeout) and not $timeout > 0)
|
if(defined($timeout) and not $timeout > 0)
|
||||||
{
|
{
|
||||||
my $msg = "timeout must be greater than zero";
|
my $msg = "check-interval must be greater than zero";
|
||||||
|
Log 2, "PRESENCE: ".$msg;
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(defined($presence_timeout) and not $presence_timeout =~ /^\d+$/)
|
||||||
|
{
|
||||||
|
my $msg = "presence-check-interval must be a number";
|
||||||
|
Log 2, "PRESENCE: ".$msg;
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(defined($presence_timeout) and not $presence_timeout > 0)
|
||||||
|
{
|
||||||
|
my $msg = "presence-check-interval must be greater than zero";
|
||||||
Log 2, "PRESENCE: ".$msg;
|
Log 2, "PRESENCE: ".$msg;
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
@ -357,7 +375,7 @@ PRESENCE_DoInit($)
|
|||||||
|
|
||||||
unless($hash->{helper}{DISABLED})
|
unless($hash->{helper}{DISABLED})
|
||||||
{
|
{
|
||||||
DevIo_SimpleWrite($hash, $hash->{ADDRESS}."|".$hash->{TIMEOUT}."\n", 0);
|
DevIo_SimpleWrite($hash, $hash->{ADDRESS}."|".$hash->{TIMEOUT_NORMAL}."\n", 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -627,7 +645,7 @@ PRESENCE_ProcessLocalScan($)
|
|||||||
unless($local)
|
unless($local)
|
||||||
{
|
{
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
InternalTimer(gettimeofday()+$hash->{TIMEOUT}, "PRESENCE_StartLocalScan", $hash, 0) unless($hash->{helper}{DISABLED});
|
InternalTimer(gettimeofday()+($a[2] eq "present" ? $hash->{TIMEOUT_PRESENT} : $hash->{TIMEOUT_NORMAL}), "PRESENCE_StartLocalScan", $hash, 0) unless($hash->{helper}{DISABLED});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1;
|
1;
|
||||||
@ -652,17 +670,17 @@ PRESENCE_ProcessLocalScan($)
|
|||||||
<a name="PRESENCEdefine"></a>
|
<a name="PRESENCEdefine"></a>
|
||||||
<b>Define</b><br><br>
|
<b>Define</b><br><br>
|
||||||
<ul><b>Mode: lan-ping</b><br><br>
|
<ul><b>Mode: lan-ping</b><br><br>
|
||||||
<code>define <name> PRESENCE lan-ping <ip-address> [ <check-interval> ]</code><br>
|
<code>define <name> PRESENCE lan-ping <ip-address> [ <check-interval> [ <present-check-interval> ] ]</code><br>
|
||||||
<br>
|
<br>
|
||||||
Checks for a network device via PING requests and reports its presence state.<br>
|
Checks for a network device via PING requests and reports its presence state.<br>
|
||||||
<br>
|
<br>
|
||||||
<b>Mode: fritzbox</b><br><br>
|
<b>Mode: fritzbox</b><br><br>
|
||||||
<code>define <name> PRESENCE fritzbox <device-name> [ <check-interval> ]</code><br>
|
<code>define <name> PRESENCE fritzbox <device-name> [ <check-interval> [ <present-check-interval> ] ]</code><br>
|
||||||
<br>
|
<br>
|
||||||
Checks for a network device by requesting the internal state on a FritzBox via ctlmgr_ctl. The device-name must be the same as shown in the network overview of the FritzBox<br>
|
Checks for a network device by requesting the internal state on a FritzBox via ctlmgr_ctl. The device-name must be the same as shown in the network overview of the FritzBox<br>
|
||||||
<br>
|
<br>
|
||||||
<b>Mode: local-bluetooth</b><br><br>
|
<b>Mode: local-bluetooth</b><br><br>
|
||||||
<code>define <name> PRESENCE local-bluetooth <bluetooth-address> [ <check-interval> ]</code><br>
|
<code>define <name> PRESENCE local-bluetooth <bluetooth-address> [ <check-interval> [ <present-check-interval> ] ]</code><br>
|
||||||
<br>
|
<br>
|
||||||
Checks for a bluetooth device and reports its presence state. For this mode the shell command "hcitool" is required (provided with a <a href="http://www.bluez.org" target="_new">bluez</a> installation under Debian via APT), as well
|
Checks for a bluetooth device and reports its presence state. For this mode the shell command "hcitool" is required (provided with a <a href="http://www.bluez.org" target="_new">bluez</a> installation under Debian via APT), as well
|
||||||
as a functional bluetooth device directly attached to your machine.<br><br>
|
as a functional bluetooth device directly attached to your machine.<br><br>
|
||||||
@ -845,18 +863,18 @@ Options:
|
|||||||
<a name="PRESENCEdefine"></a>
|
<a name="PRESENCEdefine"></a>
|
||||||
<b>Define</b><br><br>
|
<b>Define</b><br><br>
|
||||||
<ul><b>Modus: lan-ping</b><br><br>
|
<ul><b>Modus: lan-ping</b><br><br>
|
||||||
<code>define <name> PRESENCE lan-ping <IP-Addresse oder Hostname> [ <Interval> ]</code><br>
|
<code>define <name> PRESENCE lan-ping <IP-Addresse oder Hostname> [ <Interval> [ <Anwesend-Interval> ] ]</code><br>
|
||||||
<br>
|
<br>
|
||||||
Prüft ob ein Gerät über Netzwerk (üblicherweise WLAN) auf Ping-Anfragen reagiert und setzt entsprechend den Anwesenheitsstatus.<br>
|
Prüft ob ein Gerät über Netzwerk (üblicherweise WLAN) auf Ping-Anfragen reagiert und setzt entsprechend den Anwesenheitsstatus.<br>
|
||||||
<br>
|
<br>
|
||||||
<b>Modus: fritzbox</b><br><br>
|
<b>Modus: fritzbox</b><br><br>
|
||||||
<code>define <name> PRESENCE fritzbox <device-name> [ <Interval> ]</code><br>
|
<code>define <name> PRESENCE fritzbox <device-name> [ <Interval> [ <Anwesend-Interval> ] ]</code><br>
|
||||||
<br>
|
<br>
|
||||||
Prüft ob ein Gerät welches per WLAN mit der FritzBox verbunden ist, erreichbar durch Abfrage des Status mit dem Befehl ctlmgr_ctl.
|
Prüft ob ein Gerät welches per WLAN mit der FritzBox verbunden ist, erreichbar durch Abfrage des Status mit dem Befehl ctlmgr_ctl.
|
||||||
Der Gerätename (Parameter: <device-name>) muss dem Namen entsprechen, welcher im Menüpunkt "Heimnetz" auf der FritzBox-Oberfläche angezeigt wird.<br>
|
Der Gerätename (Parameter: <device-name>) muss dem Namen entsprechen, welcher im Menüpunkt "Heimnetz" auf der FritzBox-Oberfläche angezeigt wird.<br>
|
||||||
<br>
|
<br>
|
||||||
<b>Modus: local-bluetooth</b><br><br>
|
<b>Modus: local-bluetooth</b><br><br>
|
||||||
<code>define <name> PRESENCE local-bluetooth <Bluetooth-Adresse> [ <Interval> ]</code><br>
|
<code>define <name> PRESENCE local-bluetooth <Bluetooth-Adresse> [ <Interval> [ <Anwesend-Interval> ] ]</code><br>
|
||||||
<br>
|
<br>
|
||||||
Prüft ob ein Bluetooth-Gerät abgefragt werden kann und meldet dies als Anwesenheit. Für diesen Modus wird der Shell-Befehl "hcitool" benötigt
|
Prüft ob ein Bluetooth-Gerät abgefragt werden kann und meldet dies als Anwesenheit. Für diesen Modus wird der Shell-Befehl "hcitool" benötigt
|
||||||
(wird durch das Paket <a href="http://www.bluez.org" target="_new">bluez</a> bereitgestellt), sowie ein funktionierender Bluetooth-Empfänger (intern oder als USB-Stick)<br><br>
|
(wird durch das Paket <a href="http://www.bluez.org" target="_new">bluez</a> bereitgestellt), sowie ein funktionierender Bluetooth-Empfänger (intern oder als USB-Stick)<br><br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user