New setup - BM2

Hi firstly I am very new to all this, so be gentle :). I have recently got into Home Assistant and bought a M5Stack Atom Lite ESP32 to run OMG (1.8.1) to support a BM2 battery monitor (BLE) I have as I saw that OMG supports that. I have got everything integrated with HA and have whitelisted the BM2. In MQTT Explorer I can see the device:-

HA can only see the GW itself and not the BM2. If I remove the whitelist I see 3 other devices appear in HA under the integration (Tile devices mostly).

I have gone through the documentation, but can’t see what I have missed. Any tips would be appreciated :). Thank you.

Welcome @geekydrewbie

Great that you got everything set up with your M5Stack Atom Lite and white-listing your BM2.

For the BM2 to be correctly integrated we recognise its iBeacon format broadcast and decode the battery level from that, and once recognised wthe gateway also connects to it once every hour to fetch the actual battery voltage.

To see why your BM2 might not be recognised correctly, can you turn ON BT: Publish Advertisement and Advanced Data in your gateway’s Home Assistant UI?

Then copy and past some more messages from your BM2 with the additional raw data included for us to investigate why it might not be correctly decoded and auto-discovered.

1 Like

Thanks @DigiH for the quick reply and kindly offering to help :).

Here is some output from the BM2:-

{
“model”: “BM2 Battery Monitor”,
“id”: “34:14:B5:40:63:C4”,
“volt”: 12.8,
“rssi”: -60
}

{
“id”: “34:14:B5:40:63:C4”,
“mac_type”: 0,
“adv_type”: 0,
“name”: “Battery Monitor”,
“manufacturerdata”: “4c000215655f83caae16a10a702e31f30d58dd82f641000064”,
“rssi”: -60,
“txpower”: 0,
“brand”: “GENERIC”,
“model”: “BM2 Battery Monitor”,
“model_id”: “BM2”,
“type”: “BATT”,
“track”: true,
“batt”: 100,
“device”: “BM2 Tracker”
}

{
“id”: “34:14:B5:40:63:C4”,
“mac_type”: 0,
“adv_type”: 0,
“name”: “Battery Monitor”,
“manufacturerdata”: “1b8814fd8faeee16353519c187ad9537”,
“rssi”: -59,
“txpower”: 0
}

Is that what you were after?

Great, thanks, that is the information I was looking for. As you can see, the broadcasts from the BM2 are not always the same, but your pasted second one is the one we recognise and it is correctly decoded with the proper

“model”: “BM2 Battery Monitor”,
“model_id”: “BM2”,

and battery level

“batt”: 100,

This means that the BM2 should also have been auto-discovered in HA, and you should see it in the devices list of the MQTT integration, from where you can add it to your dashboards.

If it hasn’t been discovered you might have missed the 30 minute discovery window, after which discovery switches itself off again.

Just turn ON SYS: Auto discovery and issue a SYS: Restart gateway. This will then start another 30 minutes disvcovery window during which your BM2 should definitely itely be discovered.

1 Like

Or have a look in MQTT Explorer under the homeassistant topic, to see if the BM2 discovery messages might not already be there - under device_tracker and sensor - voltage and batt.

Thanks @DigiH I have done that and will check on it a bit later (nothing is showing yet):). You mentioned that it will show you the batt level, but will it also provide the volts? That is the value I really want to get :slight_smile:

Yes, as mentioned above, the voltage is retrieved by connection, which defaults to every 60 minutes. You can bring this down by setting BT: Connect interval to a lower value.

Set it to every minute and watch the MQTT messages to see if the voltage is included.

Just keep in mind that connection retrieval does have an impact on the battery itself, so you might not want to always set to every minute as not to affect the battery you are actually trying to monitor by monitoring it very frequently :wink:

BTW, can you see the BM2 discovery entries under the home assistanttopic?

Hi @DigiH no unfortunately nothing yet (and probably as you would expect nothing in HA) :-

Cheers for the tip on the BT: Connect Interval. I was aiming for just once a day to check the voltage and then alert me if under a certain level.

[would reply quicker, but getting exponential wait times before allowing replies …last one was 50mins lol :smiley:]

Unfortunately there have been several spam floodings to the forum, so I think the restrictions have been increased for new users recently.

Without seeing the content of the sub-topic, I suspect the present homeassistant discovery entries to be the ones for the gateway itself.

Can you see the gateway UI in Home Assiatnt? Under the MQTT Ingetragtion, which is required for MQTT auto-discovery?

What do you currently see in the MQTT Integration device list?

Additionally you also want to turn ON BT:publish only sensors, also to only let decoded BM2 broadcasts come through.

Then issuing the above mentioned

Just turn ON SYS: Auto discovery and issue a SYS: Restart gateway

routine will also discover you BM2

I suspected that was the reason :). You are correct the subtopics are indeed the gateway itself.

I can see the Gateway UI in HA:-


and it is listed under the integration:-

I didn’t have the BT:Publish only sensors on, so just enabled that and issued SYS: Auto discovery and a SYS: Restart gateway

Cheers

Hi @DigiH

Just an update, still nothing being seen. I did also install the Theengs app on my phone and that also doesn’t pick anything up when scanning.

Hi @geekydrewbie

The Theengs App does not recognise the BM2 so far, as indicated by the missing tick mark in the last Mobile App column on the Compatible BLE Devices page. So that is expected.

Your issue with having the BM2 auto-discovered in HA is weird though.

Let’s just go through all the required steps again to see if everything is checked off.

• Can you still see messages being received from the BM2 which are being properly decoded as the middle message you posted above, which include

…
“brand”: “GENERIC”,
“model”: “BM2 Battery Monitor”,
“model_id”: “BM2”,
“type”: “BATT”,
“track”: true,
“batt”: 100,
“device”: “BM2 Tracker”
…

• If so the re option and decoding is fine. With these coming in, and you turning ON SYS: Auto discovery and issuing a SYS: Restart gateway, can you then see the uptime stating again from scratch in the SYStoMQTT message of your gateway? This indicates that the restart has been issued properly.

• As soon as you see properly decoded messages coming in from the BM2 again after the restart (with "disc":true also in the SYStoMQTT JSON) it should also be auto-discovered, indicated by the additional device_tracker sub topic under the home assistant topic. Does that not happen at all for you?

Hi @DigiH ,

Ah my bad on the app front :frowning: . Sorry about that.

In MQTT Explorer I can see:-

{
“id”: “34:14:B5:40:63:C4”,
“name”: “Battery Monitor”,
“rssi”: -59,
“txpower”: 0,
“brand”: “GENERIC”,
“model”: “BM2 Battery Monitor”,
“model_id”: “BM2”,
“type”: “BATT”,
“batt”: 100,
“device”: “BM2 Tracker”
}

I have SYS: Auto Discovery on and I have clicked SYS: Restart Gateway


Uptime went down to 4:-
image

I can see “disc”:true:-
image

but no device_tracker :-

Thanks for your help it is very much appreciated :slight_smile:

P.S I do have a white list set:-

My setup is this:-
M5Stack ATOM Lite with 1.8.1 Installed using “esp32-m5atom-lite” via Upload from the web. My Broker is mosquitto

Everything looks fine to me, and a white-list is always a good idea to only receive the devices you want.

And after the restart the first few correctly decoded received messages should also trigger the discovery of the BM2. That is what puzzles me.

You do see these received and decoded messages again after the restart?

Can you put the BT: Connect interval up a bit again, just to see if the connection attempted,pts are messing with the discovery? Just a wild guess, but at this stage best to try it out :wink:

As I do not have a BM2 here myself, I just tested it with another device_tracker device, and it was working as expected for me.

Not exactly sure where the screenshot for “interval”:0 came from, but it should not be 0, best too set to the default 55555, at least for until we can figure out what is causing the non-0discovery.

Which would also require to have BT: Adaptive Scan turned OFF, if it is still on.

Could you also post your complete copied SYStoMQTT and BTtoMQTT JSON?

1 Like

Hi @DigiH. Ok so BT: Connect Interval is back to 60 now and I have turned off BT:Adaptive Scan

SYStoMQTT
{
“uptime”: 244,
“version”: “v1.8.1”,
“rgbb”: 255,
“mqtt”: true,
“serial”: false,
“disc”: true,
“ohdisc”: false,
“env”: “esp32-m5atom-lite”,
“freemem”: 84424,
“mqttp”: “1883”,
“mqtts”: false,
“mqttv”: false,
“msgprc”: 148,
“msgblck”: 0,
“msgrcv”: 148,
“maxq”: 31,
“cnt_index”: 0,
“minmem”: 30532,
“tempc”: 50.56,
“freestck”: 2924,
“powermode”: -1,
“eth”: false,
“rssi”: -55,
“SSID”: “################”,
“BSSID”: “AE:8B:A9:B3:15:F5”,
“ip”: “192.168.254.7”,
“mac”: “90:15:06:F9:97:AC”,
“modules”: [
“WebUI”,
“IR”,
“BT”
]
}

BTtoMQTT
{
“bleconnect”: true,
“interval”: 100,
“adaptivescan”: false,
“intervalacts”: 100,
“intervalcnct”: 3600000,
“scanduration”: 1000,
“hasspresence”: false,
“prestopic”: “presence/”,
“presuseuuid”: false,
“minrssi”: -100,
“extDecoderEnable”: false,
“extDecoderTopic”: “undecoded”,
“pubuuid4topic”: false,
“ignoreWBlist”: false,
“forcepscn”: false,
“tskstck”: 1620,
“crstck”: 3056,
“enabled”: true,
“scnct”: 155,
“onlysensors”: true,
“randommacs”: false,
“filterConnectable”: false,
“pubadvdata”: false,
“presenceawaytimer”: 120000,
“movingtimer”: 60000
}

After a restart of the gateway i can still see :

Now with BT:Adaptive Scan set to OFF, can you adjust the BT: Interval between scans to something around 20 (seconds), the BT: Interval between active scans slider should follow automatically.

Also set BT: Scan duration back to its default 10 (seconds).

Then with SYS: Auto Discovery still/back ON, issue another SYS: Restart Gateway

That BM2 better lets itself be auto-discovered after all that! :stuck_out_tongue_winking_eye: Especially as you are still seeing the correctly decoded BM2 messages.

Thanks @DigiH I have done that, so will see what happens. Nothing so far though lol

It really should be within the first minute or two, after you see the decoded messages coming in.

So still absolutely no 3414B54063C4 entries under any of the home assistant sub topics? :frowning: Not even under sensor?

Other than all the above I really don’t know why it isn’t working for you, and someone else who has a BM2 might have to chip in with their experience with the BM2 and 1.8.1 OMG combo.

@DigiH Yea nothing coming in :(. Really appreciated your help :slight_smile:

Nope nothing under sensors.

Hopefully someone with 1.8.1 and a BM2 will chip in :slight_smile: