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

Yes, beacons emit random advertisements.

How can you integrate this confidence value with other device_tracker sensors to show “Home” or “Away” ?

EDIT: Thanks @robwolff3 !

Take a look at my config:

8 Likes

Great job Andrew! loving the script (apart from the bash thing :wink: ).
I’ve created a docker image with it: https://hub.docker.com/r/kabturek/monitor.sh/
I tested it on my server (old laptop) with a BTLE dongle and it works great - would be great if someone could test it on raspberry pi as this is a common use case too.

P.S. I’m still thinking that porting the code to ESP32 (built in BT! and wifi) could be a good idea (cost, size and energy saving)

4 Likes

I’m getting this “Can’t init device hci0: Connection timed out (110)” error as well. Running monitor v. 0.1.675 on Raspberry Pi Zero Ws. Nothing else running on these. Starting monitor.sh with the -r flag. Seems to work well for 1-3 days, the RPis then stop reporting presence to the MQTT broker and the hci0 error message appears.

1 Like

If you’re using the -r flag, presence is a more appropriate script than monitor.

To avoid confusion, I’m planning to remove periodic scanning from monitor altogether.

Nice! Thanks!

Hi,
first i must say this project is really interesting and i think there are many hours of work in it.
I would like to know if its possible to query a bluetooth device name by bluetooth mac address on an arduino or esp32 as they are cheaper.
How does the “hcitool name MAC” command work, i cannot find anything like that in the bluetooth specification of the ESP-IDF for ESP32. Is it based on classic bluetooth or bluetooth low energy?
Can someone give me a hint on how to do it with an ESP32?

1 Like

A name request is part of the Bluetooth protocol as far back as 2.0 or earlier I think. Look up hci commands and, specifically, command 0019.

From my limited research esp32 has problems accessing wifi and bt in the same time.

As for simple polling: https://github.com/1technophile/OpenMQTTGateway/wiki/ESP8266-BT-Module

OK. Didn’t know that. Thanks.

Can I expect the hci0 error message to go away if I switch to presence, or is that not related?

Hi,

I’m having a problem where I can be at home but monitor thinks I’m away.

I have two RPI running monitor with -tdr, triggered by my door. The problem seems to be when the door opens and I’ out with the trash. Then monitor never sees me coming inside again, on either of the RPi.

Other settings is default with only two iPhone in known devices.

what version are you running? Also what settings ? is it just -tdr ?

One of my pi zero’s started throwing this.
Correcting HCI error: Invalid device: Network is down

It would only come back if I rebooted the pi.

Hi @MarkR

I have a Galaxy S9+ and think I have the same problem as you with regards to advertising.

What is the norm for advertising? Do I have to turn the bluetooth on for it to be able to advertise as a beacon? or does it do it automatically without the bluethooth actually being turned on?

Thanks.

For noobs like me.

At step 9 I had to

sudo apt-get install bluez-hcidump
sudo apt-get install bc

After step 12 I had to

sudo systemctl start monitor.service

All working now and a great project!

1 Like

it says on here that if BT is on and has been paired to a BT speaker as an example, then advertising is turned “on” but even with a slightly older Samsung it just doesn’t advertise.

So that means after pairing and BT on your phone being off it would be able to advertise? And the speaker would see the phone whilst the BT of the phone being off?

Bluetooth needs to be on to advertise random packets but it doesnt have to be in discovery mode.

Hmmm what’s happening here I’m using Mosquitto Addon 4 for Hassio 81.6?

[INFO] found monitor on local database
1541780098: New client connected from 192.168.0.69 as mosqpub/7425-kitchen (c1, k60, u'monitor').
1541780098: ACL denying access to client with dangerous client id "mosqpub/7425-kitchen"
1541780098: Client mosqpub/7425-kitchen disconnected.
# ---------------------------
#
# MOSQUITTO PREFERENCES
#
# ---------------------------

# IP ADDRESS OF MQTT BROKER
mqtt_address=hassio.local

# MQTT BROKER USERNAME (OR BLANK FOR NONE)
mqtt_user=monitor

# MQTT BROKER PASSWORD (OR BLANK FOR NONE)
mqtt_password=<password>

# MQTT PUBLISH TOPIC ROOT
mqtt_topicpath=monitor

# PUBLISHER IDENTITY
mqtt_publisher_identity='kitchen'

# MQTT PORT
mqtt_port='1883'

# MQTT CERTIFICATE FILE
mqtt_certificate_path=''