Bluetooth tracker to only detect arriving

So in quest for having a more solid arrival detection, I added bluetooth_tracker to my configuration (on top of iOS app tracking, and HomeKit tracking). Since I’m using Raspberry Pie 3, I just set it up to detect both mine and my wife’s iphones through bluetooth. It works great to detect our arrival. However while we’re home, for some reason, the bluetooth randomly drops, and show one of us not_home. It actually nearly caused to arm the alarm by flagging both of us not_home when we were home this morning! So this made me thinking, is there a way to use the bluetooth tracking only to detect our arrival, and not for departure?

Also, if I wanted to add one or more bluetooth detectors to detect our phones, and hence reduce the false positives, what devices would you suggest?

Hi,

I have the same setup in my house and running all 5 mobile phones as presence detection. I had the same issue with the frequent drop-outs and solved it the following way

  1. In the configuration.yaml (or other yaml-file where your device tracker is defined) you have ta add the parameter consider_home: 300. You have to play with the value a bit to find the best for your case

  2. I have defined a Input boolean (e.g. Daddy_home) for each home member (not using home or not_home

  3. When ever not_home is triggered i wait for 2 minutes and verify if status is still not_home than I change the according boolean (e.g. Daddy_home = false)

  4. When ever home is triggered i wait for 2 minutes and verify if status is still home than I change the according boolean (e.g. Daddy_home = true)

The above steps removed the frequent switches between home and not_home. Unfortunately I don’t have the according scripts anymore as I have moved my automation to Node-Red.

I have no false triggers anymore and use the presence detection now for

  • Welcome home message
  • Good-by message to phone with information if doors are open or lights are still on
  • Weather/Rain warning to my phone if nobody is home
  • Remind my kids on tasks (e.g. get the garbage bins out when they come home)
  • the list is getting longer and longer week by week :slight_smile:

The best thing to do here is to group all of your trackers together, then use that group’s state for automations. I use GPS Logger, Bluetooth, and Unifi. All 3 are independent trackers and all 3 are listed in a group.tracker_name for each person. Per the group docs, the state of a group with device trackers in it will be “home” if ANY of the trackers are home and “not_home” if ALL of the trackers are not home. I have been using this method for a long time now and its very reliable.

This is exactly what I’m doing now. But the spotty behavior of bluetooth tracking is problematic. Just yesterday I had two false positive examples. As I said, if I could just use bluetooth for detecting the arrival, and not the departure, it would be much more reliable…

It sounds like you have something setup wrong then. The whole point of multiple trackers is to eliminate this issue. BT marking you as away, if you’re using the group properly, won’t ever mark the group as away as long as one tracker is home. Can you post your config?

I explained how it happened in my original post: “It actually nearly caused to arm the alarm by flagging both of us not_home when we were home this morning!”

One reason that this happens might be that the Pi3 bluetooth range does not cover our whole house… But I have seen the connection dropping even when I sat 6 ft away from the Pi3.

If you group everything together, this cant happen as long as one of your other trackers are home and you are using the state of the group for your automations and alarming.

For example, this is in my groups.yaml file:

  tracker_gregg:
    name: Gregg
    view: no
    entities:
      - device_tracker.gregg_phone #Gregg GPS Logger
      - device_tracker.gregg_phone_wifi
      - device_tracker.gregg_phone_BT

In my setup, I use the state of group.tracker_gregg to arm, disarm, etc. If the BT device tracker goes to “away” or “not_home” or whatever, it doesn’t matter because I will still be home on wifi and the GPS Logger tracker. One single entity in that group being home makes the state of the group as home. With this setup, your configuration should never directly reference the BT device tracker except in the group itself.

Straight from the Home Assistant Docs HERE:

Group behavior
When any member of a group is on then the group will also be on. Similarly with a device tracker, when any member of the group is home then the group is home.

Oh, I see. In my case, I only have one device_tracker per person, so both gps and bluetooth (sadly I can’t use wifi, since my modem does not support it) update the same device_tracker (for each person separately). So how do you separate device_tracker to “gregg_phone” and “gregg_phone_BT”? Thanks for the sample code, btw.

I’m assuming you have them combined in the known_devices.yaml file by adding the BT mac address in the existing GPS entry? I had done this early on as well but ran into similar problems.

If so, the easiest thing to do would be to just remove the mac address from the entry and restart Home Assistant. This will still keep the same entry for your GPS tracker and then create a new one once it detects your phone (with the same BT MAC address - at the bottom of the list). Once you figure out what this is called, make both of those into a group, similar to my example I added above.

Long story short, always keep each tracker separate in the known devices file and group them by person in your groups.yaml.

Others have been messing with the Bayesian sensor, but I’d suggest you get this running and ensure its reliable before you venture down that road.

Have you looked at this solution? I haven’t set it up myself as I use wifi tracking which is working really well for me for the time being.

Thanks! I think it’s working now. :slight_smile:

You could use nmap instead of wifi.

will you share your automation setup on yaml here ?

See my other post above

(LINK)