Skip to main content

Li Time Bluetooth battery reader via BLE (Python, Bleak)

Project description

litime-ble

Lightweight Python library and CLI to read Li-Time BLE battery statistics via Bluetooth Low Energy.

New in 0.2.0: Device discovery, enhanced logging, comprehensive examples, and CLI module support.

Install

pip install litime-ble

Or install from source:

pip install .

Quick start

Device Discovery

Find your Li-Time battery automatically:

from litime_ble import find_litime_batteries_sync

batteries = find_litime_batteries_sync(timeout=5.0)
if batteries:
    mac_address = batteries[0]['address']
    print(f"Found battery: {mac_address}")

Battery Reading

from litime_ble import BatteryClient

# Synchronous (simple)
with BatteryClient.sync(address="C8:47:80:15:5C:0F") as client:
    status = client.read_once()
    print(f"Battery: {status.voltage_v:.1f}V, {status.soc_percent:.0f}%")
    print(status.json())  # Full data as JSON

# Asynchronous (recommended)
import asyncio
from litime_ble import BatteryClient

async def read_battery():
    client = BatteryClient(address="C8:47:80:15:5C:0F")
    async with client.session():
        status = await client.read_once_async()
        return status

status = asyncio.run(read_battery())

CLI

# Discover batteries
python -m litime_ble discover --battery-only

# Read battery status
python -m litime_ble read --address C8:47:80:15:5C:0F --json

# Or use the installed command
litime-battery read --address C8:47:80:15:5C:0F --json

Documentation & Examples

Developer

Quick test:

# PowerShell
$env:PYTHONPATH = (Resolve-Path src).Path; python -m pytest -q

# macOS/Linux
PYTHONPATH=$(pwd)/src python -m pytest -q

Code quality:

ruff check src --fix

License

This project is licensed under the MIT License.
It follows the same license as the original codebase it was based on: litime-bluetooth-battery.

Copyright (c) 2025 Konnexio Inc.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litime_ble-0.2.2.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litime_ble-0.2.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file litime_ble-0.2.2.tar.gz.

File metadata

  • Download URL: litime_ble-0.2.2.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for litime_ble-0.2.2.tar.gz
Algorithm Hash digest
SHA256 0dcb3ef634a13b68f9456a0f31aba344c4fec4b52e85b074ae3b3f43e6c77e33
MD5 8c6dcdd4d14e896dd9fae6ea041f7bff
BLAKE2b-256 ce5c7fcd65c7c71d275e06556bb156dbbe915a634961d37e184be7b6e0e58d10

See more details on using hashes here.

Provenance

The following attestation bundles were made for litime_ble-0.2.2.tar.gz:

Publisher: publish-pypi.yml on konnexio-inc/litime-ble

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file litime_ble-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: litime_ble-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for litime_ble-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 813114429e3b24ce7eac58fcddd9a826aa8fcd6483ab9bbb46a0165894d44c61
MD5 99e7d96568db36f778e168e4cd6993f6
BLAKE2b-256 0b941ad22acda9495cc25ee59aeede7f28978deba733776c188291ca355a1933

See more details on using hashes here.

Provenance

The following attestation bundles were made for litime_ble-0.2.2-py3-none-any.whl:

Publisher: publish-pypi.yml on konnexio-inc/litime-ble

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page