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

@andrewjfreyer I have a bug with this new version unless im doing something wrong

my MQTT topics arent publishing correctly

location/bedroom1/3ff:ff:ff:ff:ff:ff

if my mac address is ff:ff:ff:ff:ff:ff I am getting a 3 in front of all my topics. is this correct ?

furthermore did you disable name scanning? The topics that I am currently seeing are not displaying the name of my devices
(FYI my mac is not ff:ff:ff:ff:ff:ff I am just using this for an example)

{“id”:“3ff:ff:ff:ff:ff:ff “, “retained”:“false”, “version”:“0.1.661”, “confidence”:“25”,“name”:“Undiscoverable Device Name”,“timestamp”:“Tue Sep 25 2018 22:01:52 GMT+0000 (UTC)”,“manufacturer”:“Unknown”,“type”:“KNOWN_MAC”,“rssi”:””}

also it seems that my confidence never reaches 100. it seems that the confidence goes to 50. It never reaches anything above 50.

I basically did a GIT PULL and sudo bash monitor.sh -u -d

1 Like

I’m seeing the same. Just raised an issue on Github. Random 3 appearing.

1 Like

are your confidence levels strange and the names never appearing. my confidence never reaches 100

1 Like

Don’t really know as I installed it for the first time tonight.

{
	"id": "3c0:ee:fb:6c:0e:f2",
	"retained": "false",
	"version": "0.1.661",
	"confidence": "12",
	"name": "Undiscoverable Device Name",
	"timestamp": "Tue Sep 25 2018 23:15:17 GMT+0100 (BST)",
	"manufacturer": "Unknown",
	"type": "KNOWN_MAC",
	"rssi": ""
}

@andrewjfreyer might I suggest you start a dev branch on GitHub or else a Stable branch where you release tested versions and those who want to, can use, what might be, a little less stable repo :smile:.

2 Likes

@benjimatt I have found the error. check out

for the fix.

[edit] Only happens with mac addresses with a character in the first 2 digits.

2 Likes

:clap::clap::clap: thanks man that seems to have done it.
Looks like its all working correctly again

1 Like

Sorry, stupid bug. Should be fixed in the most recent push.

FYI for anyone that wants to use the status feature to know if monitor is Offline or Online you can add this to your sensor section

- platform: mqtt
  state_topic: 'location/bedroom/status'
  name: 'Bedroom Bluetooth Status'

shows either offline or online

3 Likes

alright, alright, alright. Stop calling out my laziness! haha :slight_smile:

Sorry y’all … I guess there are far too many people using this now for me to use my personal github as a testing platform. A beta branch has now been created. If you’d like to be on the bleeding edge, change your cloned repo to the beta branch by:

git fetch
git checkout beta

I’ll still push updates to the master frequently, but I’ve finally switched over all my nodes and test nodes to the beta channel.

Sorry it took so long…

4 Likes

@benjimatt Thanks for the quick demo!

Another way to use this feature is within the mqtt sensor definition itself:

  - platform: mqtt
    state_topic: 'location/first floor/[MAC ADDRESS]'
    value_template: '{{ value_json.confidence }}'
    unit_of_measurement: '%'
    name: 'Apple Watch - First Floor'
    availability_topic: "location/first floor/status"
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes:
      - id
      - name 
      - rssi
      - version
      - manufacturer
      - type
      - timestamp
      - retained
      - confidence 
2 Likes

@andrewjfreyer if I use -td will each node still send out a depart trigger once confidence falls to zero?

Also I noticed that the -td works pretty well. I can now turn off bluetooth if I wanted to for whatever reason. I noticed that both of my devices are home but the devices still scan for each new advertisement found. I would figure if using -td that once all devices are home there would no longer be a need to do any arrival scans until another depart scan is initiated or until a device has actually departed and is listed as NOT home.

1 Like

Add the r flag too for -trd

Also, td will still allow arrival scans

you currently still have another bug, hate to bother you but it just isnt working correctly.

Currently I have 1 device that the confidence is stuck at 6% on all three Pi’s that I have running. I am only on monitor -td and all of my pi’s .

Im just going to restart it but there is surely an issue with depart.

Edit: below just happen after the restart
[Screenshot_20180926-062547|281x500]

(upload://A0RSYNWk6CDZPRa9occx66yJ2s7.jpeg)

1 Like

Any more info you can share on this?

Is there any info on how you correctly update this component?
Is there any command line sollution?
Or am i suppose to copy / paste the new code from your repo and then restart the pi?

Navigate to the /monitor directory and update via:

git pull

3 Likes

here are the logs for one of my nodes. One device isn’t home and the other is home. But both are showing away. Im currently using -trd. The only thing I can think of is I have my trigger et when the state of my door changes which is technically twice (open and close) but all it does is send out the depart command
02%20PM

-- Logs begin at Wed 2018-09-26 11:45:16 UTC. --
Sep 26 21:21:29 blue2 bash[495]: 0.1.662 09:21:29 pm [CMD-RAND]        43:39:AB:CF:2F:86 ADV_IND -90 dBm
Sep 26 21:21:32 blue2 bash[495]: 0.1.662 09:21:32 pm [CMD-RSSI]        61:2C:58:77:4A:0F Undiscoverable Device Name BEAC RSSI: -102 dBm (Slow/No Motion, changed -11) 
Sep 26 21:21:40 blue2 bash[495]: 0.1.662 09:21:40 pm [CMD-RSSI]        6F:16:2A:6C:AD:60 Undiscoverable Device Name RAND RSSI: -82 dBm (Slow/No Motion, changed -17) 
Sep 26 21:21:53 blue2 bash[495]: 0.1.662 09:21:53 pm [CMD-RAND]        1B:7B:2E:66:6D:F5 ADV_NONCONN_IND -93 dBm
Sep 26 21:21:57 blue2 bash[495]: 0.1.662 09:21:57 pm [CHECK-DEL]        5F:5F:5F:E4:DF:6C expired after 93 (30 bias) seconds RAND_NUM: 20 
Sep 26 21:21:57 blue2 bash[495]: 0.1.662 09:21:57 pm [CHECK-DEL]        5D:37:A2:06:ED:51 expired after 66 (15 bias) seconds RAND_NUM: 19 
Sep 26 21:22:02 blue2 bash[495]: 0.1.662 09:22:02 pm [CMD-RSSI]        71:14:62:F6:DD:32 Undiscoverable Device Name RAND RSSI: -98 dBm (Fast Motion Departing, changed -98) 
Sep 26 21:22:02 blue2 bash[495]: 0.1.662 09:22:02 pm [CMD-RAND]        71:14:62:F6:DD:32 ADV_IND -98 dBm
Sep 26 21:22:04 blue2 bash[495]: 0.1.662 09:22:04 pm [CMD-RSSI]        42:12:1A:36:82:4B Undiscoverable Device Name RAND RSSI: -97 dBm (Fast Motion Departing, changed -97) 
Sep 26 21:22:04 blue2 bash[495]: 0.1.662 09:22:04 pm [CMD-RAND]        42:12:1A:36:82:4B ADV_NONCONN_IND -97 dBm
Sep 26 21:22:10 blue2 bash[495]: 0.1.662 09:22:10 pm [CMD-RSSI]        6F:16:2A:6C:AD:60 Undiscoverable Device Name RAND RSSI: -55 dBm (Moderate Motion Approaching, changed 26) 
Sep 26 21:22:24 blue2 bash[495]: 0.1.662 09:22:24 pm [CMD-RSSI]        7C:B1:37:E1:12:5D Undiscoverable Device Name RAND RSSI: -95 dBm (Fast Motion Departing, changed -95) 
Sep 26 21:22:24 blue2 bash[495]: 0.1.662 09:22:24 pm [CMD-RAND]        7C:B1:37:E1:12:5D ADV_NONCONN_IND -95 dBm
Sep 26 21:22:27 blue2 bash[495]: 0.1.662 09:22:27 pm [CMD-RSSI]        52:46:8C:8E:05:7A Undiscoverable Device Name RAND RSSI: -94 dBm (Fast Motion Departing, changed -94) 
Sep 26 21:22:27 blue2 bash[495]: 0.1.662 09:22:27 pm [CMD-RAND]        52:46:8C:8E:05:7A ADV_NONCONN_IND -94 dBm
Sep 26 21:22:28 blue2 bash[495]: 0.1.662 09:22:28 pm [CMD-RSSI]        4F:D1:1E:A1:6C:08 Undiscoverable Device Name RAND RSSI: -84 dBm (Fast Motion Departing, changed -84) 
Sep 26 21:22:28 blue2 bash[495]: 0.1.662 09:22:28 pm [CMD-RAND]        4F:D1:1E:A1:6C:08 ADV_NONCONN_IND -84 dBm
Sep 26 21:22:32 blue2 bash[495]: 0.1.662 09:22:32 pm [CHECK-DEL]        71:84:9E:3F:EF:86 expired after 64 (0 bias) seconds RAND_NUM: 23 
Sep 26 21:22:32 blue2 bash[495]: 0.1.662 09:22:32 pm [CHECK-DEL]        51:9B:BE:1A:AC:8E expired after 67 (15 bias) seconds RAND_NUM: 22 
Sep 26 21:22:32 blue2 bash[495]: 0.1.662 09:22:32 pm [CHECK-DEL]        4A:AC:05:84:3D:17 expired after 74 (0 bias) seconds RAND_NUM: 21 
Sep 26 21:22:36 blue2 bash[495]: 0.1.662 09:22:36 pm [CMD-RSSI]        72:9B:7F:73:5F:58 Undiscoverable Device Name BEAC RSSI: -95 dBm (Fast Motion Departing, changed -95) 
Sep 26 21:22:56 blue2 bash[495]: 0.1.662 09:22:56 pm [CMD-RSSI]        2C:41:A1:A2:19:EE Undiscoverable Device Name PUBL RSSI: -93 dBm (Fast Motion Departing, changed -93) 
Sep 26 21:23:01 blue2 bash[495]: 0.1.662 09:23:01 pm [CMD-RSSI]        5A:D9:0E:8F:9A:8B Undiscoverable Device Name RAND RSSI: -100 dBm (Fast Motion Departing, changed -100) 
Sep 26 21:23:01 blue2 bash[495]: 0.1.662 09:23:01 pm [CMD-RAND]        5A:D9:0E:8F:9A:8B ADV_IND -100 dBm
Sep 26 21:23:05 blue2 bash[495]: 0.1.662 09:23:05 pm [CMD-RAND]        71:14:62:F6:DD:32 ADV_IND -99 dBm
Sep 26 21:23:06 blue2 bash[495]: 0.1.662 09:23:06 pm [CMD-RAND]        42:12:1A:36:82:4B ADV_NONCONN_IND -98 dBm
Sep 26 21:23:07 blue2 bash[495]: 0.1.662 09:23:06 pm [CMD-RSSI]        50:CE:81:6D:7E:52 Undiscoverable Device Name RAND RSSI: -87 dBm (Fast Motion Departing, changed -87) 
Sep 26 21:23:07 blue2 bash[495]: 0.1.662 09:23:07 pm [CMD-RAND]        50:CE:81:6D:7E:52 ADV_NONCONN_IND -87 dBm
Sep 26 21:23:07 blue2 bash[495]: 0.1.662 09:23:07 pm [CHECK-DEL]        43:39:AB:CF:2F:86 expired after 79 (0 bias) seconds RAND_NUM: 22 
Sep 26 21:23:07 blue2 bash[495]: 0.1.662 09:23:07 pm [CHECK-DEL]        45:25:D5:B1:03:45 expired after 77 (15 bias) seconds RAND_NUM: 21 
Sep 26 21:23:15 blue2 bash[495]: 0.1.662 09:23:15 pm [CMD-RSSI]        7E:67:0B:BF:5B:60 Undiscoverable Device Name RAND RSSI: -82 dBm (Fast Motion Departing, changed -82) 
Sep 26 21:23:15 blue2 bash[495]: 0.1.662 09:23:15 pm [CMD-RAND]        7E:67:0B:BF:5B:60 ADV_NONCONN_IND -82 dBm
Sep 26 21:23:36 blue2 bash[495]: 0.1.662 09:23:36 pm [CMD-RAND]        6D:54:E8:93:C8:0E ADV_NONCONN_IND -103 dBm
Sep 26 21:23:42 blue2 bash[495]: 0.1.662 09:23:42 pm [CHECK-DEL]        64:2F:8A:97:45:CF expired after 109 (30 bias) seconds RAND_NUM: 22 
Sep 26 21:23:42 blue2 bash[495]: 0.1.662 09:23:42 pm [CHECK-DEL]        41:EA:7F:00:30:63 expired after 49 (0 bias) seconds RAND_NUM: 21 
Sep 26 21:23:42 blue2 bash[495]: 0.1.662 09:23:42 pm [CHECK-DEL]        4F:D1:1E:A1:6C:08 expired after 73 (0 bias) seconds RAND_NUM: 20 
Sep 26 21:24:01 blue2 bash[495]: 0.1.662 09:24:01 pm [CMD-RAND]        1E:20:35:F5:69:F4 ADV_NONCONN_IND -92 dBm
Sep 26 21:24:05 blue2 bash[495]: 0.1.662 09:24:05 pm [CMD-RSSI]        70:4D:B3:19:84:B0 Undiscoverable Device Name RAND RSSI: -86 dBm (Fast Motion Departing, changed -86) 
Sep 26 21:24:05 blue2 bash[495]: 0.1.662 09:24:05 pm [CMD-RAND]        70:4D:B3:19:84:B0 ADV_NONCONN_IND -86 dBm
Sep 26 21:24:11 blue2 bash[495]: 0.1.662 09:24:11 pm [CMD-RAND]        42:12:1A:36:82:4B ADV_NONCONN_IND -98 dBm
Sep 26 21:24:17 blue2 bash[495]: 0.1.662 09:24:17 pm [CHECK-DEL]        50:CE:81:6D:7E:52 expired after 70 (0 bias) seconds RAND_NUM: 20 
Sep 26 21:24:17 blue2 bash[495]: 0.1.662 09:24:17 pm [CHECK-DEL]        71:14:62:F6:DD:32 expired after 73 (0 bias) seconds RAND_NUM: 19 
Sep 26 21:24:18 blue2 bash[495]: 0.1.662 09:24:18 pm [CHECK-DEL]        5A:D9:0E:8F:9A:8B expired after 76 (0 bias) seconds RAND_NUM: 18 
Sep 26 21:24:22 blue2 bash[495]: 0.1.662 09:24:22 pm [CHECK-DEL]        61:2C:58:77:4A:0F expired after 167 (0 bias) seconds 
Sep 26 21:24:26 blue2 bash[495]: 0.1.662 09:24:26 pm [CMD-RSSI]        6F:16:2A:6C:AD:60 Undiscoverable Device Name RAND RSSI: -78 dBm (Moderate Motion Departing, changed -23) 
Sep 26 21:24:44 blue2 bash[495]: 0.1.662 09:24:44 pm [CMD-RAND]        6B:1A:42:17:D8:2C ADV_NONCONN_IND -95 dBm
Sep 26 21:24:49 blue2 bash[495]: 0.1.662 09:24:49 pm [CMD-RSSI]        6F:16:2A:6C:AD:60 Undiscoverable Device Name RAND RSSI: -55 dBm (Moderate Motion Approaching, changed 24) 
Sep 26 21:24:52 blue2 bash[495]: 0.1.662 09:24:52 pm [CHECK-DEL]        6D:54:E8:93:C8:0E expired after 76 (15 bias) seconds RAND_NUM: 17 
Sep 26 21:24:52 blue2 bash[495]: 0.1.662 09:24:52 pm [CHECK-DEL]        6A:F4:DB:69:D2:7E expired after 53 (0 bias) seconds RAND_NUM: 16
1 Like

Unfortunately, this is only about two minutes of logs and it doesn’t appear that any known device or scan occurred during this window. It seems like the final ‘0’ confidence report isn’t being made. I’ll see if I can repeat this behavior.

I think I see whats partially happening. I went back to default settings

this is how confidence is dropping (fake mac address btw)

location/bedroom/ff:ff:ff:ff:ff:ff
“confidence”:“50”
location/bedroom/ff:ff:ff:ff:ff:ff
“confidence”:“25”
location/bedroom/ff:ff:ff:ff:ff:ff
“confidence”:“12”
location/bedroom/ff:ff:ff:ff:ff:ff
“confidence”:“6”
location/bedroom/1ff:ff:ff:ff:ff:ff
“confidence”:“0”

notice it is adding the 1 at confidence 0 for some reason.

1 Like