Skip to main content

GitHub Release Python Version License

Aiobmsble

Requires Python 3 and uses asyncio and Bleak

Asynchronous Library to Query Battery Management Systems via Bluetooth LE

This library is intended to query data from battery management systems that use Bluetooth LE. Stand-alone usage is possible in any Python environment (with necessary dependencies installed). It is developed to support BMS_BLE-HA integration that was written to make BMS data available to Home Assistant, but can be hopefully useful for other use-cases as well.

Features

  • Support for autodetecting compatible BLE BMSs
  • 50+ different protocol variants
  • Automatic detection of compatible BLE write mode
  • Asynchronous operation using asyncio
  • Any number of batteries in parallel
  • 100% test coverage plus fuzz tests for BLE data

[!CAUTION] This library shall not be used for safety relevant operations! The correctness or availability of data cannot be guaranteed (see warranty section of the license), since the implementation is mostly based on openly available information or non-validated vendor specifications. Further, issues with the Bluetooth connection, e.g. disturbances, can lead to unavailable or incorrect values.

Do not rely on the values to control actions that prevent battery damage, overheating (fire), or similar.

Supported Devices

The list of supported devices is maintained in the repository of the related Home Assistant integration. For details about the supported data per BMS, please have a look at BMS data table:

  • A means that the field is directly available from the BMS.
  • A . means that the field is not natively available, but all required fields for its calculation are available.
  • Empty means that the field is not available at all.

API documentation

The project uses pdoc to generate the API documentation. You can generate it locally using the installation for development and then running the command

pdoc 'aiobmsble' '!aiobmsble.bms' -o docs

which will generate the documentation locally in the /docs folder.

Usage

In order to identify all devices that are reachable and supported by the library, simply run

aiobmsble

from the command line after installation.

aiobmsble --json '{"local_name": "dummy"}'

returns the BMS type using the JSON advertisement data, e.g. from Home Assistant Bluetooth Advertisement Monitor.

From your Python code

In case you need a reference to include the code into your library, please see __main__.py.

From a Script

This example can also be found as an example in the respective folder.

"""Example of using the aiobmsble library to find a BLE device by name and print its sensor data.

Project: aiobmsble, https://pypi.org/p/aiobmsble/
License: Apache-2.0, http://www.apache.org/licenses/
"""

import asyncio
import logging
from typing import Final

from bleak import BleakScanner
from bleak.backends.device import BLEDevice
from bleak.exc import BleakError

from aiobmsble import BMSSample
from aiobmsble.bms.dummy_bms import BMS  # TODO: use the right BMS class for your device

NAME: Final[str] = "BT Device Name"  # TODO: replace with the name of your BLE device

# Configure logging
logging.basicConfig(level=logging.INFO)
logger: logging.Logger = logging.getLogger(__name__)


async def main(dev_name: str) -> None:
    """Find a BLE device by name and update its sensor data."""

    device: BLEDevice | None = await BleakScanner.find_device_by_name(dev_name)
    if device is None:
        logger.error("Device '%s' not found.", dev_name)
        return

    logger.info("Found device: %s (%s)", device.name, device.address)
    try:
        async with BMS(ble_device=device) as bms:
            logger.info("Updating BMS data...")
            data: BMSSample = await bms.async_update()
            logger.info("BMS data: %s", repr(data).replace(", ", ",\n\t"))
    except BleakError as exc:
        logger.error("Failed to update BMS: %s", type(exc).__name__)


if __name__ == "__main__":
    asyncio.run(main(NAME))  # pragma: no cover

Testing

For integration tests (using pytest) the library provides advertisement data that can be used to verify detection of BMSs. For your tests you can use

from aiobmsble.test_data import bms_advertisements

def test_advertisements() -> None:
    """Run some tests with the advertisements"""
    for advertisement, bms_type, _comments in bms_advertisements():
        ...

Installation

Install python and pip if you have not already, then run:

pip3 install pip --upgrade
pip3 install wheel

For Production:

pip3 install aiobmsble

This will install the latest library release and all of it's python dependencies.

For Development:

git clone https://github.com/patman15/aiobmsble.git
cd aiobmsble
pip3 install -e .[dev]

This gives you the latest library code from the main branch.

Troubleshooting

In case you have problems with the library, please enable debug logging. You can also run aiobmsble -v from the command line in order to query all known BMS that are reachable.

In case you have troubles you'd like to have help with

  • please record a debug log using aiobmsble -v -l debug.log,
  • open an issue with a good description of what your question/issue is and attach the log, or
  • open a bug if you think the behaviour you see is misbehaviour of the library, including a good description of what happened, your expectations,
  • and put the debug.log as attachment to the issue.

Thanks to

@gkathan, @downset, @gerritb, @Goaheadz, @alros100, @majonessyltetoy, @snipah, @Gruni22, @azisto, @BikeAtor, @Karatzie, @PG248, @SkeLLLa,@romanshypovskyi, @riogrande75, @ebagnoli, @andreas-bulling, @goblinmaks, @andreitoma-github, @hacsler, @ViPeR5000, @edelstahlratte, @nezra, @Fandu21, @rubenclark74, @geierwally1978, @Tulexcorp, @oliviercommelarbre, @shaf, @gavrilov, @SOLAR-RAIDER, @prodisz, @thecodingmax, @daubman, @krahabb, @ardeus-ua, @GlennDC, @hhgerhard-google, @crotwell, @dschenzer, @randyoo, @wilcox97, @darrenjackson72, @nostroff, @ppvadmin @admlaz, @ryanalden, @hflocki, @danilos2k, @hlathome, @MartinusTech, @vtacquet, @pwbpease

for helping with making the library better.

References

Release files for aiobmsble 0.29.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiobmsble 0.29.0
File Size Uploaded
aiobmsble-0.29.0.tar.gz 247.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiobmsble 0.29.0
File Interpreter ABI Platform
aiobmsble-0.29.0-py3-none-any.whl Python 3 none any Details

Total release size:418.0 kB

Release files / aiobmsble-0.29.0.tar.gz

Download URL aiobmsble-0.29.0.tar.gz
Size 247.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c36798809295afbaf9dd47d827e3bd05a09f1300aa06d0445be8bdb1909dd055
BLAKE2b-256 checksum
How to use checksums
4e1064f75929fa45169da955331a81618039a7b797873752df2d7e1176097d40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / aiobmsble-0.29.0-py3-none-any.whl

Download URL aiobmsble-0.29.0-py3-none-any.whl
Size 170.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbb7a1d1b9c64fe55d5b876fd7e0c0b4568984d040f6826d844e3bccef16b41f
BLAKE2b-256 checksum
How to use checksums
e624d731bdf54c0f2d329fb77e0be9986cf50e6e9ce4fa8643df19183e2cbeb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.29.0 This release

2 release files

0.28.0

2 release files

0.24.0

2 release files

0.23.0

2 release files

0.21.0

2 release files

0.19.2

2 release files

0.19.1

2 release files

0.18.1

2 release files

0.18.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.2

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.12.1

2 release files

0.11.0

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.7.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page