From aa50f1bb5da3ed1eaaf204799216a087c8584624 Mon Sep 17 00:00:00 2001
From: markusbloch <>
Date: Tue, 16 Apr 2013 16:27:27 +0000
Subject: [PATCH] new mode "function"
git-svn-id: https://svn.fhem.de/fhem/trunk@3079 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/CHANGED | 2 ++
fhem/FHEM/73_PRESENCE.pm | 20 ++++++++++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/fhem/CHANGED b/fhem/CHANGED
index 7ab5d821b..dece91128 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII
- SVN
+ - feature: PRESENCE: new mode "function" to use own perl functions for
+ presence checks
- bugfix: fixing not-working FHEM restart, when a PRESENCE check is running
- bugfix: fixing memory overflow when "list" a PRESENCE definition
- bugfix: fixing dead PRESENCE definitions in case of timeouts
diff --git a/fhem/FHEM/73_PRESENCE.pm b/fhem/FHEM/73_PRESENCE.pm
index 25ec7d5ad..51697f17f 100755
--- a/fhem/FHEM/73_PRESENCE.pm
+++ b/fhem/FHEM/73_PRESENCE.pm
@@ -876,6 +876,7 @@ PRESENCE_ProcessAbortedScan($)
lan-ping - A presence check of a device via network ping in your LAN/WLAN
fritzbox - A presence check by requesting the device state from the FritzBox internals (only available when running FHEM on a FritzBox!)
local-bluetooth - A presence check by searching directly for a given bluetooth device nearby
+ function - A presence check by using your own perl function which returns a presence status
lan-bluetooth - A presence check of a bluetooth device via LAN network by connecting to a presenced or collectord instance
@@ -896,6 +897,11 @@ PRESENCE_ProcessAbortedScan($)
Checks for a bluetooth device and reports its presence state. For this mode the shell command "hcitool" is required (provided with a bluez installation under Debian via APT), as well
as a functional bluetooth device directly attached to your machine.
+ Mode: function
+ define <name> PRESENCE function {...} [ <check-interval> [ <present-check-interval> ] ]
+
+ Checks for a presence state via perl-code. You can use a self-written perl function to obtain the presence state of a specific device (e.g. via SNMP check).
+ The function must return 0 (absent) or 1 (present).
Mode: lan-bluetooth
Checks for a bluetooth device with the help of presenced or collectord. They can be installed where-ever you like, just must be accessible via network.
The given device will be checked for presence status.
@@ -1000,7 +1006,7 @@ Options:
Set
- - statusRequest - (Only for local-bluetooth, lan-ping and fritzbox) - Schedules an immediatly check.
+ - statusRequest - (Only for mode local-bluetooth, lan-ping, function and fritzbox) - Schedules an immediatly check.
@@ -1069,6 +1075,7 @@ Options:
lan-ping - Eine Erkennung auf Basis von Ping-Tests im lokalen LAN/WLAN
fritzbox - Eine Erkennung aufgrund der internen Abfrage des Status auf der FritzBox (nur möglich, wenn FHEM auf einer FritzBox läuft)
local-bluetooth - Eine Erkennung auf Basis von Bluetooth-Abfragen durch den FHEM Server. Das Gerät muss dabei in Empfangsreichweite sein, aber nicht sichtbar sein
+ function - Eine Erkennung mithilfe einer selbst geschriebenen Perl-Funktion, welche den Anwesenheitsstatus ermittelt.
lan-bluetooth - Eine Erkennung durch Bluetooth-Abfragen via Netzwerk (LAN/WLAN) in ein oder mehreren Räumen
@@ -1080,16 +1087,21 @@ Options:
Prüft ob ein Gerät über Netzwerk (üblicherweise WLAN) auf Ping-Anfragen reagiert und setzt entsprechend den Anwesenheitsstatus.
Modus: fritzbox
- define <name> PRESENCE fritzbox <device-name> [ <Interval> [ <Anwesend-Interval> ] ]
+ define <name> PRESENCE fritzbox <Gerätename> [ <Interval> [ <Anwesend-Interval> ] ]
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.
+ Der Gerätename (Parameter: <Gerätename>) muss dem Namen entsprechen, welcher im Menüpunkt "Heimnetz" auf der FritzBox-Oberfläche angezeigt wird.
Modus: local-bluetooth
define <name> PRESENCE local-bluetooth <Bluetooth-Adresse> [ <Interval> [ <Anwesend-Interval> ] ]
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 bluez bereitgestellt), sowie ein funktionierender Bluetooth-Empfänger (intern oder als USB-Stick)
+ Modus: function
+ define <name> PRESENCE function {...} [ <Interval> [ <Anwesend-Interval> ] ]
+
+ Prüft den Anwesenheitsstatus mithilfe einer selbst geschriebenen Perl-Funktion (z.B. SNMP Abfrage).
+ Diese Funktion muss 0 (Abwesend) oder 1 (Anwesend) zurückgeben.
Modus: lan-bluetooth
Prüft ein Bluetooth-Gerät auf Anwesenheit über Netzwerk mit Hilfe von presenced oder collectord. Diese können auf jeder Maschine installiert werden,
welche eine Standard-Perl-Umgebung bereitstellt und über Netzwerk erreichbar ist.
@@ -1197,7 +1209,7 @@ Options:
Set
- - statusRequest - (Nu für local-bluetooth, lan-ping and fritzbox) - Startet einen sofortigen Check.
+ - statusRequest - (Nur für Modus local-bluetooth, lan-ping, function und fritzbox) - Startet einen sofortigen Check.