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.1.tar.gz (26.3 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.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litime_ble-0.2.1.tar.gz
  • Upload date:
  • Size: 26.3 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.1.tar.gz
Algorithm Hash digest
SHA256 55f9b4b3ef77b4bd413a7b30b2c92deb0706ea50cce34645f94161b3cdaf6b68
MD5 ef7ce4573bda3b09c687794cc9838508
BLAKE2b-256 faf53d117e7829de99e41d21caa9ebbb40b982c938ecf75edb5fdcf8db60ea80

See more details on using hashes here.

Provenance

The following attestation bundles were made for litime_ble-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: litime_ble-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f85fab726fbd589d5bf9797165762ff8e651a8d681c8713bb61fb693d71aee00
MD5 f23d254c2bc54f1cc56ce546b95d60f9
BLAKE2b-256 5d626fba644fb4e3ebf86cac091a4771f2cec1255ad8f4ca0c2b37dd647740db

See more details on using hashes here.

Provenance

The following attestation bundles were made for litime_ble-0.2.1-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