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

I did not say it could not function this way. I gave a reason why it had not been considered as an option.

Ashley (the project developer) may have another technical reason. Or may even just not have the time to include this. I can’t comment on that.

Respect and appreciate your response. Completely understand those reasons for no implementation. Just figured with the simplicity and existing support already included in HA, that it would have been implemented early on. Definitely would have contributed to more adoption of the project. Almost motivated to turn my work into an integration but then it means support. I am already OCD with my home implementation with a dev, staging, QA, and prod. environment. Last thing I need is making myself go back to work lol.

Amazing article - definitely helps - thank you!

(so… when’s the triangualtion coming?! :wink: )

1 Like

@agittins , I may be wrong but I am pretty sure that before, the last seen area has always been different thant the current area. I was using this to run my gate automation but now things are failing and I noticed that the area last seen is equal to the current area unless the current area is unknown.

Am I making this up or has something changed? I personllay believe that the area last seen should not be the current area as then it would make that information redundant and useless (unless a suer is unknown - aka not near a proxy).

Thoughts?

The companion app implementation is specific to the companion app, and has nothing in common with how HA handles bluetooth data - while Bermuda interfaces to HA’s bluetooth implementation.

This part is a good idea, and I will probably use this at some point as I have been wondering about ways to link the device entry in HA for the companion app to the Bermuda device. Sometimes it’s tricky to do this sort of linking though as it can cause unexpected side-effects in HA or unexpected behaviour for existing installations (well, unexpected to me, anyway) - it’s not an entirely “simple” process, but I am likely to implement something like this at some level, at some point.

It’s very easy to feel like it wouldn’t be hard for someone else to do something :stuck_out_tongue_winking_eye:

This was first suggested a bit over a year ago, and I give a reasonably complete run-down on the situation at Use Android companion app beacon monitor as BT proxy node · Issue #327 · agittins/bermuda · GitHub - including the existence of a bluetooth proxy app.

Note that my suggestion at the time (and again in other places) is to raise a ticket for the companion app to implement the “BaseHaScanner” feature. I suspect there might be one or more open feature requests for it but I’m not sure - but it’s certainly the (my) preferred way forward.

FWIW, my position is that Bermuda supports the Homeassistant bluetooth integration and processing data from scanners that implement the BaseHAScanner interface, like esphome, shelly, local bluetooth (with caveats) and, importantly, the GitHub - kvj/hass_Bluetooth_Proxy_Companion project (also with an important caveat that I’m not sure is resolved yet).

I intend to do my best to support any system that implements this interface, with the important caveat that the user experience and utility will be non-linearly proportional to the rate of ad updates and availability of accurate timestamps.

I am aware that this post uses the word “caveat” suspiciously often :rofl:

Apart from the pedantry of triangulation requiring heading data, the trilateration of devices also requires reliable timestamp information and ideally rapid updates - neither of which are provided by the Beacon monitor in the companion app. Also I am 100% certain that the distance calculation method that is baked in will be useless to Bermuda, as it precludes doing really important smoothing and noise reduction on the received data, or being able to do operations at the base db level, which I am expecting to be a requirement in the near future.

It could be possible, but it would add a bunch of extra code to Bermuda for a niche method of implementation with sub-par results when better options/paths exist - the proxy implemenation linked above, and having a BaseHaScanner implementation in the companion app.

Everything in the BaseHaScanner interface, along with timestamps and sub-second updates. Also, support for every bluetooth device, not just the narrow selection of those sending iBeacon :tm: adverts.

Yes, it can really feel like that sometimes :laughing:

1 Like

This is what it’s meant to do - the use-case is to persist the area value even after the device has gone out of range or stopped transmitting, such as when the kids lose the ipad somewhere then the battery goes flat.

I don’t think it ever worked that way, because I don’t remember that being a bug that I had to fix! :rofl:

One possibility is that Bermuda may have been updating the value after updating the area sensor, so if you have an automation that triggered on the area sensor changing, you might find the previous area name still stored in the last_seen_area sensor. This might have shown up as a race condition, where it was just luck as to whether the automation saw them both the same or not, or it may have been a “bug” in Bermuda where it only updated the last_seen on the next update cycle, ie one second later.

I’m pretty sure these are the most likely explanations, as I know I never intended the last seen to reflect “previous area”, only to persist the most recently detected area - but it may well have behaved that way in some form, unintentionally and without my noticing it (or remembering :sweat_smile: ).

If you need to automate based on the area changing from a particular area to another, I’d use triggers that specify the desired transition using both the from and to paramaters.

eg, in yaml:

trigger: state
entity_id:
  - sensor.ashley_pixel_irk_area
from:
  - studio
  - garage
to:
  - lounge

or the UI:

(note that you’ll want to check the actual state value used for each area in the developer tools, or you could use the attributes instead and specifically match area id or area name).

Would that work for what you are implementing?

The problem I keep running into is how to trigger this gate automatin. Originally it was via my phone’s bluetooth connection but then my spouse uses an iPhone and I can’t see connected bluetooth device. Then, that’s when I decided to use a ESP32, put it in the car and track it via its own iBeacon.
So the trigger has to be when the car reaches the gate. But then I need to know if we are coming or leaving the house. This is mainly to best automatically close the gate without too much delay as we have pet and to do so I need to know if I am coming from my garage or elsewhere.
This is really not a problem for you to solve though I think it would make sense that the last seen area is the last seen area and the current area is the one you are in. And as you said, if a device goes offline/unknown, the last change area should be updated with the last current area. Though I see this could be problematic if home assistant is restarted during this process, etc.
Thank you for the reply as always and I will see on how to change my logic.

Hi all,

I am really struggling with understanding how to configure Bermuda. I understand the concepts of trilateration.

I want to track my Apple Watch around the house. I have integrated it into HA via the Private BLE device integration.

For static devices, I currently have:

  • 1 BT proxy device to improve connection to my SwitchBot bots.
  • 1 AppleTV.
  • 1 Switchbot

I was hoping to prove the setup before buying a bunch more ESP32 BT proxy devices to complete ‘mapping’ the house.

My Bermuda page self-populated and looks like this:

When I click on the patio_camera_switchot, the associated sensors says it’s in the Livingroom (which it is not - the device has been assigned to an area though).

Are these supposed to be the static devices that are used to locate my watch or are these the devices being located?

If these are the static devices, how do I remove my watch from the list and add it as a mobile device? I know my watch’s BT MAC address but cannot find it in the select devices list (below).

How to I allocate the static devices like the AppleTV, the BT proxy and the switchtbot?
Any advice would be greatly appreciated.

Those are the devices being located/tracked.

The location of the patio_camera_switchbot should be dictated by the location of hte closest proxy device.

I cannot answer this question but it all depends if those devices are supported as BT Proxy devices. I may be wrong but I believe only the below devices are supported by home assistant for Remote BLE proxies by the Bluetooth integration: list

Also, from Bermuda BLE itself, this is the list of supported proxies:

  • ESPHome devices with the bluetooth_proxy component enabled. I like the D1-Mini32 boards because they’re cheap and easy to deploy.
  • Shelly Plus or later devices with Bluetooth proxying enabled in the Shelly integration.
  • USB Bluetooth on your HA host. This is not ideal, since they do not timestamp the advertisement packets and finding a well-supported usb bluetooth adaptor is non-trivial. However they can be used for simple “Home/Not Home” tracking, and basic Area distance support is enabled currently.

Q: When you click on the Bermuda integration and then click on the cog (see 1st scrennshot), what do you see listed under the scanners? Below is the list of my Shelly and ESP devices used ac BLE proxies to track things around the house:

1 Like

Thanks for your reply!

Got it, thanks! So, these are devices that Bermuda found itself as opposed to the long list in my 2nd screenshot which lists a bunch of BT devices that could also be added manually)?

The confusing thing is that patio_camera_switchbot is in a fixed position (attached to one of my wall switches). It will never move so why is Bermuda tracking it (and getting the location wrong given the only scanner proxy is in the same room)?

Is there any way I can tell Bermuda not to track it or should I just ignore it?

I get the picture below - it only shows the single proxy I had bought for testing (and to strengthen by BT network).

OK, I get it - I have one scanner (will buy more) and everything else with BT is being tracked, correct?

So, can we make Bermuda’s life easier by telling it not to track my (fixed position) Switchbot? …do I simply disable device_tracker.patio_camera_switchbot_bermuda_tracker

thanks!

Yes those could potantially be added. In my case, I purcahsed a small BLE tracker for my dog and being a bsic device, I had to find it myself, then go through the list and select it as a device to be tracked. I also used iBEacons for some devices and so add to select those manually from that list as well.

That is correct, you currently have a single scanner. This scanner is mapped to a specific area (I assume it is your Living Room). So anything being detected by this scanner will show up as being in your leaving room as you do not have any other scanners currently.

I would just ignore it. If you remove it from Bermuda BLE, it will automatically comes back as this is a bluetooth device.

I am not sure why you would care. This device’s location will never change and you don’t have to use it for anything so I would leave it as-is personally and ignore it!

3 Likes

Brilliant - thanks for all your answers.

No, that’s the (remaining) confusing thing - the proxy is not in my living room (in HA or real life).

Hi @jchh,

I see that @toxic has covered most of your questions pretty well (thanks toxic!), so I’ll just add/clarify a couple of things…

Key point of confusion here is likely to be that… Bermuda doesn’t (yet) actually do trilateration! Currently it detects which proxy a given device is closest to, and reports that as the device’s area.

Currently Bermuda doesn’t have an internal concept of “static” devices, other than it assumes all bluetooth proxies are static. This will change at some point, allowing you to indicate certain devices as “landmarks” that do not move, and also to exclude certain proxies from being considered as statically-positioned. But not currently.

Can you send a screenshot of the device page for this device? To be honest, I don’t know why it’s showing up as a device in Bermuda like that. Bermuda tries to identify any existing devices that the user is likely to want to track, such as any devices set up in the Private Bluetooth Device integration, which is where your watch is coming from. But I can’t work out why the switchbot is showing up here.

Is it a plug? Have you flashed custom firmware to it? I think the switchbots are able to be flashed with esphome, in which case they can be set up as bluetooth proxies - but even in that case I wouldn’t expect it to show up there. Maybe a screenshot will give me enough info to work out what’s going on there (like which other integrations are picking it up, which might in turn cause Bermuda to latch onto it).

If I can’t tell from the screenshot what’s going on I might ask you for a “download diagnostics” but a simple screenshot might be the easiest place to start.

1 Like

Hopefully my previous post on using the from: and to: conditions for your automations will do the trick - from unknown to gate means “arriving home”, while from “garage” to “gate” means leaving.

I’d also take a look at the wait action which you could then use to wait (for example) for the car to get within x metres of the gate before opening it, or x metres away before closing etc.

Thanks!

I’ll reply tomorrow when I’m next at my PC.


Edit: OK, it’s a new day!

Firstly, thank you so much for coming up with this; it’s an incredibly inventive & imaginative!

Thanks for clarifying that it’s nearest proxy. …I’m still excited about this though.

I uninstalled / then re-installed and now the SwitchBot isn’t showing as a tracked device. I’m honestly not sure whether that means I added it manually myself or something else, but it is working fine now :+1:

I have been through so many iteration I can’t even tell you but I had used the from: and to: triggers befroe but still the automation sometimes would not even trigger at all.

I have done a few things to help which so far has been a lot better:
1- Split the open and closing gate into 2 separate automations
2- My car ESPHOME device now is only sending iBeacon and no longer being a BT proxy
3- Removed my dining room ESPHOME BT PRoxy. It keeps on detecting my car on arrival and so preventing my gate from opening. I tried playing with the Per-Scanner RSSI Offsets but it would sill discover the car with crazy distance instead of the Gate Shelly device whcich is way closer (though BT signal I guess is not as strong on those devices…)
4- . Added a bluetooth proxy towards the end of the driveway so I know if I have arrived home in order to close the gate and open my garage door.
5- Added an extra WAP for better coverage of my shelly devices managing the gate!

I am still making a few tweaks and only today disconnected my Dinong room BT proxy but I whink now I should get much better and fater response.

I have avoided using the distance cause I am not sure how much/fast its detect and how accurate it is. My spouse if not so patient so I need the least amount of variable even if that means I need to suffer building more bullter proof automations ;).

Thanks again for your reply and all your help!

Hi

Been some time i’ve been here, but i still want to use this.

I bought some esp32 plugs here:

I flashed those with esp home like this:

substitutions:
  name: keuken-plug
  friendly_name: Keuken - Plug ESP32
  relay_restore_mode: ALWAYS_OFF

packages:
  Athom_Technology.Smart_Plug_V3: github://athom-tech/esp32-configs/athom-smart-plug.yaml
  Bermuda.c3: github://agittins/bermuda-proxies/packages/bermuda-proxy-c3.yaml

esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "ESP32 Fallback Hotspot"
    password: !secret esp32_ap_password

text_sensor: !remove

time:
  - id: !remove sntp_time
  - id: homeassistant_time
    platform: homeassistant

However it seems that the 2 packages have conflict with eachother.
It has some duplicate things like:
-WiFi Signal dB
-Restart
etc etc

How should i solve this, cause i think the best thing to do is to keep the athom smart plug package and get rid of the bermuda one, but then add some kind of bluetooth proxy which would work?

But im not that good in esp home…
Who can help pls?
Thx

Is there any way with this integration to group tracked devices? My wife and I both have a watch and phone but often one or the other is left on charge. It would be great if I could group two devices as a person and then the location would only update based on the last changed device.

1 Like

You can build a template sensor for that.

Dear Forum,

i have some problems with bermuda. I am trackning my iphone works ok. i bought some tile devices and my amazitfit watch which has an option to advertise itself. I added the 2 tile devices in bermuda. I walk thought the house they get recognized in the correct room. same with my watch. however after a while they become ‘unavaiblae’ . If i add them again to bermuda with same mac adress even without removing them they work again. if i aproacht he tracker the distance becomes smaller if i go further away the distance is higher. and the cycle repeats itself. i don’t really know what to do anymore to get it working. From my research other usesrs have reported that tiles work . The scanners are a combo of esphome and shelly devices. I would also like to mention that i tried with the nrf conneect app on my iphone scanning for the devices and it sees them. so i would not say that the tiles or my watch do not transmit. The nrf scannner app also has a rssi graph option which increases and decreases if the tile or my watch come close to the phone or goes further away. Can someone give me some pointers on what can i try to do to get this working?