Presence detection using Bluetooth BLE for eedomus

beacon_mainWishing to optimize the rules governing my home according to the occupants present, I wanted to be able to detect individual presence of each member of the family.
A method often used in this case is the detection of the presence of Bluetooth Low Energy (BLE) objects such as activity trackers, BLE buttons, beacons, etc. These latter in particular exist in different forms (keyring, sticking buttons) they are small and easily carried.

Unfortunately eedomus controller is not (yet?) compatible with BLE. The detection will therefore be carried out by an external device (server, raspberry pi) and the information provided to eedomus.

Installing the detector

I used the plugin “Presence detection“, initially intended for domoticz in order to realize the bluetooth detection function.
This plugin is independent from domoticz and doesn’t require the installation of the latter. It installs on any system running Linux : linux server, synology, raspberry pi, etc … In my case I installed it in a virtual Ubuntu 16 dedicated to home automation.

beacon_dongle_bt2It’s of course necessary to have a bluetooth interface on this linux system. A bluetooth BLE dongle  with chipset CSR is the recommended solution because it’s widely compatible and very inexpensive. I bought myself this model for 5,83 €.

The dongle installation must be carried out correctly in order to optimize the detection range:

  • bluetooth works in the same frequency band as Wifi, so it is better to move interface away from any wifi element (router, box adsl, …).
  • I advise to install it at the end of a USB extender cable in order to have an optimal location.
  • Like any RF element, it is desirable that the cable has a filtering ferrite to prevent any disturbances generated by the server from reaching the bluetooth dongle

I personally used a USB cable initially supplied with a USB WiFi dongle, on which I added a ferrite. Three turns of cable in the ferrite helps improving filtering efficiency.

 

beacon_dongle

 

I won’t describe installation of the Presence Detection plugin because the dedicated page has a detailed description of the whole procedure. This description is well done, it includes specifics for different platform on which you can install it. Another time, Domoticz doesn’t need to be installed, so the information specific to domoticz isn’t to be taken into account. The Autorun part is also to be put activated. For ubuntu 16 it is Autorun method 2 that must be applied.
The installation would have taken place without any problem in my sinde if I had methodically followed up the instructions, they are indeed complete and clear. In fact, I skipped a few lines … and then I had to go back.

We will return later to the specific configuration to be applied for eedomus. For the moment it is necessary to configure eedomus controller to receive the information.

smartvoice_eedomus_httpactuatorPreparing eedomus controller

For each BLE device to be detected, it is necessary to create a virtual device of type http Actuator.

This actuator must be able to take two values: “HOME” and “AWAY”.

 

beacon_actionneur_config

beacon_actionneur_valeurs

Configuring the script for eedomus

Domoticz API isn’t so different than eedomus one, and script can be configured to adapt easily to eedomus controller.

Everything is contained into variable  “URL_DOMOTICZ” which has to be changed at line 37 with following content :

URL_DOMOTICZ = 'http://LOCAL_IP_OF_EEDOMUS/api/set?action=periph.value&api_user=YOUR_USER&api_secret=YOUR_SECRET_KEY&periph_id=PARAM_IDX&value=PARAM_CMD'

LOCAL_IP_OF_EEDOMUS, YOUR_USER et YOUR_SECRET have to be filled with your personal information. Presence state update is directly sent to eedomuxs on local lan.

Configuring BLE peripherals

All Bluetooth devices have a MAC address. Sometimes it changes in time but the majority of bluetooth objects have a fixed address. Moreover, many BLE objects regularly send frames indicating their presence. It is therefore a question of detecting these frames to detect the presence of the object.

The configuration of the objects to be detected is done from line 53 of the script :

beacon_conf_device

Each object is described on a single line with those parameters :

["Name_of_object", Mac_Address, Tempo, 0, Id_Virtual_Periph, SWITCH_MODE]

  • Name_of_object : indicative name (not used by eedomus)
  • Mac_Address : Mac Address of BLE object to be detected
  • Tempo : delay before AWAY state is aknowledged
  • Id_Virtual_Periph: ID of virtual peripheral on eedomus which has been previously created

Mac address of object can be detected using specific script provided with the plugin and available here : Presence Detection, First step.

You can use also different smartphone apps more or less fonctional like this one : Android Bluetooth LE Scanner

BLE object detection test

For the time being I’ve tested this setup with the following objects :

beacon_test_tibe
Ticatag Tibe connect
 (beacon BLE)
Range is around 10 meters indoor at same floor. BLE signal have difficulties to go through concrete floor, then detection is not possible of Tibe if at second floor in my home.

 

Beacon_test_misfit


Misfit flash
(activity tracker)
The range is very poor, less than 2 meters, then this tracker can’t be used to detect presence in the area of a house but on a very reduced zone.

 

 

beacon_iTAG2


Beacon iTAG (beacon BLE )
Range is around 10-15 metre indoor. BLE signal has difficulty to go through concrete floor, iTAG is hardly detected on second floor.

 

Conclusion

This script, initially dedicated to Domoticz, can be used easily with eedomus. The detection of multiple BLE objects is possible as long as it has a fixed MAC address and it regularly transmits signals.

Once this detection system has been set up, you will be able to set up different rules allowing to automatically switch your house to “Absence” mode for instance.

Vincent Recipon

Propriétaire de ce blog. Owner of this blog.

You may also like...

4 Responses

  1. Compaoré says:

    Bonjour,
    Pensez-vous que ce script serait utilisable pour un smartphone iPhone ? En effet, mon épouse utilise un iPhone. Je souhaiterais que mon système domotique détecte sa présence. Des règles devront s’executer par la suite.
    De mon côté, je suis sur Android et j’utilise avec bonheur Tasker. Peut-être auriez-vous une autre solution pour IOS

    Merci.
    Emmanuel

    • Bonjour, Malheureusement non ce script ne permet pas de détecter la présence d’un smartphone. Par défaut ce type d’appareil n’émet pas de signal Bluetooth (sauf lorsqu’il est en mode appairage). L’iphone se connecte t’il à votre réseau WiFi personnel ? Si oui il est possible de lui affecter une adresse IP fixe et d’utiliser la fonction ping de l’eedomus. Cela reste cependant aléatoire car suivant le smartphone et sa configuration le Wi-Fi est coupé en veille ou pas.

  2. enr37 says:

    salut et merci pour la R&D :p
    perso, j’utilise les smartphones apres les avoir mis en ip fixe. la portée est plus longue.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.