Bermuda - Bluetooth/BLE Room Presence and tracking [custom integration]

I’ve been away with limited internet for the last few days, so catching up a bit…

As long as your watch is transmitting something, Bermuda should be able to track it. Since you know it has a stable MAC address, you should be able to go into the Bermuda integration, “Configure”, “Select Devices”, and find the MAC in the drop-down box. You can type in as much of the MAC as you need to to filter the devices, which should help if there’s a lot of stuff in there.

If your watch doesn’t appear in the list then either it’s not sending adverts, or perhaps bermuda (or HA) is filtering it out for some reason. If that’s the case, install an app like NRConnect and find the watch’s broadcasts in there, and send screenshots of the raw advert so I can see what’s going on.

You can also send a “download diagnostics” which will let me see what the backend is seeing, so I can perhaps identify why it’s not showing up.

You’ll need the v0.6.9rc2 version that’s in “beta”. Then in the “Configure” menu you’ll see buttons to take you through the proxy and device calibrations. There should be enough info in there to guide you through it, but let me know if it’s confusing or if the wording is off.

If your issue is jumping between two proxies there are also some other things to check:

  • What is your esphome config on the proxies, and what hardware are they running? A well-tuned esphome config will give you more reliable reports at closer intervals. Bad config will cause bouncing because of big gaps between advert reports or device reboots.
  • How are your proxies and watch physically located, typically? If the distances are similar (and for rssi measurements, the definition of “similar” can be surprisingly loose) then it will bounce between them. Eg, if Watch to proxyA is 2m and watch to proxyB is 3m, i’d expect you’d see a lot of bouncing, since a “noisy” signal at proxyA is going to be weaker than a “lucky” signal at proxyB. But if proxyA is at 2m and proxyB is at 6m, I’d expect far fewer bounces, all else being equal.
  • Have you altered the other settings from their defaults? They typically work OK but it’s easy to get into the weeds when trying to improve things.

If you are still having trouble you can raise a ticket on github and include a “download diagnostics” so I can take a look at the internals. If you haven’t restarted HA (or reloaded Bermuda) for a while it can take a long time to generate the diagnostics, so you might need to be patient for that bit.

Ooh, well spotted! That’s a great tute.

Awesome!

1 Like

Thanks for your response. The issue with the ‘generic’ smart watch and other watches is that they stop broadcasting a signal once they connect to a device (phone)
If I turn off Bluetooth on my phone then I can see track my watch with Bermuda. If I turn on BT on the phone, once the watch connects to the phone I cannot track the watch anymore. :frowning:

In the last 24 hours I saw a video on setting this up using ESPHome, and got 5 boards I had laying around setup around my home and I’m SUPER impressed so far. I even managed to get my Apple Watch added using the Private BLE Device option!

Only issue is my house is very small, and not much separates 4 of those rooms, so detection in my kitchen works pretty well as it’s in an extension, but when I’m sat in my living room the other 3 rooms are right above me, and it often briefly considers me in a room upstairs.

Do you have any tips for making room detection more accurate in this situation?

Thanks for the awesome integration!

1 Like

I’m also having this issue. Since I don’t need BT on the phone when I’m at home I created an automation where HA switches off BT on the phone when I arrive home. I prefer that Bermuda tracks my watch rather than my phone.

1 Like

Would you please share your automation? Thanks!

Sure! I have HA Companion installed in my phone (called p20). Please, be aware that it will not run in all phones:

alias: Switch off BT on p20 when arriving home
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.p20_wifi_connection
    to: YOUR_ESSID
condition: []
action:
  - action: notify.mobile_app_p20
    metadata: {}
    data:
      message: command_bluetooth
      data:
        command: turn_off
mode: single
1 Like

Yeah, it’s a bit of a pain. I configure my phone’s watch app (Gadgetbridge) to not stay connected to the watch so it only connects to it when I want it to - but that won’t be convenient for everyone as you miss notifications etc.

You might be able to find an iBeacon app for your watch - I think there’s one for the Galaxy, I was using one for infinitime at one point. A dedicated beacon app should still broadcast even while the watch is connected.

Nice! And thanks for sharing!

Another option might be to tell your watch app to disconnect, rather than turning off bluetooth altogether. Of course that would depend on support from the watch app (I think Gadgetbridge can do this as it fully supports control via “intents”, and the ha companion app can define and trigger those on-device).

Awesome!

Yeah, that’s pretty difficult when you’ve got rooms directly above, since the real distance can be quite similar. Adding another proxy in the lounge might help, the idea being that when the main lounge proxy is unlucky enough to get a weak signal, the hope is that the secondary one will get a clear ping, so that a moderate signal received by one of the upstairs proxies won’t be strong enough to “win”.

You can also try placing your upstairs proxies higher up on the walls (not at floor level) and the downstairs ones at waist-height, so that you increase the actual distance difference that they’re reading against. It’s always likely to be a bit of a battle though. You could experiment with placing foil below the upstairs proxies, that might reduce the amount of signal they receive from below - this sort of thing can be very hard to do with confidence though, RF stuff is dark magic, and it’s quite possible to accidentally build an aerial when you think you’re creating shielding!

2 Likes

I have the huawei p20 pro phone.
This doesnt work anymore.

You could use tasker on android to turn on/off bluetooth too.
BUT
Since 2023 this is also not possible anymore

Newer versions of android doesnt allow turning off bluetooth etc anymore.

So its getting really hard to do this.

I’m actually planning to buy a samsung smartphone cause of this… In samsung , you have the bixby routines, to do this:

I wanted a oneplus device though, but routines/commands arent available there… nor is tasker or HA able to toggle bluetooth on it.

I have an issue where the devices become “unavailable” (not “unknown”) after some time and are then unusable again until I reload the Bermuda integration when standing next to a proxy

Here you can see it clearly: I reloaded bermuda with the bottom device next to a tracker, then I reloaded it with the top device next to a tracker a bit later. Then bot devices where available for some time, until at the same point in time they stopped being. I reloaded it later that day and again they became unavailable.

What I noticed:

grafik

Home Assistant shows that the bermuda integration isnt providing that device anymore.

I also noticed that it seems to be at ~9AM that the devices are not reported anymore, except for the weekend. Is it possible that Bermuda thinks its not working when there are no devices in the area, even though that might just be because everyone is working and no phones are in the home anymore?

is it possible to track the occupaceny off a area, i would like to turn off the light when the room is empty.

You’ll have to compile /respond to that yourself. Areas don’t maintain occupancy like zones do.

Over on the github spdustin made a pretty good suggestion on how to do this: feature/question: area occupation sensors · Issue #203 · agittins/bermuda · GitHub

Yeah labels have really changed how I do automation. It’s basically the same thing I do for multiple things now

The ability to target pretty much anything for any reason is gamechabging. Want all the xyz that are also lmnop but tagged ‘Trakker’? A couple selectattr statements later and you’re there. Could even extend it and make a template sensor that behaves exactly like zones do but for a given room…

1 Like

Agreed - as soon as I saw it announced I knew it was going to be massively useful. All the framework and what might be seen as “rigidity” in HA was I am sure, hard graft to beat into shape over time. But then being able to layer a super-flexible user-driven thing like labels over the top of it really unlocks a lot of benefits.

Hi @doktormerlin, sorry I thought I had replied to your post earlier, but it seems not!

What you are experiencing seems fairly unusual, I’ve not seen that sort of behaviour before - at least that I can recall. There was one instance where someone found Bermuda no longer updated a device they had set up via Private BLE Device, and they worked out it was because they’d disabled the sensor for it, which caused private ble device to no longer update itself, so Bermuda couldn’t either.

The 9am pattern is very odd. Bermuda should still be trying to track devices even when they’re away. You mention it says they show up as “unavailable” but not “unknown”, while the history log shows them as “unknown” for long periods. Are they at the “unavailable” status for shorter periods not shown in that screenshot, or do the sensors show up differently in the log?

I think I’ll need a lot more data to work out what’s going on for you. Would you mind opening an issue on the github, and including the result of a “download diagnostics”? The diagnostics can be pretty slow to generate, but if you reload Bermuda first, wait a few minutes, then do the download it will finish a lot faster (it gets slowed down having to trawl through anonymising all the old mac addresses, which can take a while if the system’s been up for several days).

It’s possible that there’s an interaction if you have only Private BLE Devices and no manually-specified devices in Bermuda itself - it should still work fine but that’s the only thing I can think of off the top of my head that could potentially cause this sort of behaviour.

But if you can provide a diagnostics that will get us a long way to working out what’s going on.

Mayabe a stupid question, but why are my iphone very often go to unkown.
I would like to use it turn on somthing during the time my phone is in a room, if it leaves it should turn off.
But now when going to unknown the things i’m not in the room.

Is this a setting ?

Bermuda tries to stick to what it can “prove”. So if it gets a signal, it will make some assertions about that (device_tracker becomes Home, area sensors update). But in the absence of a signal, it’s impossible to “prove” if the device stopped transmitting, or if it’s now out of range of all proxies, such as when you take the phone to work etc.

Likewise if your phone stops transmitting, but then you take it to another room, it’s better (in my opinion) to be “unknown” than to remain at that last area. That at least lets you combine more sensors to build an accurate picture (eg, if watch is in bedroom or watch is unknown and phone is in bedroom…)

Based on that, I think it’s better that the area go to “unknown” rather than holding on to a value that may no longer be true.

That said, it is an opinionated choice on my part :slight_smile: and there is an open feature request for including a “Last seen area” sensor, which will be implemented. mogorman also shared their workaround using a template:

{% if state_attr('sensor.lina_area', 'area_name') == None or is_state_attr('sensor.lina_area', 'area_name', 'unknown') or is_state_attr('sensor.lina_area', 'area_name', 'unavailable')  -%}
{{ states('sensor.lina_filtered') }}
{%- else %}
{{ state_attr('sensor.lina_area', 'area_name')  }}
{%- endif %}

For things like lights, I’d suggest having area change being a trigger that starts a timer, rather than tying the off-state directly to the thing you are controlling. But it all depends on your use-case as to which method will be most suitable.

1 Like

doesn’t a device periodically send a package.

Sure they do.

  1. when was that timer in comparison to Bermudas internal refresh? (config screen for Bermuda)

I think my android companion was pinging every 30 seconds. When I set everything up I played around with max distance to report and how long to keep a device marked in. An area until most everything stabilized.

Ashley, I get why they’re asking for the last area sensor. I originally planned to do that myself what I found is instead keeping the device marked in area for about 2x or 3x as long (60s)as my longest reporting interval for BLE beacon (30 s) gave me a good debounce effect as long as the range was set wide enough. (basically don’t drop the area unless it misses two consecutive reports)

The problem is everyone starts not knowing those values and the default calibration in the config is probably a lot bit too tight so it’s flapping a lot.

How do you permanently remove a scanner that was previously a Bluetooth proxy but no longer is a Bluetooth proxy? I had an existing ESPHome device that I enabled the proxy function on but decided I didn’t want a proxy in that area and now it always shows with a skull and crossbones in the configuration. I’d like to remove it for good, but I haven’t been able to figure out how.