Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering in device_tracker #286

Open
kamkilt opened this issue Aug 8, 2024 · 3 comments
Open

Filtering in device_tracker #286

kamkilt opened this issue Aug 8, 2024 · 3 comments
Assignees

Comments

@kamkilt
Copy link

kamkilt commented Aug 8, 2024

I'm trying to move totally from ESPresence to Bermuda BLE Trilateration, my goal is to quickly and precisely detect approaching/arriving at home to unlock the door lock while coming back.

I'm making test and comparison and have found that Filtering is apparently not working for device_tracker entity.

On below screenshot we can see, that there is false (more than 12m set radius) detection reflected in device_tracker state change.
It's probably detecting me in a car going out of garage.
I'don't know is it a bug or future, but in my case I would like to have all the filtering working also in device_tracker entity.
Screenshot 2024-08-08 at 07 46 37

@agittins agittins self-assigned this Aug 8, 2024
@agittins
Copy link
Owner

agittins commented Aug 8, 2024

Howdy!

The TL/DR is: Increase Device Tracker Timeout to something like 5 minutes (300s), and/or add extra logic to your automations, like unlocking only when the Area leaves unknown.

This is largely by design, and I'd rather not change how the device_tracker works because it's job is to transition to HOME when it can prove that a device is close enough to hear at all, and then switch to away when it assumes it's been long enough that it has probably left.

Filtering and making extra assumptions beyond that is really what the distance and area sensors are about. For your use-case, I'd suggest (well, first I'd suggest caution about using unencrypted bluetooth to unlock secure areas, but I assume you've assessed the risks for your situation)... I'd suggest using the device_tracker to trigger your arm_house automation, tweaking the device tracker timeout to get a good balance for how quickly you want the house to assume that you've left.

Then for the disarm_house automation I'd trigger on "when Area switches from unknown". Optionally you could add a check that the house has been armed for more than x minutes, to avoid nuisance unlocks while you're still in the car getting ready to leave, etc. This would still give you rapid response on returning home, and incorporate the max_radius restriction as well.

The key is to work out what sensor states really fit the criteria for your being "away", and I'd suggest that the device_tracker sensor should be only a part of that.

Does that make sense?

@kamkilt
Copy link
Author

kamkilt commented Aug 12, 2024

Thank you for quick answer, I tried this approach, but in this case I have a lot of changes from unknown to specific area, it seams that AREA doesn't have timeout implemented but have DISTANCE filtering enabled (I've set 12m).
For testing purposes I have set notification only after change of AREA from unknown and receive a lot of notification while being still at home.
Screenshot 2024-08-12 at 08 56 14

@agittins
Copy link
Owner

I probably didn't explain what I meant very well. I was meaning that what might work is if you:

  • Use the device_tracker to sense when you are "away", and have the devtracker_timeout value set to 300 seconds or more. Have this automation turn on a boolean helper called "house_empty" or something.
  • For your "arriving home" automation, it should use a combination of both:
    • Area switches from Unknown to anything
    • AND house_empty has been ON for more than 5 minutes

This way you don't get nuisance "gone away" triggers because the device_tracker waits for 5 minutes before deciding that you really have left, and you don't get nuisance "arrived home" triggers because it makes sure you've been gone a good while before accepting that bluetooth signals really do mean you are home again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants