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

I wrote here last week regarding some unreliable results. I have a small apt but due to thick cement walls the phone sometimes drops to 0% confidence. You asked me if I had a door sensor. Which I don’t. But I just realized I got a motion sensors pointing at the hallway door. So could I use that in the same sense and trigger a departure scan only when motion is detected and no time else? And if so, can this be done within Node red with the mqtt node?

Thanks once again!

1 Like

Yes, that can work just fine with either HA or in Node Red.

I think I have this correct setup. Does this seem right?

So if that is correct, next step would be to disable departure other than node red/motion sensor. Do I just set PREF_DEPART_SCAN_INTERVAL= to a really huge number or whats the correct method?

No, that’s not quite right. Unless you have defined your $mqtt_topicpath variable to be rpizero/monitor The topic should be monitor/scan/depart and the payload should be blank (for your purpose).

Then you’ll launch monitor with the flag -td.

1 Like

Thanks! I’ve implemented this. I had an issue when ‘real life’ testing in that only one of my instances reported 0% the other instance remained at 100%.

I think this may have been caused by multiple door openings and closings prior to leaving so I put another script in-between the automation and this script which restarts the script incase its already running.

Right now when my door opens I call
Script.cancel
When my door closes
Script.turn_on

I also call
Location/scan/restart

Just in case,. For my own sanity

https://n-o-d-e.net/nano_server.html

3 Likes

Nice case.

Just following up on this (it has been awhile since the MOL has been to the house). When I run the hcitool it returns no response. Have you seen this behavior before? Is it a matter of the iOS version?

Edit: just updated her phone to iOS 12 and it’s still happening. Reports the status and then when the screen turns off, goes to zero.

I think i’ll adopt this implmentation instead much more simplified.

What is ‘Location/scan/restart’?

1 Like

This calls a restart to all nodes in the topic path. It basically does
Sudo systemctl restart monitor.service
On all of your nodes

3 Likes

Excellent didn’t know that was possible!

I didn’t know this either - sounds perfect?! Like an arrive scan and a depart scan all in one?!

1 Like

Yeah, I dont think that was the Intent… But for me it works well because there are still random times where one of my sensors isnt reporting correctly. This way I know that they will most likely be correct once the automatic restart happens. Honestly since its just calling a systemctl restart I feel that it shouldnt have a negative affect.

2 Likes

Poyfect!! Love it.

I trying to get the only departure on mqtt trigger to work with my motion sensor. But even though I ssh into monitor and then sudo bash monitor.sh -td and have set PREF_MQTT_REPORT_SCAN_MESSAGES=true it wont work.

I tried with going into my sensor in HA, turn off my bluetooth on my phone to simulate a drop off or weak signal. And even then the sensors slowly starts to go to 0% confidence. Shouldn’t this only happen when I’ve triggered mqtt monitor/scan/DEPART in node red?

my PREF_MQTT_REPORT_SCAN_MESSAGES is set to False. but i dont think that matters.

A follow up to my previous post.

When I woke up this morning I turned off Bluetooth on my phone and same result, phone sensor 0%. But now when I left home for work and my phone sensor in HA is still on 100%. How is that? What’s the difference? Anyhow - I guess my mqtt departure trigger in node red isn’t working.

False is default but read somewhere earlier in the thread that I should have that as true with mqtt dept trigger. Hm

Is there a docker container available for this?

Have you searched the thread?