Integrate Bluetooth battery monitoring devices (cars, motorbikes etc.)

@1technophile

Im using the esp32dev-ble (v1.6.0), it has discovered the BM2 monitor correctly, and the percentage is always right but the voltage sporadicaly changes between 0v and the actual voltage. Its a bit odd, looking through the MQTT messages, I cannot see it publishing a 0v message:
image


{
 "stat_t": "+/+/BTtoMQTT/50547B22656A",
 "dev_cla": "voltage",
 "unit_of_meas": "V",
 "name": "volt",
 "uniq_id": "50547B22656A-volt",
 "val_tpl": "{% if value_json.uuid is not defined and value_json.volt is defined -%} {{value_json.volt}} {%- endif %}",
 "state_class": "measurement",
 "device": {
   "identifiers": [
     "50547B22656A"
   ],
   "connections": [
     [
       "mac",
       "50547B22656A"
     ]
   ],
   "manufacturer": "Generic",
   "model": "BM2",
   "name": "BM2-22656A",
   "via_device": "SLKbattmon"
 }
}

Here are my settings in case I have something misconfigured:

It looks like it may be switching to 0v, when it does a scan that does not include Voltage data:

Help very much appreciated. Thank you

Reading up through this thread, I suspect this is my issue. Here is one of the messages:

{"id":"50:54:7B:22:65:6A","rssi":-40,"brand":"GENERIC","model":"iBeacon","model_id":"IBEACON","type":"BCON","mfid":"4c00","uuid":"655f83caae16a10a702e31f30d58dd82","major":-2703,"minor":0,"volt":8.7}

It looks to me that Volt 8.7 is actually the battery percentage (87%)

Indeed, but this Ibeacon message should not be taken by the HA entity due to this function in the value template:

value_json.uuid is not defined

Which version of HA are you running ?

Aha! Iā€™m on 2022.11.5

I have been postponing an update as I have a large amount of -platform:mqtt entries.

Maybe due to your HA version as you seem to be the only one getting this issue

Thanks, I have updated now, will report back if it re-occurs.

Anybody?

Iā€™m happy to try OMG but Iā€™d rather keep all my devices on one platform.

Iā€™m not sure how you define ā€˜all my devices on one platformā€™. However from my experience with bluetooth on various platforms and configs, I would recommend abstracting the bluetooth ā€˜centralā€™ function away from being on the same box as Home Assistant. While HA folks have done good work to make bluetooth on various versions of Linux more robust, it is just too easy for the bluetooth adapter to get into weird/non-working states. Bluetooth is an amazing platform, however it is a moving target for OS developers to keep all of itā€™s possible configurations running, and wow it has many configurations. The various ESP32 bluetooth ā€˜centralā€™ (aka device that translates some form of Home Assistant API to a conversation with one or more bluetooth devices) are pretty good cost/complexity/functionality path. That said, I still have a very old Raspberry Pi 3 running a frozen in time version of Linux (and bluetooth stack), for one of these ā€˜centralā€™ functions in my mix, because ā€˜it just worksā€™. Good hunting.

On a side note, the BMx family of battery monitoring devices in an interesting thing. The BM2 seems to be the simplest to start with, however from what I can tell all BMx devices are exactly the same hardware as the BM2. For the most part, again from what I can glean, they just changed the bluetooth encryption key in devices after the BM2, after someone did an amazing job of reverse engineering the encryption keys out of an android app. If you are up for a little adventrure, the BM2 and I think BM6 at least can be reflashed with custom firmware that gives you full control over the advertising data, adds access to motions data.

I use ESPHome and bluetooth proxies around my house so where possible Iā€™d rather have something which can send out standard BLE announcements and be handled by ESPHome than needing to add OMG or similar into the mix - thatā€™s nothing against OMG, I just like the ā€œsingle pane of glassā€ view of my ESP devices that ESPHome provides.

Good to know about reflashing the BM2 - that might be an option.

I am however almost certain somebody came up with an ESPHome config which was able to recieve/decrypt the BM2 packets otherwise I had the weirdest dream (I love tech but not enough to dream about something like this :smiley: )

1 Like

I used the config posted by sew999. Iā€™ll draw attention to a few points that hung me up:

Iā€™m pretty sure this is the include.h in question.

The arduino part in this section is important otherwise it wonā€™t compile properly:

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

I had been attempting to re-purpose an ESP32 dev board that I had initially flashed with ESPHome Bluetooth Proxy. I fought with this on and off for what feels like months and finally it hit me to try and comment out the BT Proxy business:

#packages:
#  esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/esp32-generic.yaml@main

And both the BM2 as well as another Otodata propane tank monitor I couldnā€™t get working started reporting data to Home Assistant. I canā€™t say an ESP32 canā€™t do both BT Proxy and these other esp32_ble_tracker / ble_client roles, but that seemed to be causing a conflict for me in some way.

DaBer

1 Like

Which Battery monitor are you using and which ā€œtypeā€ do you have it configured as? Iā€™m attempting this path and canā€™t seem to get it working 100%.

1 Like

Finally a bit time to follow-up on this. Erased, board information:
grafik

Flashed with esp32dev-ble again (probably for the 15th time):

Now I finally see the OMG Wi-Fi. Unfortunately it times out after a while so I only can enter the Wi-Fi password. Once it connected to my Wi-Fi I want to configure the remaining parts (especially MQTT).

But when accessing the web interface, Iā€™m asked to provide a username and password. What are those? Tried everything I could find especially from Wifi and MQTT configuration | OpenMQTTGateway v1.6.0, but no luck.

TBH this is really not the best onboarding experience I have so farā€¦ looking forward to finally get things working! Never had such trouble with all my other ESPs, no matter if with ESPHome, Bluetooth Proxy or other custom images like Nuki Hub etc.

Hope this helps :wink:

Indeed it does, but meanwhile I found it here: OpenMQTTGateway v1.6.0 released : r/esp32 (reddit.com) admin/OTAPASSWORD.

And how to change those authentication information? Of course I donā€™t want to keep those defaults.
Answered that too: needed to long press the reset button. Can only be set on the initial setup screen (a design failure in my eyes).

Obviously you didnā€™t have the best experience, especially with your initial

(probably for the 15th time)

which Iā€™m not sure what caused this for you, and with which OS, browser and driver.

Or through custom environment builds. But as an open source project we are listening to user suggestions for improvement and are also taking submitted improvement pull request and feature requests into consideration.

The result from your posts is that we are looking into adding changing the WebUI login credentials from within the WebUI in a future update.

1 Like

Now finally: Iā€™ve setup OMG. It discovered my Mi Scale at first which is shown on the web interface (and being auto-discovered by HA already). Now I relocated OMG next to the BM2. While it is discovered according to console:

N: Send on /BTtoMQTT/XXXXXXXXXXXX msg {"id":"XX:XX:XX:XX:XX:XX","name":"ZX-1689","rssi":-82,"txpower":0}

thereā€™s no auto-discovery, no entities are created in HA - nothing in MQTT.
- Can OMG only catch one sensor at a time?
- Do I need to configure anything else?
Please note my HA Core version is 2023.3.6.

Also seeing this on the console:

N: Send on /BTtoMQTT/XXXXXXXXXXXX msg {"id":"XX:XX:XX:XX:XX:XX","name":"ZX-1689","rssi":-87,"txpower":0,"brand":"GENERIC","model":"iBeacon","model_id":"IBEACON","type":"BCON","mfid":"yyyy","uuid":"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy","major":-2495,"minor":20865,"volt":10}

You really are having a lucky dip here today with OpenMQTTGatway!

Anything which could and might go not the expected way seems to be coming your way :frowning:

I have just read up on this new, personally never before heard, name "ZX-1689", which apparently is only being used for BM2 battery monitors being distributed in Germany. Is that where you are located?

Not knowing if it this BM2 variant might also be using differently encoded device information, would you be able to set Advertisement and Advanced Data to true, which is also available as a switch in your HA OpenMQTTGateway settings, and give another sample data again?

If the decoding is the same as all the other BM2 models and only the broadcast name is different we can have a build ready for you in a few hours which also includes this German variant.

I will look into this asap. I spent more than enough hours today for this, hope to turn back shortly with the requested information.

For now: ā€œZX-1689ā€ seems to be (hopefully!) just a variant of the BM2, distributed by PEARL and labeled with Lescars (which I think originally is a French company?) mainly in Germany (Lescars Kfz-Batterie-WƤchter mit Bluetooth und App, fĆ¼r 12-Volt-Batterien).

Oh yes, Pearl love re-branding devices :wink:

Looking forward to your future sample data with the advertising data turned on, so we can verify if the data encoding is hopefully the same.

Can you work with that output?

N: Send on /BTtoMQTT/XXXXXXXXXXXX msg {"id":"XX:XX:XX:XX:XX:XX","mac_type":0,"adv_type":0,"name":"ZX-1689","manufacturerdata":"4c000215655f83caae16a10a702e31f30d58dd82f641518164","rssi":-83,"txpower":0,"distance":12.61001,"brand":"GENERIC","model":"iBeacon","model_id":"IBEACON","type":"BCON","mfid":"4c00","uuid":"XX5f83caXX16a1XX702eXXf30XX8ddXX","major":-2495,"minor":20865,"volt":10}

I donā€™t know if uuid is potentially sensitive too so I masked it partially.