Yes, they do. Let me know what you are seeing in the MQTT homeassistant
discovery topic
Did you receive and try the ESP32 ?
Hiya @1technophile
I have a BM2 sensor connected to my car battery & an ESP32 loaded with OpenMQTTGateway and am just seeing âBattery %â like this
Also, if it helps, the BM2 message received is like this
{
âstat_tâ: â+/+/BTtoMQTT/94A9A8427243â,
âdev_claâ: âbatteryâ,
âunit_of_measâ: â%â,
ânameâ: âBM2-battâ,
âuniq_idâ: â94A9A8427243-battâ,
âval_tplâ: â{{ value_json.batt | is_defined }}â,
âstate_classâ: âmeasurementâ,
âdeviceâ: {
âidentifiersâ: [
â94A9A8427243â
],
âconnectionsâ: [
[
âmacâ,
â94A9A8427243â
]
],
âmanufacturerâ: âGENERICâ,
âmodelâ: âBM2â,
ânameâ: âBM2 Battery Monitor-427243â,
âvia_deviceâ: âOpenMQTTGateway_ESP32_BLEâ
}
}
I think that the BM2 needs to be paired in Bluetooth to work?
Hope this helps
Steve
Hi @sew999,
The BM2 only has the battery level in its advertising data, so the 100% you are seeing is correctly the only value which can be decoded from this freely available broadcast.
For any other BM2 services you correctly assume that a connection is required, which you might possibly achieve with the OpenMQTTGateway READ command.
Additionally if you expand the BTtoMQTT section under OpenMQTTGateway_ESP_BLE in MQTT Explorer you will see the different devices detected and decoded by OMG, which some or all created the Home Assistant sensor entries.
Hi @e-raser,
Could you also have a look under the BTtoMQTT section for your Mi Scale - when it is on/just been used for weighing. It should definitely show up there, also with its MAC address (âidâ) for entry into Theengs App, and if you copy and past the information from there might show us why the auto-discovery might not have worked correctly.
Hi @DigiH
Bummer⌠I am having battery problems overnight and was hoping to get a remote record of the voltage. I bought this sensor as it said it was supported
Thanks for your helpâŚ
Cheers
Steve
Received: yes, 5 of them in front of me.
Tried: Unfortunately not. Priorities have changed for now (no Smart Home time currently), I hope to be able to test this within the next two weeks.
On my todo list:
- Check Mi Scale autodiscovery
- Test OMG with BM2
Will turn back once I can provide experiences on those.
Hi @DigiH @1technophile
Interestingly, I was trying out the Windows app âBluetooth LE Explorerâ and was able to access a number of different services on the BM2
Well according to GitHub - KrystianD/bm2-battery-monitor: Python MQTT publisher and ESPHome template for Bluetooth based Battery Monitors - reverse engineering. itâll be service_uuid: 0xFFF0 & characteristic_uuid: 0xFFF4
I have been trying to load my ESP32 with his code, but dont think Iâm handling the bm2_mmqt.py file correctly - I dont think its being includedâŚ
I will try this tomorrow and see if I get something
I managed to build an ESP32 in ESPHome last night that worked with this code and returned the voltage reading in mqqt. I put the include.h and secrets.yaml file in the config/esphome directory.
Iâm guessing from the lambda part of the sensor code that the voltage source is encrypted, so does that help with making an update of OpenMQTTGateway, possibly?
esphome:
name: esp32s3
friendly_name: ESP32S3
includes:
- include.h
esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
logger:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
time:
- platform: sntp
id: sntp_time
web_server:
port: 80
mqtt:
broker: 192.168.0.XXX
discovery: false
topic_prefix: esphome/BM2
username: mqtt-user
password: XXXXXXXXX
esp32_ble_tracker:
sensor:
- platform: ble_client
type: characteristic
ble_client_id: bm2_battery_meter
name: Voltage
service_uuid: 'fff0'
characteristic_uuid: 'fff4'
unit_of_measurement: 'V'
accuracy_decimals: 2
state_class: measurement
device_class: voltage
force_update: true
notify: true
lambda: |-
mbedtls_aes_context aes;
mbedtls_aes_init(&aes);
unsigned char output[16];
unsigned char key[16] = { 108, 101, 97, 103, 101, 110, 100, 255, 254, 49, 56, 56, 50, 52, 54, 54, };
unsigned char iv[16] = {};
mbedtls_aes_setkey_dec(&aes, key, 128);
mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_DECRYPT, 16, iv, (uint8_t*)&x[0], output);
mbedtls_aes_free(&aes);
return ((output[2] | (output[1] << 8)) >> 4) / 100.0f;
ble_client:
- mac_address: 94:A9:A8:42:72:43
id: bm2_battery_meter
Working on my side, will be in the next version of OMG.
Wow⌠Great news⌠Thank youâŚ
You guys are amazing. Thanks!
Looking forward to the release. Will have a look at the release notes to grab the right one right from start.
First I will have a test look at the Mi scale (off-topic). Thumbs up for BM2, sounds pretty good so far.
@sew999 @e-raser we need some data to identify properly that the BM2 is a BM2 and not an iBeacon without relying on the name.
Could you upload esp32dev-ble-mqtt-undecoded
from the web upload
And share what you are getting by PM or remove the MAC address from the message (id), should look like this:
{"id":"11:22:33:44:55:66","mac_type":0,"adv_type":0,"name":"Battery Monitor","manufacturerdata":"4c000215655f83caae16a10a702e31f30d58dd82f6444d7164","rssi":-93,"txpower":0,"brand":"GENERIC","model":"BM2 Battery Monitor","model_id":"BM2","type":"BATT","batt":100}
We want to identify a pattern accross the advertisements to identify the BM2 with reliability.
Hiya
I setup an ESP32 with the unencoded profile, but dont see any messages in the format you wanted, I see only this:
{âidâ:â94:A9:A8:42:72:43â,ânameâ:âBattery Monitorâ,ârssiâ:-73,âtxpowerâ:0}