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

Just about any phone with bluetooth is probably the best option, in my view. Why are you hoping to avoid pinging? 2.4GHz interference? Monitor does not scan very frequently at all. Presuming default settings, it only scans when a random advertisement from a device not previously seen is received. In the worst case scenario (i.e., you live in a major city apartment complex with many neighbors and many bluetooth devices) monitor will scan only as frequently as presence. If you are in a single family home without a ton of bluetooth devices, I think you’ll be pleasantly surprised with monitor’s performance using just phones.

I’d strongly recommend considering scanning for her phone. Else, monitor should be able to detect most beacons just fine. I’ve used cheap ones I found on gear best (use a one-time use credit card there… I’ve had some identity issues after buying from them). Others use NUTs, others use Tile.

Hi Andrew, thanks so much for your response.

I was hoping to use a beacon as my wife often goes out without her phone … but never leaves home without her house keys! :slight_smile: :slight_smile:
I’ll see if I can grab some cheap beacons to test with. I wondered if some performed better than others with battery life etc.

I’ve been VERY impressed with Monitor.

That is completely opposite of my wife, haha. NEVER without her phone. I’ve used BlueCats iBeacons with success, but the batteries drain after about 6mo. These are the ones that I bought from GearBest (I’ll repeat my warning to use a single-use credit card number on this site). Does your wife have a FitBit or other fitness band? Anything else that she uses that has bluetooth hardware?

Thanks for the kind words on monitor - really happy it’s working out for so many people!

2 Likes

@andrewjfreyer am I correct in thinking that if I start the script once with flags set all subsequent starts will run the script with those flags by default? e.g. on boot.

Also I see yourself and a few others in this thread mentioning they force a scan e.g. when a door opens how do I achieve this?

1 Like

@andrewjfreyer I have monitor working quite well, thank you very much for the effort and the unbelievable support you offer here.

I have a question about arrival/depart scan: I have a xiaomi door sensor to the only outside door of our apartment.
It can only tell if the door is open or closed, I can’t think of a way of using it to tell if a state change means an arrival or a departure.
Can I still use it to trigger an mqtt arrive or depart message? Which should I prefer?

1 Like

If you run the script manually specifying whichever flags you want along with -u it will update the start script to use those flags on boot.

2 Likes

@cain is correct. use the -u flag to update the boot script.

You do not need to do anything special to respond to MQTT triggers; the script responds to arrive and depart triggers by default. I recommend triggering a depart scan based on activity at an exterior door after a delay of 10 to 15 seconds. This is because it is much easier to detect arrival of a new device then it is to detect departure of an existing device. By triggering a departure scan based on an exterior door, we can dramatically speed up the time it takes to detect a departure of a known device.

See my comment immediately above this one. I strongly recommend to trigger a depart scan based on activity at that door, posted after a 10 to 15 second delay. I use a 10 second delay in my house. No special flags are needed.

Perhaps I’m missing something uber obvious…but is there any way to use monitor absolutely vanilla BUT, somehow get it to report status of all tracked devices at (say) a 15 minute interval? Basically I am concerned that if HA somehow missed an MQTT message it could be a day or more before the state got corrected. Whereas if the script published what it knows every 15 minutes…
This reporting of status could be requested by an MQTT message or pushed from Monitor itself as far as I’m concerned. Sorry if I’m missing something obvious.
Also, I’m not requesting how to do a 15 minute SCAN interval but a 15 minute reporting of STATUS update. :slight_smile: :slight_smile:

Yes, there is a way! Use the -e flag to periodically report the bluetooth environment noticed by the node. This includes an array of known devices and their present state.

1 Like

Thanks Andrew - I’m trying to update monitor to use this -e flag, so I stopped both the script AND the service, and when I try to restart it I get a lot of

monitor/monitor.sh: line 112: : No such file or directory
monitor/monitor.sh: line 476: log_listener: command not found
monitor/monitor.sh: line 477: btle_scanner: command not found
monitor/monitor.sh: line 478: btle_listener: command not found
monitor/monitor.sh: line 480: periodic_trigger: command not found
monitor/monitor.sh: line 479: mqtt_listener: command not found
monitor/monitor.sh: line 481: refresh_databases: command not found

No rush to reply, I have a feeling it will still work, just wondering if I should be concerned about the errors if I can just ignore 'em!

I’ve bought the beacons/ibeacons you recommended here:

and I’m not sure if I should use -b or -g. Will experiment! With default no flags, monitor “finds” the itag but then swiftly decides it’s gone again. Thanks again! :slight_smile:

EDIT: -g seems to have done the trick. The iTag seems to fluctuate wildly, 96%, 85%, 100% etc etc (something my iPhone never does). Interesting.

Hello,

Small scale domoticz user here currently using GPS-location for geofence, but since the phone sometimes forgets to report i was looking for something better…

Found this and finally I had a reason both to try Home Assistant and buy a couple of rpi, great! :smiley:

Been using presence successfully for a couple of weeks, but since I read about interference I have a few occations of bad response of my wifi that I contribute to that. Today I therefore switched to Monitor. So far everything looks great!

I have two suggestions for improvement.

  1. Add option in mqtt_preferences to send nickname instead of mac address. Mac adress is really only of interest when setting things up in monitor.
  2. I have two pizerow running, one in each end of the house. For only the house I think one would be enough but I wanted to make sure it covered my small yards in both ends of the house and add some extra redundancy. I really don’t care which pi catches the signal after the first debug-session and I would like not to scan if not needed. Would it be possible to share the information on detected devices through mqtt so that one pi does not scan for a device that is detected by another? The messages are already there so it should really “just” be to set up new messages to listen to in mqtt_preferences and then add devices with 100 confidence to an ignore-list.

Had the script been in python I would have tried to implement it myself, might look into it if you don’t have time but both bash and git take some time to get to know, and time is not on my side at the moment…

Thanks a lot for the good work! Great implementation and a fantastic attitude towards other users!

1 Like

Thanks!

Responses:

  1. Yes, I can add an option for topic aliases. This would probably help a number of users. Good idea!

  2. This is already an option! :slight_smile: I suggest that you use the -t flag with your ‘remote’ pi nodes. This means that these notes will only scan when they are triggered via mqtt to scan. For example, in my house I have three nodes. A “main” node on the first floor, and two “triggered” nodes on the second and third. There is no scanning on the second/third floor unless and until the “main” node determines that one of our phones/beacons has left.

These are important errors, and I’d be very surprised monitor worked after logging these errors. First, make sure to update the script. Second, make sure that the /support directory created during the git pull operation is actually present.

Did you end up creating a new topic or is this one still where its all at?

Haven’t yet. I’ll get on that. Sorry.

Ah no probs just setting up my first one and wanted to make sure i was posting in the right spot :slight_smile:

Second thread here.

Getting access denied on that link. Also on the new monitor thread the script link doesn’t seem to work for me, at least on my iPhone.

1 Like

Weird markdown errors. I think.

1 Like