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

Thanks for the explanation @andrewjfreyer , but based on what you said, will it completely solve the problem? This will potentially solve when both are in, how about if just him is in and the phone dies? Or if there are multiple ppl in the home like a guest? (which at this point, is scary in thought considering the security risk).

I think the best approach is some extra form of intelligence in the management script, and not just forcing monitor to scan depart only. Whereby if a device declared away, and yet the door wasn’t opened within the timeout period with an offset if -30 seconds. There will be use cases for that of course, like if everyone is home, no need scanning arrival for extra security.

Better still for added security I think, have a sensor at the door that tells it someone is in front of it, either via a proximity or step sensor or something. So a device declared as Arrived with the door sensor being active tells it someone wants to get in. This was part of the reason I wanted to know how it was being activated from the door before monitor is instructed to scan.

Hope I made sense?

1 Like

Yes, I understand. The thinking is that the phone whose battery dies will not be recognized as having left at all. As a result, it won’t “arrive” when it’s plugged in again. Does that make sense?

I like the only depart scan if triggered.

Wasp in a box method!

1 Like

Ok will wait for the updates and test it. Looking forward to the depart only scanning, that will be cool

1 Like

I wanted to implement depart only scanning, so for both my scanning devices I used:
monitor.sh -t -x
And a depart scan is triggered when I open my apartment door.

However, I’m afraid that if I’m still in range when the scan is done, I’ll never be marked as away.

Is there a way to scan on depart AND to also scan periodically, but not too often?

My main scanning device sits close to the street with lots of people always passing through and if I let it triggered by unknown MAC addresses, it is scanning all the time :frowning:

1 Like

Does anybody have any false negatives? I have occasions where my phone will report 0% on both Pis after being stationary in the same spot for over an hour. This then fires my ‘away’ or ‘home’ automation’s which is troublesome.

1 Like

Yes I do used to get it, and I had a chat with @andrewjfreyer on it. In one of his updates, he added a feature that after the main monitor senses below a certain confidence level, before it gets to zero it has instructed the others to scan. This way if at the other end of the home, you could still be picked up.

As a fail safe, in addition to the above, my system has its own timeout, before declaring that I am away when below a confidence level. So when my device is sensed to be below my stated confidence level, within my timeout I instruct the system to do another Arrival scan again, so to be sure its not a False negative. Since Arrival scan is quick, this is quickly completed within the timeout and it checks again if I am truly out before doing anything.

Regards

1 Like

Just run it as default, or monitor.sh -x if you want the retain. Fill put in your MAC address into the known_devices file and it should only scan for you but when triggered and periodically.

Regards

1 Like

Was this a recent update by @andrewjfreyer and is there anything i need to do to use it?

Your fail safe sounds good would you mind sharing the implementation?

1 Like

I’m working on a feature now that should solve this. Triggering depart scan only on a particular MQTT message

1 Like

We can increase the minimum time between arrival scans or you could use periodic scanning with the -r flag

You can increase the number of arrival scans from the default of 2 and increase the time between scans from the default of three to effect a similar change

1 Like

Is there any way to get monitor to output the MAC’s that aren’t in the known_devices list that it sees more than once? I seem to have a lot of random bluetooth devices triggering arrival scans and it seems to be throwing things off. I’m not sure if its just all of the random devices I have in my house or its picking up some neighbors phones/devices too.

1 Like

can the scan start/end topics be changed a bit? - I think having it be generic (location/scan {"status":"start"}) with a payload to indicate the status fits better into many use cases, particularly HA where you may want to easily setup a mqtt binary sensor to indicate the state of the scan(s)

1 Like

Try the environment reporting with the -e option.

Yes, harmonizing MQTT topics with standards is definitely on my list. But… it’s a pretty major breaking change for a lot of people, so I’ve been putting it off.

Does anyone know of a pi zero outlet mount? Meaning something like this: https://mountgenie.com/products/the-google-home-mini-back-pack

2 Likes

I used a command strip to attach each directly to the power brick. Probably adds wild interference, but whatever.

@andrewjfreyer Yup it looks like you understood exactly why I stop the service. I think your solution will be better since I wont have to wait for the monitor service to boot back up after the door opens. With your fix it should save me a few seconds on depart. If I am reading your solution correctly than this would essentially allow me to turn off my phone once it has arrived even if both devices are not home.

My only worry is if I leave, how long will it do the depart scan for? My elevator is relatively close to my front door. I would still want it to scan for a couple minutes just to make sure that I have truly left the house.

thanks for this BTW, I didnt want to ask because you are already doing a bunch of work on the project and I didnt know how many people actually let there phones die when they are at home.

@Odianosen25 I am not 100 percent worried about the security part of things, it was more of an annoyance. In my actual Door lock settings (August Lock) I have it set to lock immediately when the door closes (about 3 seconds). So my front door is essentially always locked. I am only stopping the service when all devices are home for 4 minutes. If my devices are both home and my door hasn’t opened there is no longer a need for monitor to worry about anything until my door actually opens again (since both devices are already home).
currently if I don’t stop the service my phone will turn on after recovering from off/dead and monitor would sense that I am home an open my door. (the august lock will auto re-lock if the door hasnt been open for 1 minute)

2 Likes

First i’m really sorry for insisting on something that people have answered so many times but my ignorant head stidd doesn’t get it:

So I, like some others, must have more then one instance of monitor running, but I know for a fact that If I haven’t connect to a specific one I’m not at home this is where -t option enters:

  monitor -t[adr] scan for known devices only on mqtt trigger messages:
        a \$mqtt_topicpath/scan/ARRIVE (defined in MQTT preferences file)
        d \$mqtt_topicpath/scan/DEPART (defined in MQTT preferences file)
        r send ARRIVE or DEPART messages to trigger other devices to scan 

This is perfect “stop everything” until I say i need your help.
Just for the sake of making this as clear as water (monitor+mqq for dummys (like ME) )
HA: 192.168.1.1
front door: 192.168.1.2 (topic: /door/00:00:00:00:00:00 )
bed room: HA: 192.168.1.3 (topic: /room/00:00:00:00:00:00 )

Now the problematic part for someone like me (maybe even just me)
I use HA so my mqtt server is on my HA server, which means I have credentials setup on my mqtt_preference file for my HA server (HA: 192.168.1.1)

Now for me to get this option to work I need to send/publish messages to the topics
/room/00:00:00:00:00:00 which on my exemple is on server 192.168.1.3

I have mosquitto running:
pi@monitor_quarto:~ $ mosquitto
1537520034: mosquitto version 1.5 starting
1537520034: Using default config.
1537520034: Opening ipv4 listen socket on port 1883.
1537520034: Error: Address already in use

This gives me nothing
pi@monitor_quarto:~ $ mosquitto_sub -t /#

This all seam correct since I publish to my HA server and noting is “local” to each monitor pie, so How can I publish in a way to get the -t option working?

can i publish on a “automation” frm the HA to the HA mqtt server? This means that both monitors are subscribed to the topic on my mqtt server (if so this is the missing link, that i wasn’t able to undesrtand).

So I ask again, based on the exemple I gave, how can I trigger an arrive/departure scan on any of the pie’s running the monitor since both publish to a remote mqtt server (my HA pie)

Thank you and once more sorry for the “insisting” on the “basic” topic for many of you but i can’t get this to work.