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

Yep, that worked, HA found it & created a new device:
Screenshot 2023-05-05 at 08.59.45

And I see the volt sensor entity too:
Screenshot 2023-05-05 at 08.59.34

So (to my untrained eye) all things are pointing to the ESP32 not sending those messages to the broker. We know the BM2 itself is working, as I can see the values in the android app, so it has to be the ESP32 module :thinking:

Iirc from the docs, it says something about sensors might not send data if they’re paired. So I’ve made sure to remove the device from the android app, however when I flash the module I do see this on my Mac:
Screenshot 2023-05-05 at 09.05.26

I wonder if it really means paired?

I also installed a BLE scanner on my phone, & saw it thinks it’s an iBeacon device:

I’m not sure if it means anything specifically, however I see the iBeacon Tracker integration in HA, but there are no devices or entities associated with it, & nothing to configure :man_shrugging:

Lastly (for now) when I look in the home/OpenMQTTGateway_Garage/SYStoMQTT topic, I see this about the module:

{
   "uptime":2144,
   "version":"v1.5.1",
   "discovery":true,
   "env":"esp32-olimex-gtw-ble-wifi",
   "freemem":102236,
   "mqttport":"1883",
   "mqttsecure":false,
   "tempc":57.22222,
   "freestack":1760,
   "rssi":-46,
   "SSID":"DF_MESH",
   "BSSID":"D8:32:14:D7:23:A2",
   "ip":"192.168.0.180",
   "mac":"24:4C:AB:05:26:80",
   "lowpowermode":-1,
   "interval":55555,
   "intervalcnct":2280000,
   "scnct":31,
   "modules":[
      "BT"
   ]
}

Is "lowpowermode":-1 correct?

Maybe the message format is different to what’s being checked for? Would it help if I pushed the messages to a public Mosquitto broker so you can see everything first hand?

The sensor should not be connected to any other device to be discoverable, so you should kill the mobile app and all other connection to it

As you got this:

{
   "id":"94:A9:A8:3A:FE:12",
   "mac_type":0,
   "adv_type":0,
   "name":"Battery Monitor",
   "manufacturerdata":"4c000215655f83caae16a10a702e31f30d58dd82f471000047",
   "rssi":-68,
   "txpower":0,
   "brand":"GENERIC",
   "model":"BM2 Battery Monitor",
   "model_id":"BM2",
   "type":"BATT",
   "acts":true,
   "batt":71
}

It means that the gateway was reading data before. Try to deactivate your devices Bluetooth and check the broker to see if this message comes back
You should look at:

home/OpenMQTTGateway_Garage/BTtoMQTT/94A9A83AFE12

Yes this is correct

1 Like

So I removed the manually added sensor message from earlier, turned off Bluetooth on my Mac & Android phone, & in that topic I now see the same type of message as you posted above :white_check_mark:

When I watch the topic, the message fluctuates from showing the batt value & sometimes it just show this:

{
   "id":"94:A9:A8:3A:FE:12",
   "mac_type":0,
   "adv_type":0,
   "name":"Battery Monitor",
   "manufacturerdata":"b7e3c0516d2cbc4a897da343f5a87dd4",
   "rssi":-68,
   "txpower":0
}

I guess that’s expected too?

I definitely don’t see anything for 94A9A83AFE12 in here though

I’m lost on what to do next, as it should just work, right?

Yes not all messages can be decoded as some are encrypted

Restart the board so that it will launch an autodiscovery and you should see this populated unless there is a config error on your board. Which binary/configuration did you use for the upload?

I tried both the SYS: Restart gateway control in HA, as well as power off/on by taking the power cable out of the board, but sadly still nothing in that topic :frowning_face:

This one: esp32-olimex-gtw-ble-wifiI could try esp32-olimex-gtw-ble-eth instead maybe?

Flashed via: (Option 1) Upload from the web | OpenMQTTGateway v1.7.0 → should I try the ESP tool instead maybe?

OK, we have success!! :partying_face:

I just upgraded HA to 2023.5.1, restarted the board, & now I’m seeing this in homeassistant/sensor/

Screenshot 2023-05-05 at 16.46.30

And this in the HA UI:

Must have been something in the 2023.5 code :+1:

Thank you so much for all your help so far @1technophile , really appreciate it :star2:

And now I have the dashboard available in the HA companion app, which was my 1st goal when I started this little project :partying_face:

4 Likes

With pleasure, glad to see it working!

1 Like

hi, did you have to do anything to get the volt value?
i’m getting to the step where the sensor is in my devices, but volt is always unknown. the mqtt explorer shows some messages with volt, but the auto generated config seems to ignore volt values when the uuid is valid?

{"id":"90:E2:02:35:84:7C","rssi":-98,"brand":"GENERIC","model":"iBeacon","model_id":"IBEACON","mfid":"4c00","uuid":"655f83caae16a10a702e31f30d58dd82","major":-2495,"minor":21041,"volt":10}
{"stat_t":"+/+/BTtoMQTT/90E20235847C","dev_cla":"voltage","unit_of_meas":"V","name":"volt","uniq_id":"90E20235847C-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":["90E20235847C"],"connections":[["mac","90E20235847C"]],"manufacturer":"Generic","model":"BM2","name":"BM2-35847C","via_device":"OpenMQTTGateway_ESP32_BLE"}}

Thanks
Rico

Looking at battery voltage monitoring for 2 old cars, but confused which way I should go. I have spare esp32 with voltage sensors, or I can go for BM2 devices.

If using a BLE proxy, I suspect I’ll be getting the same data and not sure which way would be better.

I have more wifi coverage on my property so getting the esp32 data over wifi probably would be easier, but they’ll be in the garage most of the time so a esp32 ble proxy in the garage seems logical also.

Just wanted to say thanks for the BM2 support. OpenMQTTGateway is working great!

2 Likes

Did I imagine that someone built a custom ESPHome integration for the BM2 battery monitors? I’m sure I saw it either here or on Reddit, ordred a BM2 and now can’t find the thread.

1 Like

Big thumbs up from Australia, got two BM2 running through OMG 4x4 & the jetski Thanks so much :+1:t3:

2 Likes

I ended up using batmon

1 Like

@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