I’ve just installed BlueZ onto my Pi3, and I’d like to get a switch in OH2 to operate when a particular device is present. I can see the devices I want using
sudo hcitool lescan
and also using a Bluetooth LE scanner on my phone. it seems that my tiles may be broadcasting every few seconds which makes them ideal for presence detection.
I’m unsure how to progress further. I found sensorReporter by @rlkoshak which could do the trick but for some reason I can’t get it working on my pi.
I’ve also found an openhab binding that is being worked on
Has anyone else got Bluetooth LE Device detection working, or can help me with this? I’m happy to test things too.
Ideally I’d like to detect the presence of Tiles from their broadcast packets so I can use them as presence information.
Personally I run a nodejs script via cron that checks the status of predefined BT devices - both BT & BTLE. If the script finds any it then pushes the info into my MQTT broker where I can pick it up in OH2.
What exactly is the problem you have installing it? From the readme:
The install script shows the install steps to get the dependencies using using apt-get and pip and to copy and enable the start script to init.d so sensorReporter will start as a service during boot. You must edit the script to match your system. This script is intended to be informational, not to be executed as is.
Did you edit the script to work for your system or just try to run it blindly without editing it?
You can just create sensorReporter.ini directly. The step that makes the link was a trick I used because I deploy sensorReporter to half a dozen machines each with its own separate config file. So I link the config file for a given host to sensorReporter.ini and can reuse the same start script.
So what you need to do is just copy what ever .ini file you want to use to sensorReporter.ini and just use that one file.
That is because the link pointed to a file that doesn’t exist.
That makes sense, so sensorReporter.ini should just contain the hostname?
Any idea what the rest of the errors mean? To my very untrained eye it seems that the config file has a problem with missing headers, but is this in /opt/sensorReporter/sensorReporter.ini or /opt/sensorReporter/default.ini?
Thanks, I’ve copied your file into sensorReporter.ini and changed the logging to a valid location on my system /var/log/sensorReporter.log and it is started.
I can now detect my phone when it is in pairing mode with inquiry.py
Is it possible to detect the presence of BLE stuff with this? I can see them in my phone using a BLE Scanner app, that just gives me a UUID rather than a MAC address. Ultimately I’d like to detect the presence of BLE devices such as Tiles and cheap iBeacon.
A quick google suggests that the support depends on the version. There is something on GIT here https://github.com/IanHarvey/bluepy but getting it to work with your script is way beyond my knowledge!
Does the stuff on GIT make sense to you? Is it likely to give access to UUID’s without rewriting?
If I can find a way of getting iBeacon presence into OpenHAB I can buy a couple of cheap beacons off AliExpress, chuck them in the car glovebox and I will have easy car presence detection, or at least that’s the theory!
I don’t have time right now to study it. The script as written detects devices based on their MAC address. If the device isn’t transmitting or its MAC cannot be detected the script will not work with it.
To update this a bit I’ve combined it with the Network Binding to see whether my iPhone is present or not. The combination of both detection types is enough to steer my presence logic better than using either of them alone. I couldn’t detect the cars bluetooth systems when they were out of pairing mode.
I’ve gone the same route as @rlkoshak for presence detection, although I did do a bit of testing with OwnTracks and bluetooth beacons along the way.
The problem with using an iphone to detect what room you are in is that it spends a lot of its time sleeping without detecting anything other than incoming phone calls / txts etc. Owntracks can detect bluetooth beacons and pass this on to OpenHAB via the Owntracks binding, however when I tried it there was a lag and also a very noticeable battery penalty because the iphone spends less of its time sleeping. The battery penalty may be OK if you have one of the latest phones, but on my iPhone 6 the 2 problems combined meant I gave up on detecting what room I was in. There is a good article to read on room detection with Owntracks here http://jpmens.net/2015/06/03/beacons-in-the-office/
Please update the thread if you get anything that works well.
I’ve also found these https://www.happybubbles.tech/presence/detector along the way that can detect what room you are in and report the signal strength using MQTT. They have a presence server that uses a combination of signal strength from more than one beacon to guess where you are. You do need to carry a bluetooth beacon however, and the MQTT server receives a lot of messages which may impact its reliability if you use it for a lot of other things.