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

I’m having mosquito issues with some of my mqtt devices and it’s difficult to debug because monitor connects/disconnects rapidly many many times per minute with a different client I’d every time. Is there any way to reduce or stop this behaviour without impacting the effectiveness of the script?

Thanks

Just migrate to room-assistant, much more reliable for my case.

Try downloading mqtt explorer it’s a stand alone program not part of HA. You’ll will be able to sort and isolate topics.

Were you able to find the mac address of the tile mate?

I used this app to find it : https://play.google.com/store/apps/details?id=com.bluetoothFinder&hl=en_US&gl=US
I went outside with my phone and tile next to each other so it would not scan a lot of bt devices. and it found a few and tile was the one closest to me and with the best signal…

but its always shown as not_home for for me. I don’t know why.

I’ve found this post to scan for beacons which should include the tile mate. I have not purchase the tile mate yet and wanted to know if it will work for just presence detection when at home and not if outside. A few post down happybubbles suggest to forget the tile from the mobile app if you don’t use the app at all.

i added -b to start script and i now see my tile :


but still not_home

You have to add the mac to known_static_beacons, you might also have to add ‘random’ to the list as well.

@ Mikefila thx for answer. i added it like this in known_static_beacons:
00:00:00:00:00:00 Nickname
But i dont understand where i should add random? :slight_smile:
thx

I’m not completely sure but it’s either

00:00:00:00:00:00 Nickname
random

or with the quotes

00:00:00:00:00:00 Nickname
"random"

ok i will try :slight_smile: thx

“random” made it work! Works really good with my tile. BUT not with my phones. tile updates when it leaves home but phone BT sensor is always home. same on 3 phones in my home.

Do you know why maybe? :slight_smile:

This is how i start monitor: sudo bash monitor.sh -x -b -tdr

red= wrong.

Well, the “systemd unit file” is how monitor runs as a service. Do you have some other way of having it run as a service?

How are you telling it to do departure scans?

Thx for answer! :slight_smile:

This is how i start the script from CMD on my windows machine after ssh to RPi2

The first time I started, I wrote like this:
sudo bash monitor.sh -x -b -tdr -u

and now like this:
sudo bash monitor.sh

automation:

- initial_state: 'on'
  alias: 'Front door open/closed BT helper atm'
  trigger:
  - platform: state
    entity_id: binary_sensor.pi3_front_door_sensor
    to: 'off'
  action:
  - service: script.scan_bt_depart
  - service: script.scan_bt_arrive

im going to split them up to two automatins like your guide. one when i unlock door from inside (depart) and the other when unlocking with tag/code from outside.

EDIT
now i see i have wrong entity in that automation :'D

changing to this for now:

- initial_state: 'on'
  alias: 'Front door open/closed BT helper atm'
  trigger:
  - platform: state
    entity_id: lock.dorrlaset
    to: 'unlocked'
  action:
  - service: script.scan_bt_depart
  - service: script.scan_bt_arrive

but the tile did still work ?

Well, that sudo command runs it until the session ends. You really need a service file so that it auto starts :wink:

This is just a short version, you should really read up on how to work on ubuntu-like systems that use systemd. :wink:

monitor.sh is the file, that does the work. If you setup a monitor.service file, this is the one that is needed to autostart the monitor.sh file, eg. after a restart. This service file is for the OS to know, how to handle this “autostart”. As this service is controlled by the OS, you can enable, disable, start or stop this service.

So after setting up monitor.sh you have to make it autostart. Setup the file monitor.service and check the contents. After that enable the service and you are good to go. :+1:

1 Like

OK thank you! :slight_smile: Now it works, when i reboot my rpi and type “sudo systemctl status monitor.service” it is up and running =)

i added it like this in known_static_beacons:

You mentioned you added the mac in known_static_beacons file. I don’t have such as file. Only these.

known_beacon_addresses
known_static_addresses

add tile in: known_beacon_addresses
my file looks like this

# ---------------------------
#
# BEACON MAC ADDRESS LIST; REQUIRES NAME
#
# 	Format: 00:00:00:00:00:00 Nickname #comments
# ---------------------------
F2:A3:TT:98:65:95 tile one
"random"

Ok. My other problem is that I cannot find the mac address. Tried several different free bluetooth ios app, and it doesn’t provide mac address.

monitor doesn’t see the Tile either. I use this cmd.

sudo bash monitor.sh -trd -x -b