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

That’s the idea, yes. I’m quite likely to roll back a number of features of presence including guest detection and beacon detection.

presence will be simplified as a simple “ping” script. Monitor is much more sophisticated and robust already, and - in my experience - is substantially faster. And causes substantially less 2.4GHz interference.

Note that monitor already performs the same function as presence by using the -r flag.

Mmmm I only installed presence as it seemed to fit my use case better (detect known devices via MAC address and report present or not) or you saying I can replace presence with monitor and get the same result (I believe it 0 or 100% confidence with monitor)?

Yes, that’s exactly right. Monitor detects (1) generic BTLE beacons (2) ibeacons, and (3) known devices via mac address, reporting confidence of presence.

Monitor can be set to binary confidence (i.e., 0 or 100) but that is not the default. By default monitor will decrement the confidence value of known devices, just like presence.

Beacons (both generic and ibeacons) are only 0 or 100 confidence for the time being.

Interesting… what would the migration look like?

The most important notes to keep are your known addresses. Variable names in the config file are also slightly different because the behavior of monitor is inherently different.

Instructions for installation are on the github page. Beacon detection is still an active area of development but known devices works very well.

Thanks I’ll look into moving over.

When you say config file are you referring to the Home Assistant configuration.yaml (or wherever you place your integration config)?

I’m not having any luck with monitor finding my miband2.

Unfortunately, I don’t have one to test. Specified address or generic beacon?

specified address.

Running monitor manually or via systemctl? Per the instructions, run manually to be sure that any installation errors/issues are corrected…

monitor instructions don’t seem to include step 12/13 to configure the service like they show for presence is this right?

I’ve done both. No errors listed and all requirements installed.

Configuration for many options occurs via the command line. The behavior_preferences file is what is needed to be modified.

What do you see in the log when monitor attempts to scan for your device? (i.e., running manually)

I was referring to starting the service at boot. Am I missing something?

The systemctl script is handled by monitor itself. Run manually from the command line and you’ll see the option if you haven’t added a systemctl script already yourself.


0.1.570 12:06:12 pm [CMD-RAND]  48:DD:B7:64:C4:48 ADV_NONCONN_IND -95 dBm
0.1.570 12:06:12 pm [CMD-INFO]  **** Rejected group scan. No devices in desired state. ****
0.1.570 12:06:21 pm location/owner/kitchen/fc:4d:51:f6:39:9d
{
        retain: false
        version : 0.1.570
        confidence : 0
        name : KylerMiBand
        timestamp : Wed Sep 05 2018 12:06:21 GMT-0600 (MDT)
        manufacturer : Unknown
        type : KNOWN_MAC
}
0.1.570 12:06:21 pm location/scan/depart
0.1.570 12:06:22 pm [CMD-NAME]  fc:4d:51:f6:39:9d KylerMiBand  Unknown

Thanks for clarification. Reviewing install instructions while on my commute so… :grinning:

Thanks, the updated script is working again with my phone, issues with the mi band persist;

0.1.570 07:18:37 pm location/scan/departure/start
0.1.570 07:18:37 pm [CMD-INFO] **** Started departure scan. [x4 max rep] ****
0.1.570 07:18:38 pm SCANNING FOR 00:00:00:00:5A:AD
0.1.570 07:18:38 pm [CMD-SCAN] (No. 1) 00:00:00:00:5A:AD departure?
0.1.570 07:18:40 pm location/owner/6C_Pi_Zero/00:00:00:00:5A:AD
{
retain: false
version : 0.1.570
confidence : 100
name : Oneplus One
timestamp : Wed Sep 05 2018 19:18:39 GMT+0100 (BST)
manufacturer : XEROX CORPORATION
type : KNOWN_MAC
}
0.1.570 07:18:41 pm [CMD-INFO] **** Completed departure scan. ****
0.1.570 07:18:43 pm location/scan/departure/end
0.1.570 07:18:45 pm [CMD-RSSI] C8:0F:10:69:44:6B Mi Band 1s PUBL RSSI: -89 dBm (Slow/No Motion)
0.1.570 07:18:45 pm location/owner/6C_Pi_Zero/C8:0F:10:69:44:6B
{
retain: false
version : 0.1.570
confidence : 100
name : Mi Band 1s
timestamp : Wed Sep 05 2018 19:18:45 GMT+0100 (BST)
manufacturer : Unknown
type : GENERIC_BEACON
rssi : -89
}
0.1.570 07:18:45 pm [CMD-PUBL] C8:0F:10:69:44:6B SCAN_RSP Mi Band 1s Unknown -89 dBm
0.1.570 07:18:48 pm [CMD-RSSI] C8:0F:10:69:44:6B Mi Band 1s PUBL RSSI: -95 dBm (Slow/No Motion)
0.1.570 07:18:48 pm location/owner/6C_Pi_Zero/C8:0F:10:69:44:6B
{
retain: false
version : 0.1.570
confidence : 100
name : Mi Band 1s
timestamp : Wed Sep 05 2018 19:18:48 GMT+0100 (BST)
manufacturer : Unknown
type : GENERIC_BEACON
rssi : -95
}
0.1.570 07:18:48 pm [CMD-PUBL] C8:0F:10:69:44:6B ADV_IND Mi Band 1s Unknown -95 dBm
0.1.570 07:19:02 pm location/scan/arrival/start
0.1.570 07:19:02 pm [CMD-INFO] **** Started arrival scan. [x2 max rep] ****
0.1.570 07:19:03 pm SCANNING FOR C8:0F:10:69:44:6B
0.1.570 07:19:03 pm [CMD-SCAN] (No. 1) C8:0F:10:69:44:6B arrival?
0.1.570 07:19:11 pm SCANNING FOR C8:0F:10:69:44:6B
0.1.570 07:19:11 pm [CMD-SCAN] (No. 2) C8:0F:10:69:44:6B arrival?
0.1.570 07:19:19 pm [CMD-INFO] **** Completed arrival scan. ****
0.1.570 07:19:21 pm location/owner/6C_Pi_Zero/C8:0F:10:69:44:6B
{
retain: false
version : 0.1.570
confidence : 0
name : Mi Band 1s
timestamp : Wed Sep 05 2018 19:19:21 GMT+0100 (BST)
manufacturer : Unknown
type : KNOWN_MAC
}
0.1.570 07:19:21 pm [CMD-NAME] C8:0F:10:69:44:6B Mi Band 1s Unknown
0.1.570 07:19:21 pm location/scan/arrival/end

It looks like it finds it alright when it reports it as “type : GENERIC_BEACON” but when the arrival scan runs it reports it as “type : KNOWN_MAC” and “confidence : 0”, it is therefore constantly flipping from 0 - 100.

Yes, I agree that’s what it looks like. Since this is the case, I’d consider it a generic beacon and remove it from your known devices file.

Curious - if you run the command hcitool name C8:0F:10:69:44:6B in your shell, what happens?