aiobmsble


Nameaiobmsble JSON
Version 0.2.3 PyPI version JSON
download
home_pageNone
SummaryAsynchronous Python library to query battery management systems via Bluetooth Low Energy.
upload_time2025-09-07 05:57:33
maintainerPatrick Loschmidt
docs_urlNone
authorPatrick Loschmidt
requires_python>=3.12
licenseNone
keywords bms ble battery bluetooth
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![License][license-shield]](LICENSE)

# Aiobmsble
Requires Python 3 and uses [asyncio](https://pypi.org/project/asyncio/) and [bleak](https://pypi.org/project/bleak/)
> [!IMPORTANT]
> At the moment the library is under development and there might be missing functionality compared to the [BMS_BLE-HA integration](https://github.com/patman15/BMS_BLE-HA/)!
> Please do not (yet) report missing BMS support or bugs here. Instead please raise an issue at the integration till the library reached at least development status *beta*.

## 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. It is developed to support [BMS_BLE-HA integration](https://github.com/patman15/BMS_BLE-HA/) that was written to make BMS data available to Home Assistant. While the integration depends on Home Assistant, this library can be used stand-alone in any Python environment (with necessary dependencies installed).

## Usage
In order to identify all devices that are reachable and supported by the library, simply run
```bash
aiobmsble
```
from the command line after [installation](#installation). In case you need the code as reference, please see [\_\_main\_\_.py](/aiobmsble/__main__.py).

### From a Script
This example can also be found as an [example](/examples/minimal.py) in the respective [folder](/main/examples).
```python
"""Example of using the aiobmsble library to find a BLE device by name and print its senosr data."""

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  # use the right BMS class for your device

NAME: Final[str] = "BT Device Name"  # 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) -> 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)
    bms = BMS(ble_device=device, reconnect=True)
    try:
        logger.info("Updating BMS data...")
        data: BMSsample = await bms.async_update()
        logger.info("BMS data: %s", repr(data).replace(", ", ",\n\t"))
    except BleakError as ex:
        logger.error("Failed to update BMS: %s", type(ex).__name__)


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

## Installation
Install python and pip if you have not already, then run:
```bash
pip3 install pip --upgrade
pip3 install wheel
```

### For Production:

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

### For Development:
```bash
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.

[license-shield]: https://img.shields.io/github/license/patman15/aiobmsble.svg?style=for-the-badge&cacheSeconds=86400

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "aiobmsble",
    "maintainer": "Patrick Loschmidt",
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "BMS, BLE, battery, bluetooth",
    "author": "Patrick Loschmidt",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/2a/7a/6b13d96715c6c1a936d35ed3cd6d2a397cd4b5e1e514832a611bbdb2845f/aiobmsble-0.2.3.tar.gz",
    "platform": null,
    "description": "[![License][license-shield]](LICENSE)\n\n# Aiobmsble\nRequires Python 3 and uses [asyncio](https://pypi.org/project/asyncio/) and [bleak](https://pypi.org/project/bleak/)\n> [!IMPORTANT]\n> At the moment the library is under development and there might be missing functionality compared to the [BMS_BLE-HA integration](https://github.com/patman15/BMS_BLE-HA/)!\n> Please do not (yet) report missing BMS support or bugs here. Instead please raise an issue at the integration till the library reached at least development status *beta*.\n\n## Asynchronous Library to Query Battery Management Systems via Bluetooth LE\nThis library is intended to query data from battery management systems that use Bluetooth LE. It is developed to support [BMS_BLE-HA integration](https://github.com/patman15/BMS_BLE-HA/) that was written to make BMS data available to Home Assistant. While the integration depends on Home Assistant, this library can be used stand-alone in any Python environment (with necessary dependencies installed).\n\n## Usage\nIn order to identify all devices that are reachable and supported by the library, simply run\n```bash\naiobmsble\n```\nfrom the command line after [installation](#installation). In case you need the code as reference, please see [\\_\\_main\\_\\_.py](/aiobmsble/__main__.py).\n\n### From a Script\nThis example can also be found as an [example](/examples/minimal.py) in the respective [folder](/main/examples).\n```python\n\"\"\"Example of using the aiobmsble library to find a BLE device by name and print its senosr data.\"\"\"\n\nimport asyncio\nimport logging\nfrom typing import Final\n\nfrom bleak import BleakScanner\nfrom bleak.backends.device import BLEDevice\nfrom bleak.exc import BleakError\n\nfrom aiobmsble import BMSsample\nfrom aiobmsble.bms.dummy_bms import BMS  # use the right BMS class for your device\n\nNAME: Final[str] = \"BT Device Name\"  # Replace with the name of your BLE device\n\n# Configure logging\nlogging.basicConfig(level=logging.INFO)\nlogger: logging.Logger = logging.getLogger(__name__)\n\n\nasync def main(dev_name) -> None:\n    \"\"\"Find a BLE device by name and update its sensor data.\"\"\"\n\n    device: BLEDevice | None = await BleakScanner.find_device_by_name(dev_name)\n    if device is None:\n        logger.error(\"Device '%s' not found.\", dev_name)\n        return\n\n    logger.info(\"Found device: %s (%s)\", device.name, device.address)\n    bms = BMS(ble_device=device, reconnect=True)\n    try:\n        logger.info(\"Updating BMS data...\")\n        data: BMSsample = await bms.async_update()\n        logger.info(\"BMS data: %s\", repr(data).replace(\", \", \",\\n\\t\"))\n    except BleakError as ex:\n        logger.error(\"Failed to update BMS: %s\", type(ex).__name__)\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main(NAME))  # pragma: no cover\n```\n\n## Installation\nInstall python and pip if you have not already, then run:\n```bash\npip3 install pip --upgrade\npip3 install wheel\n```\n\n### For Production:\n\n```bash\npip3 install aiobmsble\n```\nThis will install the latest library release and all of it's python dependencies.\n\n### For Development:\n```bash\ngit clone https://github.com/patman15/aiobmsble.git\ncd aiobmsble\npip3 install -e .[dev]\n```\nThis gives you the latest library code from the main branch.\n\n[license-shield]: https://img.shields.io/github/license/patman15/aiobmsble.svg?style=for-the-badge&cacheSeconds=86400\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Asynchronous Python library to query battery management systems via Bluetooth Low Energy.",
    "version": "0.2.3",
    "project_urls": {
        "Bug Reports": "https://github.com/patman15/aiobmsble/issues",
        "Documentation": "https://github.com/patman15/aiobmsble/README",
        "Homepage": "https://github.com/patman15/aiobmsble/",
        "Source Code": "https://github.com/patman15/aiobmsble/"
    },
    "split_keywords": [
        "bms",
        " ble",
        " battery",
        " bluetooth"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "aef5f903c744d2f4aa299d865037b4f5a9530c59a386769dca8927acb0808fa5",
                "md5": "c53e4b4db879377bdf7470f1b92847a8",
                "sha256": "d3003e5d2b5bef47a359b1f3678f3a796b1e1fcd55fd503e85ec81b34343df10"
            },
            "downloads": -1,
            "filename": "aiobmsble-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c53e4b4db879377bdf7470f1b92847a8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 75919,
            "upload_time": "2025-09-07T05:57:31",
            "upload_time_iso_8601": "2025-09-07T05:57:31.960267Z",
            "url": "https://files.pythonhosted.org/packages/ae/f5/f903c744d2f4aa299d865037b4f5a9530c59a386769dca8927acb0808fa5/aiobmsble-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2a7a6b13d96715c6c1a936d35ed3cd6d2a397cd4b5e1e514832a611bbdb2845f",
                "md5": "ddfef6064755d58b3ef210d84518f731",
                "sha256": "2bf5bb4098a822fda0952a480516f207d11d4035813aaed43a6adec4ead0bc12"
            },
            "downloads": -1,
            "filename": "aiobmsble-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ddfef6064755d58b3ef210d84518f731",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 54675,
            "upload_time": "2025-09-07T05:57:33",
            "upload_time_iso_8601": "2025-09-07T05:57:33.553474Z",
            "url": "https://files.pythonhosted.org/packages/2a/7a/6b13d96715c6c1a936d35ed3cd6d2a397cd4b5e1e514832a611bbdb2845f/aiobmsble-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-07 05:57:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "patman15",
    "github_project": "aiobmsble",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aiobmsble"
}
        
Elapsed time: 1.37292s