The PRESENCE module provides several possibilities to check the presence of mobile phones or similar mobile devices such as tablets.
This module provides several operational modes to serve your needs. These are:
- 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
- lan-bluetooth - A presence check of a bluetooth device via LAN network by connecting to a presenced or collectord instance
Define
Mode: lan-ping
define <name> PRESENCE lan-ping <ip-address> [ <check-interval> ]
Checks for a network device via PING requests and reports its presence state.
Mode: fritzbox
define <name> PRESENCE fritzbox <device-name> [ <check-interval> ]
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
Mode: local-bluetooth
define <name> PRESENCE local-bluetooth <bluetooth-address> [ <check-interval> ]
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: 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.
define <name> PRESENCE <ip-address>[:port] <bluetooth-address> [ <check-interval> ]
The default port is 5111 (presenced). Alternatly you can use port 5222 (collectord)
presenced
The presence is a perl network daemon, which provides presence checks of multiple bluetooth devices over network.
It listens on TCP port 5111 for incoming connections from a FHEM PRESENCE instance or a running collectord.
Usage:
presenced -d [-p <port>] [-P <filename>]
presenced [-h | --help]
Options:
-p, --port
TCP Port which should be used (Default: 5111)
-P, --pid-file
PID file for storing the local process id (Default: /var/run/presenced.pid)
-d, --daemon
detach from terminal and run as background daemon
-v, --verbose
Print detailed log output
-h, --help
Print detailed help screen
It uses the hcitool command (provided by a bluez installation)
to make a paging request to the given bluetooth address (like 01:B4:5E:AD:F6:D3). The devices must not be visible, but
still activated to receive bluetooth requests.
If a device is present, this is send to FHEM, as well as the device name as reading.
The presenced is available as:
collectord
The collectord is a perl network daemon, which handles connections to several presenced installations to search for multiple bluetooth devices over network.
It listens on TCP port 5222 for incoming connections from a FHEM presence instance.
Usage:
collectord -c <configfile> [-d] [-p <port>] [-P <pidfile>]
collectord [-h | --help]
Options:
-c, --configfile <configfile>
The config file which contains the room and timeout definitions
-p, --port
TCP Port which should be used (Default: 5222)
-P, --pid-file
PID file for storing the local process id (Default: /var/run/collectord.pid)
-d, --daemon
detach from terminal and run as background daemon
-v, --verbose
Print detailed log output
-l, --logfile <logfile>
log to the given logfile
-h, --help
Print detailed help screen
Before the collectord can be used, it needs a config file, where all different rooms, which have a presenced detector, will be listed. This config file looks like:
# room definition
# ===============
#
[room-name] # name of the room
address=192.168.0.10 # ip-address or hostname
port=5111 # tcp port which should be used (5111 is default)
presence_timeout=120 # timeout in seconds for each check when devices are present
absence_timeout=20 # timeout in seconds for each check when devices are absent
[living room]
address=192.168.0.11
port=5111
presence_timeout=180
absence_timeout=20
If a device is present in any of the configured rooms, this is send to FHEM, as well as the device name as reading and the room which has detected the device.
The collectord is available as:
Set
- statusRequest - (Only for local-bluetooth, lan-ping and fritzbox) - Schedules an immediatly check.
Get
Attributes
- loglevel
- do_not_notify
- readingFnAttributes
- disable
If this attribute is activated, an active check will be disabled.
Possible values: 0 => not disabled , 1 => disabled
Default Value is 0 (not disabled)
- fritzbox_repeater
(Only in Mode "fritzbox" applicable)
If your FritzBox is part of a network using repeaters, than this attribute needs to be enabled to ensure a correct recognition for devices, which are connected via repeater.
This attribute is also needed, if your network device has no speed information on the FritzBox website (Home Network).
BE AWARE: The recognition of device going absent in a repeated network can take about 15 - 20 minutes!!
Possible values: 0 => Use default recognition, 1 => Use repeater-supported recognition
Default Value is 0 (Use default recognition)
Generated Events:
General Events:
- state: $state (absent|present|disabled) - The state of the device or "disabled" when the disable attribute is enabled
Bluetooth specific events:
- device_name: $name - The name of the Bluetooth device in case it's present
presenced/collectord specific events:
- command_accepted: $command_accepted (yes|no) - Was the last command acknowleged and accepted by the presenced or collectord?
- room: $room - If the module is connected with a collector daemon this event shows the room, where the device is located (as defined in the collectord config file)
=end html
=begin html_DE
PRESENCE
Das PRESENCE Module bietet mehrere Möglichkteiten um die Anwesenheit von Handys/Smartphones oder anderen mobilen Geräten (z.B. Tablets) zu erkennen.
Dieses Modul bietet dazu mehrere Modis an um Anwesenheit zu erkennen. Diese sind:
- 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
- lan-bluetooth - Eine Erkennung durch Bluetooth-Abfragen via Netzwerk (LAN/WLAN) in ein oder mehreren Räumen
Define
Modus: lan-ping
define <name> PRESENCE lan-ping <IP-Addresse oder Hostname> [ <Interval> ]
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> ]
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.
Modus: local-bluetooth
define <name> PRESENCE local-bluetooth <Bluetooth-Adresse> [ <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: 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.
define <name> PRESENCE <IP-Adresse>[:Port] <Bluetooth-Adresse> [ <Interval> ]
Der Standardport ist 5111 (presenced). Alternativ kann man den Port 5222 (collectord) nutzen. Generell ist der Port aber frei wählbar.
presenced
Der presenced ist ein Perl Netzwerk Dienst, welcher eine Bluetooth-Anwesenheitserkennung von ein oder mehreren Geräten über Netzwerk bereitstellt.
Dieser lauscht standardmäßig auf TCP Port 5111 nach eingehenden Verbindungen von dem PRESENCE Modul oder einem collectord.
Usage:
presenced -d [-p <port>] [-P <filename>]
presenced [-h | --help]
Options:
-p, --port
TCP Port which should be used (Default: 5111)
-P, --pid-file
PID file for storing the local process id (Default: /var/run/presenced.pid)
-d, --daemon
detach from terminal and run as background daemon
-v, --verbose
Print detailed log output
-h, --help
Print detailed help screen
Zur Bluetooth-Abfrage wird der Shell-Befehl "hcitool" verwendet (Paket: bluez)
um sogenannte "Paging-Request" an die gewünschte Bluetooth Adresse (z.B. 01:B4:5E:AD:F6:D3) durchzuführen. Das Gerät muss dabei nicht sichtbar sein, allerdings ständig aktiviert sein
um Bluetooth-Anfragen zu beantworten.
Wenn ein Gerät anwesend ist, wird dies an FHEM übermittelt zusammen mit dem Gerätenamen als Reading.
Der presenced ist zum Download verfügbar als:
collectord
Der collectord ist ein Perl Netzwerk Dienst, welcher Verbindungen zu mehreren presenced-Instanzen verwaltet um eine koordinierte Suche nach ein oder mehreren Bluetooth-Geräten über Netzwerk durchzuführen.
Er lauscht auf TCP port 5222 nach eingehenden Verbindungen von einem PRESENCE Modul.
Usage:
collectord -c <configfile> [-d] [-p <port>] [-P <pidfile>]
collectord [-h | --help]
Options:
-c, --configfile <configfile>
The config file which contains the room and timeout definitions
-p, --port
TCP Port which should be used (Default: 5222)
-P, --pid-file
PID file for storing the local process id (Default: /var/run/collectord.pid)
-d, --daemon
detach from terminal and run as background daemon
-v, --verbose
Print detailed log output
-l, --logfile <logfile>
log to the given logfile
-h, --help
Print detailed help screen
Bevor der collectord verwendet werden kann, benötigt er eine Konfigurationsdatei in welcher alle Räume mit einem presenced-Agenten eingetragen sind. Diese Datei sieht wie folgt aus:
# Raum Definitionen
# =================
#
[Raum-Name] # Name des Raumes
address=192.168.0.10 # IP-Adresse oder Hostname
port=5111 # TCP Port welcher benutzt werden soll (standardmäßig 5111)
presence_timeout=120 # Prüfinterval in Sekunden für jede Abfrage eines Gerätes, welches anwesend ist
absence_timeout=20 # Prüfinterval in Sekunden für jede Abfrage eines Gerätes, welches abwesend ist
[Wohnzimmer]
address=192.168.0.11
port=5111
presence_timeout=180
absence_timeout=20
Wenn ein Gerät in irgend einem Raum anwesend ist, wird dies an FHEM übermittelt, zusammen mit dem Gerätenamen und dem Raum, in welchem das Gerät erkannt wurde.
Der collectord ist zum Download verfügbar als:
Set
- statusRequest - (Nu für local-bluetooth, lan-ping and fritzbox) - Startet einen sofortigen Check.
Get
Attributes
- loglevel
- do_not_notify
- readingFnAttributes
- disable
Wenn dieses Attribut aktiviert ist, wird die Anwesenheitserkennung nicht mehr durchgeführt.
Mögliche Werte: 0 => Erkennung durchführen , 1 => Keine Erkennungen durchführen
Standardwert ist 0 (Erkennung durchführen)
- fritzbox_repeater
(Nur im Modus "fritzbox" anwendbar)
Wenn die FritzBox Teil eines Netzwerkes ist, welches mit Repeatern arbeitet, dann muss dieses Attribut gesetzt sein um die Erkennung von Geräten zu gewährleisten,
welche über einen Repeater erreichbar sind.
Dies gilt ebenso für Devices, welche keine Geschwindigkeitsangaben auf der FritzBox Seite (Heimnetz) anzeigen können.
ACHTUNG: Die Erkennung der Abwesenheit eines Gerätes in einem Repeater-Netzwerk kann ca. 15 - 20 Minuten dauern!!
Mögliche Werte: 0 => Standarderkennung verwenden, 1 => Erkennung für Repeatergeräte verwenden
Standardwert ist 0 (Standarderkennung verwenden)
Generierte Events:
Generelle Events:
- state: $state (absent|present|disabled) - Der Anwesenheitsstatus eine Gerätes (absent = abwesend; present = anwesend) oder "disabled" wenn das disable-Attribut aktiviert ist
Bluetooth-spezifische Events:
- device_name: $name - Der Name des Bluetooth-Gerätes, wenn es anwesend (Status: present) ist
presenced-/collectord-spezifische Events:
- command_accepted: $command_accepted (yes|no) - Wurde das letzte Kommando an den presenced/collectord akzeptiert (yes = ja, no = nein)?
- room: $room - Wenn das Modul mit einem collectord verbunden ist, zeigt dieses Event den Raum an, in welchem dieses Gerät erkannt wurde (Raumname entsprechend der Konfigurationsdatei des collectord)
=end html_DE
=cut
| |