[presence] Reliable, Multi-User, Distributed Bluetooth Occupancy/Presence Detection

Hi @LarsAC
Giving a try of the presence script on an intel NUC (ubuntu VM)
I have installed all the packages in the presence.sh docs but I get an error

Scan result: [Invalid device: No such device]

I’m struggling with bluetooth configuration, but no results…

Did you succeed setting up the bluetooth on the NUC?

Why BLT has to work on the NUC? Or you plan to use that as a sensor?

Solved, bluetooth interface working on the NUC, just had to share it to the VM.

I will use the integrated bluetooth interface with the presence script to detect the BT devices. If coverage is limited I’ll add a rpi zero w as suggested by the author.

1 Like

Glad you got it working!

1 Like

Now I’m experimenting with the reliability of the bluetooth detector, and trying to integrate with my existing home/away automations. Will report results soon :sunglasses:

1 Like

Great work on this :slight_smile:
I have a android mobile phone that this woks very well for, but I also have a Nut BTLE tag that this doesn’t work at all for as it always comes up with confidence 0, does anyone have any suggestions or is it not supposed to work with tags?

presence/owner/keith/xx:xx:xx:1B:6D:28 { version : 0.1.481, confidence : 0, name : Nut, timestamp : Wed Aug 15 2018 11:40:58 GMT+0100 (BST), manufacturer : Unknown , type : Known Static MAC ,“type”:“Known Static MAC” }

BTW I also have some MiFlora plant monitors that come up 100% and some LED BTLE lights that come up 100%

I have the same problem with a nut mini. Always 0.

The device should report as a beacon. Enable the -b flag, and remove the MAC address from known_static_addresses. You’ll see the beacon address in the logs.

I see this in the logs for my Nut…

0.1.481 07:52:53 pm [CMD-RAND] xx:xx:xx:xx:6D:28 ADV_IND RAND_NUM: 2 (x10)

Is the beacon flag enabled? If so, you’ll also see the iBeacon advertisements.

The above is what I see in monitor with the -b option, also this…

0.1.481 10:59:36 pm onds PUBL_NUM: 3
0.1.481 10:59:40 pm [CMD-RAND] xx:xx:xx:xx:6D:28 ADV_IND RAND_NUM: 3
0.1.481 10:59:40 pm onds PUBL_NUM: 3
0.1.481 10:59:43 pm [CMD-RAND] xx:xx:xx:xx:6D:28 ADV_IND RAND_NUM: 3
0.1.481 10:59:43 pm onds PUBL_NUM: 3
0.1.481 10:59:46 pm [CMD-RAND] xx:xx:xx:xx:6D:28 ADV_IND RAND_NUM: 3
0.1.481 10:59:46 pm onds PUBL_NUM: 3
0.1.481 10:59:50 pm [CMD-RAND] xx:xx:xx:xx:6D:28 ADV_IND RAND_NUM: 3
0.1.481 10:59:50 pm onds PUBL_NUM: 3
0.1.481 10:59:53 pm [CMD-RAND] xx:xx:xx:xx:6D:28 ADV_IND RAND_NUM: 3
0.1.481 10:59:53 pm onds PUBL_NUM: 3
0.1.481 10:59:56 pm [CMD-RAND] xx:xx:xx:xx:6D:28 ADV_IND RAND_NUM: 3
0.1.481 10:59:56 pm onds PUBL_NUM: 3
0.1.481 10:59:59 pm [CMD-RAND] xx:xx:xx:xx:6D:28 ADV_IND RAND_NUM: 3
0.1.481 11:00:00 pm onds PUBL_NUM: 3

This likely means that the Nut BTLE tag is not conforming to the iBeacon specification. I’ll see if I can add support for devices like this.

1 Like

Andrew, i’m running precense on one PI Zero right now, with plans on using 6 to cover house plus garage. But with just one running, my wife complained that her BT keyboard was acting strange and those problems dissapeared when I shutdown the Pi.

To make things worse, her office is just next to the entry door to the house, so cant avoid covering that area for precense detection.

How would you solve that issue if you had the same prob?

1 Like

Hello @andrewjfreyer,

New fan of your script thanks to @PianSom.

Please a quick question:

Is it possible for one to estimate the distance of the Bluetooth presence system, from the Bluetooth device based on the confidence?

If it is, could you kindly share some data on your finding? I know it depends on several things like walls in between and type of Bluetooth device, but I just need any little data you might have worked out already if you had considered it before.

Thanks and regards

Hey @Odianosen25 - I’m sure you don’'t want to read what is nearly 500 posts now, but Andrew did mention up here that he has not had very much luck at all with this.

Hey @andrewjfreyer (and any Appdaemon users) - if you haven’t been watching it, you might like to have a look over in the Appdaemon section here at some wonderful coding that @Odianosen25 has just put together for monitor

1 Like

Oh thanks bro, yeah you right, wasn’t really in the mode of reading via the entire threads :smile:.

I was looking at doing some triangulation, but even at that, i think it I will still look at it later to I could at least allow for possible location of which floor a device is.

Like interfacing it with Snips and asking “where is my phone?”. It could give a possible location based on the different readings, even if its not so accurate.

Well a project for another time.

Many thanks again @PianSom, much appreciated :facepunch:t5:

1 Like

I’d make the switch to the monitor script. With low interval values, the presence script has the tendency to interfere with 2.4 GHz devices, including Bluetooth and Wi-Fi.

@PianSom is totally right. The variability in Bluetooth response times and RSSI calculations is far too large for any meaningfully accurate estimations of distance. The best I have been able to do is a plus or minus of 30 to 50 feet. Triangulation with maximum error of 100 feet is really not that useful, haha

I’m sure someone smarter than me is trying to figure out an answer to this question right now

I’m currently on presence without any interference, would you recommend upgrading to monitor? If so, are the install instructions the same as presence? Thanks so much for the amazing work!

One thought occurs to me - are the response times/RSSI at least consistent over time, in your experience? Or do they vary with, for example, atmospheric conditions?

I don’t know about you, but when at home I am usually in one of relatively few locations - in bed, asleep; slumped in front of the TV; in my study; in the bathroom, etc. So I wonder if it might be possible to infer a room location from a database of times/RSSI?