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

I have tried with NUT but no luck, they don’t work.

BTLE detection is moved to monitor, as an FYI

Hello @andrewjfreyer,

I am using node-red way, and so far liked it so much! Works very nice and convenient. Thanks for your effort.

Just a quick question,

How do you add new devices? As I guess, I need a new flow for every device? Or am I wrong?

Thanks!

Hi Andrew,

Was running the “Presence” for a few months now and I wanted to try the Monitor version.
Great overall improvement !

I have a question for you, is it possible to publish to the MQTT broker using a nickname instead of the Mac Address ?

Reason for this is that I have a MQTT-SmartThings bridge and several actions based on presence. The devices on the SmartThings side must be named after the Mac Address.

When a member of the family changes their phone, it messes everything. I would like to only update the “known_static_addresses” file …

1 Like

Mine randomly stop working. I’m running them on pi zeros and this morning one wasn’t doing anything even though it was still up (top showed it fine). I even restarted and nothing, hung processes or something? Is the pi no powerful enough?

@ryanrdetzel, I am experiencing the same thing. Both on a Pi zero and on a Pi2 in need to reboot almost daily.

1 Like

Monitor or Presence? For monitor beta, that is known issue that I’m working out.

This is an often-requested feature. I’ll likely include it in a future update.

Thanks @andrewjfreyer, in my case that is monitor.
Side-note: not sure what the difference is. I was guessing monitor was the successor of presence…

FYI, here is the code I modified in the “mqtt” script to be compatible with the “SmartThings Virtual Presence Sensor” + MQTT bridge :

#DEFINE THE TOPIC
#********************* Modif JMB ******************
local topic=“$mqtt_topicpath/$3/presence”
[ “$PREF_MQTT_SINGLE_TOPIC_MODE” == true ] && topic=“$mqtt_topicpath/$3/presence”
#**************************************************

and

#POST TO MQTT
#********************* Modif JMB ******************
if [ “$2” == 100 ]; then
$mosquitto_pub_path $should_retain $mqtt_ca_file_append -h “$mqtt_address” -p “$mqtt_port” -u “$mqtt_user” -P “$mqtt_password” -t “$topic” -m “present”
else
$mosquitto_pub_path $should_retain $mqtt_ca_file_append -h “$mqtt_address” -p “$mqtt_port” -u “$mqtt_user” -P “$mqtt_password” -t “$topic” -m “not present”
fi
#**************************************************

Hi Andrew, wanted to say how great this is. Great work.

I do have two questions:

  1. You mentioned you use this with a Pi Zero. How? I find that with bluetooth scanning and WiFi the pi becomes completely unresponsive to SSH. Can barely login.

  2. I’m also finding that I have to restart monitor every time I restart Home Assistant or I get very unreliable results in my template sensors. Do you have this issue?

Thanks

1 Like

I’d suggest that you use monitor if you are experiencing interference. The issue is with repeated bluetooth scanning, which is how presence functions. monitor on the other hand waits for passive bluetooth advertisements and then scans.

1 Like

Thanks. I am using monitor though. Must be some other issue. Thanks.

Awesome and very thorough write up - thank you for sharing!

Just installed (and have a bunch of cheap BLE tags that I initially wanted to use for my cars - but also to keep the garage light on when i’m in there and NOT keep waving at the sensor LOL)

if i use hcitool scan i only get ‘thoroughbred’ Bluetooth devices
however using bluetoothctl i can see (what i think is) the BLE tags.

little confused if I can use the tags - it seems not?
EDIT (using my phone MAC it reports to MQTT perfectly - so thanks again for the instructions!)

Beacons are not supported by presence, but you may be interested to try the sister project monitor

1 Like

Thank you for this. Works perfectly with my Samsung S9. But I have trouble with my wifes iPhone 7. It is only discovered if I go into the Bluetooth settings, turn BT off then on. Then the iPhone is discoverable.
Is there a setting in the iPhone maybe?

1 Like

Thanks, I just made this work as well, it’s a brilliant suggestion, use of mqtt to create new entities.
image

This sounds like a symptom of your wife’s phone never having connected to any bluetooth device. Apparently Apple will not power the bluetooth radio for BTLE advertisement unless her phone has previously connected to at least one bluetooth device.

iPhone 7s work fine on this script for other users. I suggest connecting to an arbitrary device and then trying again.

Which tags were you using?

I have a scenario where BLTE tags are ideal, and I don’t mind changing the batteries every six months. However, the (cheap) tags I purchased, power down after 30 minutes. That’s impossible to work with; I need a tag that stays on constantly and reports presence with each scan.

Thank you very much! Her phone is new and was never paired to anything Bluetooth before. Paired it with a random speaker and now it works beautifully.
Thanks again!

1 Like