Presence with BT (consider home)

I have a problem with no idea how to solve it. Need some help.

I have presence based on phone BT. A raspberry is doing scans every 30 seconds and publish status via MQTT.

I need to, once some person is detected, to keep that status for some time (like 10 minutes), but if the phones goes away of the BT radio, is will publish status ‘not_home’.

If I set the scan frequency to a lower rate, it will take a long time to detect someone. I tried to make some automation but did not work.

I also have presence detection with ping to the ip device, but BT is much faster when I come home and some times phone does not connect to wifi immediately, but BT is always discovered after few seconds I cross the door (but then if I go away the BT radio, it changes to not_home and that is my problem).

Any idea how to solve this?

Well, this is probably solvable a couple of different ways. What are you using for automation? Built-in HA or NodeRed or something else?

Built-in HA. What do you propose?

Well, I’m more familiar with NodeRed and this would easily be done with a delay node and a switch node. I mocked up an example for you below.

Not sure how to implement this in HA.

BT presence with MQTT works as push notifications, so I cannot control when they happen or stop them from happening (I think)

Well, if you want to publish the config that you tried for HA automation, we could offer some feedback to make it work.

Sure, is quite simple:
I have two device trackers for each person:

  • Phone BT (with a raspberry for detecting and then publishing via mqtt) -> tracker_bt
  • Phone ping (as soon as phone connects to the internet, it changes to home state) -> tracker_phone

So, what I made was, when tracker_bt was detected (person status change to home), then I set up tracker_phone to home as well (it has the property consider_home set to 10 minutes).

But it did not worked, because as soon as tracker_bt change back to not_home, person status also change to not_home (even tracker_phone was still with home status).

A few options here…

  1. This article on making presence detection less binary
  2. Group your Bluetooth and WiFi trackers so that you’re home as long as one is home
  3. Add a sensor to any entry/exit door, use a boolean for home/away, and automations (that’s how I do it)