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> [ <timeout> ]
Checks for a network device via PING requests and reports its presence state.
Mode: fritzbox
define <name> PRESENCE fritzbox <device-name> [ <timeout> ]
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> [ <timeout> ]
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> [ <timeout> ]
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
Get
Attributes
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
=cut |