agittins / bermuda

Bermuda Bluetooth/BLE Triangulation / Trilateration for HomeAssistant
MIT License
568 stars 12 forks source link

Username / password at setting up integration #40

Closed andrejs2 closed 1 year ago

andrejs2 commented 1 year ago

First big thanks for the integration, I just googled for ideas how to solve my problem with a deaf dog I have...he was hit by a motorbike few weeks ago because he ran on the street and the gateway was open beacuse my kids didn't close the gates...anyways long story short I was looking for triangulation (trilateration) for a beacon on my dog's collar. Thumbs up!

I have 1 question: When setting up integration the windows for username / password poped up... what is this? Where can I get the credentials? Thanks!

agittins commented 1 year ago

Hi @andrejs2 !

Unfortunately the integration is still very much in the early stages, and there is no trilateration implemented yet - but hopefully I'll be able to make some more progress on it soon. As such, right now it won't help you with locating the beacon, at least not without a fair bit of mucking about.

However, what it can do thus far is indicate the distance (distance is a very relative / approximate term here) between the beacon and the nearest bluetooth proxy you have, so it may be somewhat useful for you in that way.

The username/password is junk left over from the template I used to create the integration, so you can just put some random text into those fields.

Also, the version released here is a bit behind what I have on my local system, so I'll push my changes up in the next day or two (got a lot on tomorrow), as I think the current one here probably won't do anything useful for you yet, and on top of that it requires editing the source code to choose which devices to track.

If you're keen to hack on it by all means have at it, but I think the best thing might be if I find some time this weekend to get a minimum-viable-release together that might give you something at least vaguely useful :-) but don't get your hopes too high, it's nowhere near triangulation yet!

What I will try to get done is:

Would that be useful?

Do you have multiple bluetooth receivers (like esphome or shelly ble-proxy's) or are you just on one usb bluetooth dongle? Also, is the beacon on your dog's collar one that has a stable MAC address? There's no code in this for knowing how to track a beacon with a rotating mac, like the airtags.

If you get the integration configured, the one useful (again, a relative term!) thing you could poke at would be the json dump of the discovered bluetooth devices and calculated distances - go to Developer Tools, Services, and choose the bermuda.dump_devices service. It should give you a listing of the integration's internal state.

I should head off, but I'll post here any updates in the next day or two. Feel free to ask any questions you might have, and I hope your doggo is doing OK!

andrejs2 commented 1 year ago

Big thank you @agittins for your answer and help!

I find your project very interesting and promising... eventhough it's not fully operational and functional, I managed to get some things out of it :) My HA started tracking some data, but I'm not sure if the dog's beacon (it'a iBeacon) was tracked, it has a stable mac but can't find it in dump.

From bermuda.dump_devices I got 570 lines of data from 4 scanners (bluetooth proxies and esp32 esphome devices, shellys from which I couldn't get any other bluetooth data through proxy but here they did pushed something through :). There is much data in dump and I didn't have time yet to check it out precisely...

I managed to get though with username and password - like you said ...typing someting did the trick. đź‘Ť

I'm not so much keen on coding and I'm not a programmer any kind but I'll try to extract some useful data. And have to measure the distances from each scanner...I'll get back to you if I figure out something. There is so much potential in this :).

Much appreciated for your quick response and commitment to your project, looking forward to help as much as I can!

My dog is recovering quickly even though he is quite old. Thanks for aksing! There is so much energy and life in him!

agittins commented 1 year ago

Howdy! Well... I'm a little bit excited :-)

Just pushed a release of v0.3.0, which actually does stuff

After you update you will probably need to refresh your browser's page or you won't see the descriptions of the config fields - actually I'd suggest you remove the integration and add it fresh.

Now when you click the CONFIGURE button, rather than asking you for a bogus user/password it offers some more useful options.

When you have a chance it would be great if you could give it a spin and let me know how you go!

andrejs2 commented 1 year ago

@agittins Thanks for a new release, I had to install previous one, setting up latest was flawless...thank you!

In the mean time I got new BLE beacon for my dog (now he wears two beacons for testing purposes :)). The Chiplo One (iBeacon) wasn't recognized by ble tracker (but it works with Espresense). The other beacon (the aliexpress nRF52810) was instantly tracked and below I paste the part of dump file. Pasting as raw on purpose, because the output in code format is not devided into lines... The dog's beacon is CD:34:EC:21:23:ED and is tracked with most ble trackers in house (except Espresense)

48:55:19:99:5a:e2: name: ShellyPlus1PM-485519995AE0 local_name: ShellyPlus1PM-485519995AE0 prefname: ShellyPlus1PM-485519995AE0 address: 48:55:19:99:5a:e2 options: max_area_radius: 99 devtracker_nothome_timeout: 15 attenuation: 3 ref_power: -55 configured_devices:

  • CD:34:EC:21:23:ED unique_id: 48:55:19:99:5a:e2 area_id: 6336851a1eba4dfeb02ea1819bec6a6c area_name: Uta area_distance: 0.31622776601683794 area_rssi: -40 area_scanner: shellyplus1pm-b48a0a2160b8 (B4:8A:0A:21:60:B8) zone: null manufacturer: null connectable: false is_scanner: false entry_id: null send_tracker_see: false create_sensor: false last_seen: 147401.671208684 scanners: e0:5a:1b:c8:02:d4: name: Utility ESP32 Bluetooth Proxy c802d4 (e0:5a:1b:c8:02:d4) area_id: shramba adapter: Utility ESP32 Bluetooth Proxy c802d4 source: e0:5a:1b:c8:02:d4 rssi: -90 tx_power: -127 options: max_area_radius: 99 devtracker_nothome_timeout: 15 attenuation: 3 ref_power: -55 configured_devices:
    • CD:34:EC:21:23:ED rssi_distance: 14.677992676220699 adverts: {} stamp: 147401.671208684 b4:8a:0a:21:60:b8: name: shellyplus1pm-b48a0a2160b8 (B4:8A:0A:21:60:B8) area_id: 6336851a1eba4dfeb02ea1819bec6a6c adapter: shellyplus1pm-b48a0a2160b8 source: B4:8A:0A:21:60:B8 rssi: -40 tx_power: -127 options: max_area_radius: 99 devtracker_nothome_timeout: 15 attenuation: 3 ref_power: -55 configured_devices:
    • CD:34:EC:21:23:ED rssi_distance: 0.31622776601683794 adverts: {} stamp: 147399.702199364

I would like to ask for some help here. I have two questions—just to start.

  1. What format arerssi_distance, last seen and stamp value? How can I 'decypher' this?
  2. I get create_sensor: false, what are the parameters, conditions for creating the sensor?

Looking forward to explore this integration!!!!

agittins commented 1 year ago

That's great!

rssi_distance is in metres, and the timestamps are a format used inside homeassistant, I think it's "seconds since the system started up" or something. So to use them I use now() minus that stamp in seconds to work out a time.

If you click the "Configure" button for the integration you can add and remove which devices to track at the bottom there.

Once you've done that I'd suggest using the Area and Distance sensors to base any automations on, it will be a lot easier than processing the yaml in a template or something, plus it gives you the times in a normal sort of format.

Let me know how you go!

andrejs2 commented 1 year ago

Thanks for the insight on time and distance. Now the senors showed up!!! Got area and distance, finetuned the rssi on 1m, but it's unreliable (nRF52810). But the plus side on this beacon is that it beacons quite often in comparison to Chipolo One.

I'm expanding my bluetooth proxy coverage in my yard in the meantime and also waiting for new esp32s to arrive :))

Now I'm can focus on automating the stuff :)