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

" When I run sudo bash monitor.sh -b none of my iOS devices are showing up in the scans, though several items say they are are apple devices. I ran the following using my iPad MAC address
hcitool name 88:AE:07:79:FF:A0
And it returned iPad . I suppose I should add my devices to known devices, but why isn’t this and my other devices showing up with the monitor command? Where are the MAC addresses that are showing up in -b coming from?"

Hey, did you ever solve this? I think I’m running into the same issue. name call returns the name, but no iOS devices are showing up in the scan/on MQTT. I can get the neighbor’s AppleTV and Samsung TV, but not my iphone.

Thanks!

The usual way is to follow the instructions GitHub - andrewjfreyer/monitor: Distributed advertisement-based BTLE presence detection reported via mqtt

The usual way is to follow the instructions GitHub - andrewjfreyer/monitor: Distributed advertisement-based BTLE presence detection reported via mqtt

yeah…I’m pretty new to this whole thing too and I can attest to what lweberru is saying. The instructions are great, up to a point and then it’s pretty confusing and assumes a lot of knowledge on the part of the user. Not that this kind of thing isn’t specifically for a very particular audience who generally know these things…

But yeah. just “read the instructions” isn’t helpful in this case.

1 Like

Yes but pointing to the instructions (as I did) is helpful. There is a section there in the link I gave that is clearly labelled “Home Assistant Example”. If that isn’t understood or is unclear, ask away, but don’t come here without having read and attempting to understand.

I read the instructions. Before I addressed here, that I have no clue, about how to continue. As Fart mentioned. The docu and the examples assumes a lot of knowedge on the part of the user. So lets assume the following:

  • I have the monitor.sh running as service - log says all is fine. The mqtt integration also works (hopefully), but I dont know how to test even that. So How can I test it.
  • I want to detect at least one single device if it is “near” the PI, or want to know the distance or whatever it can tell me.

So an explanation what to do next is missing for me.

Lets take the given example there:

- platform: mqtt
  state_topic: 'monitor/first floor/alias'
  value_template: '{{ value_json.confidence }}'
  unit_of_measurement: '%'
  name: 'First Floor'

Which parts of the “state_topic” is a fixed string, which is a variable I have to replace which something different?
Where do I define the name of the location - here “First Floor”. I think I have to tell it the pi with the running monitor.sh?

I hope its now clearer, why I dont know how to proceed

1 Like

If it helps, this is what I did: Bluetooth LE Tracker issues

Hi John. Yes this helps me a lot. The feature “PREF_DEVICE_TRACKER_REPORT=true”, does this prevent the monitor from pushing these % values or is this just an additional feature to get a clear home/not home message? Also unclear is the need to use this known_static_addresses or what happens if I let it empty

I left known_static_addresses empty because when I inputted my Tile’s MAC in there it would scan my Tile twice and give a home message followed by a not_home message, thus rendering it useless. Left empty, it works fine, HA knows what MACs to look for via what I wrote in configuration.yaml

And yes, if you want percentages my setup might not be what you’re looking for, via PREF_DEVICE_TRACKER_REPORT I forced it to give me an “all or nothing” message…in any case, I am not sold on whether the percentages given are good enough for room detection (at least not without multiple Pis) and for “being home” detection a simple yes/no should suffice, no?

This setup + a Tile on my keychain means that I get recognized as Home as soon as I walk within BLE range (usually the front door of my apartment building, since I live on the ground floor) and get set to Not Home a few hundred meters down the street (which actually is very handy to not be set as Not Home when simply taking out the trash).

Hi,

I got the system runnning now. But all I get is always a 100% confidence or a 0%. The pi is in my living room, target was to detect if someone is inside the living room, but whenever someone is inside the house (at nearly all locations there) the confidence is 100%. If I go away fast far enough, the value switches to 0%. So my problem is that there is no real benefit using the tool, because it is just a home/not_home detection. What I need is a real value of the signal strength to decide how near some device is.

Is there a way to make the system having values between 0 and 100% to give me more details about the signal strength or something like this? Even I would install several PIs all would just say 100% whenever someone is in the house :frowning:

Looking inside the logs I see that there is a “dBm” value, but that value seems to be ignored…

I am also still a bit unsure which switches to use as parameters for monitor.sh

If you pair the Pi with the Bluetooth device, it will be able to give you RSSI values which you can then use to do what you want.

Regards

Ah cool, thank you, will try that.
Do I need to change any settings within monitor.sh to send these values to mqtt?
How can I catch these values within home assistant best (in parallel to the confidence)?
I saw the following inside the mqtt platform documentation. But not sure how to configure it for monitor.sh:

sensor:
  - platform: mqtt
    name: "RSSI"
    state_topic: "home/sensor1/infojson"
    unit_of_measurement: 'dBm'
    value_template: "{{ value_json.RSSI }}"
    availability_topic: "home/sensor1/status"
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes_topic: "home/sensor1/attributes"

If I try the following:

  - platform: mqtt
    state_topic: 'monitor/wohnzimmer/<MAC>'
    value_template: '{{ value_json.rssi }}'
    unit_of_measurement: 'dBm'
    name: 'Mobile RSSI'

I am not getting values (device is paired).

Also tried to have to sensors running on the same state_topic -> also not working.

Hello @lweberru,

I don’t use the sensors in HA for my RSSI, but your example will not work as it just sends a string value. So based on that, this should work:

sensor:
  - platform: mqtt
    name: "RSSI"
    state_topic: "monitor/Living Room/<device>/rssi"
    unit_of_measurement: 'dBm'
    availability_topic: "monitor/Living Room/status"
    payload_available: "online"
    payload_not_available: "offline"

Hope this helps

This cant work, because, the sensor cant know that I want to get the RSSI attribute out of the message…

Apologies made a mistake with the state topic, I have edited it to reflect what I think you should use.

Regards

Still dont think, that this will work, according to the docu, the message should look like that:

topic: monitor/{{name of monitor install}}/{{mac address or ibeacon uuid}}
message: {
    "id":"{{mac address or ibeacon uuid}}",
    "report_delay":"{{delay from first detection to this message in seconds}}",
    "flags":"{{GAP flags}}",
    "movement":"stationary",
    "confidence":"{{ranging from 0-100}}",
    "name":"{{if available}}",
    "power":"{{if available}}",
    "rssi":"{{if available}}",
    "mac":"{{if ibeacon, the current mac address associated with the uuid}}",
    "manufacturer":{{if available}}",
    "type":"{{GENERIC_BEACON_PUBLIC or APPLE_IBEACON}},
    "retained":"{{message retained?}}",
    "timestamp":"{{formatted date at which message is sent}}",
    "version":"{{monitor version}}"
 }

so the topic stays in the format without the rssi ending and rssi is just part of the message as it is confidence (which works). So in my oppinion there is something else wrong.

I just registered an mqtt listener to one of my devices with the format:

monitor/{{name of monitor install}}/{{mac address or ibeacon uuid}}

and I am getting this:

{  
   "id":"10:8E:E0:14:2D:8D",
   "confidence":"100",
   "name":"Lukas_Uhr",
   "manufacturer":"Samsung Electronics CoLtd",
   "type":"KNOWN_MAC",
   "retained":"false",
   "timestamp":"Mi Jul 10 2019 16:26:01 GMT+0200 (CEST)",
   "version":"0.2.197"
}

Also registered:

monitor/{{name of monitor install}}/{{mac address or ibeacon uuid}}/rssi

and all I get is -99

So somehow your idea “works” without beeing documented. But also provides no valid data.

So the monitor.sh is the issue. It just does not send the rssi data. So home assistant has no chance to read it.

Which parameters are needed within monitor.sh, to get the things up and running?

The rssi should work, without any special flags.

Yes sometimes it just sends -99, but after a while it will send the right value. Just ensure it is paired to the device.

U can send multiple arrival scans to it without restarting it, and see if the rssi changes.

For me to update time, I just send it arrival scans instructions, as there is no special topic to activate that yet.

Regards

Yes I found it in the docu, that rssi is done as you explained. But anyway I dont get any rssi info about my 2 devices. I think this is probably related to the devices. One is an samsung galaxy S7 and the other a samsung galaxy watch. Probably only IOS can act as an ibeacon or so - no idea.
This all looks like this all dont work as expected

Ok unfortunately I got no experience with non Apple products so cannot advise on that.

Regards

Hi Guys,
I’ve just ordered a rpi zero and will be going down the rabbit hole with this over the weekend.

i currently run HA on a RPI 3B and having major issues with the bluetooth tracker becoming unresponsive, I rely heavily on bluetooth as a tracking device.

this will be the first time I’ll be using MQTT

could someone offer any NOOB-like tips to ensure I get this running successfully.

first question
how offend by default does this scan to ensure I’m still at home?