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
- Documentation - Complete API docs and usage guide
- Examples - Ready-to-run example scripts with CLI options
- Developer Guide - Setup, testing, and contribution guidelines
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55f9b4b3ef77b4bd413a7b30b2c92deb0706ea50cce34645f94161b3cdaf6b68
|
|
| MD5 |
ef7ce4573bda3b09c687794cc9838508
|
|
| BLAKE2b-256 |
faf53d117e7829de99e41d21caa9ebbb40b982c938ecf75edb5fdcf8db60ea80
|
Provenance
The following attestation bundles were made for litime_ble-0.2.1.tar.gz:
Publisher:
publish-pypi.yml on konnexio-inc/litime-ble
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
litime_ble-0.2.1.tar.gz -
Subject digest:
55f9b4b3ef77b4bd413a7b30b2c92deb0706ea50cce34645f94161b3cdaf6b68 - Sigstore transparency entry: 507636157
- Sigstore integration time:
-
Permalink:
konnexio-inc/litime-ble@5cbfb182d3876f73eed31e3bd4e5fff71f24cbab -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/konnexio-inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5cbfb182d3876f73eed31e3bd4e5fff71f24cbab -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f85fab726fbd589d5bf9797165762ff8e651a8d681c8713bb61fb693d71aee00
|
|
| MD5 |
f23d254c2bc54f1cc56ce546b95d60f9
|
|
| BLAKE2b-256 |
5d626fba644fb4e3ebf86cac091a4771f2cec1255ad8f4ca0c2b37dd647740db
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
litime_ble-0.2.1-py3-none-any.whl -
Subject digest:
f85fab726fbd589d5bf9797165762ff8e651a8d681c8713bb61fb693d71aee00 - Sigstore transparency entry: 507636183
- Sigstore integration time:
-
Permalink:
konnexio-inc/litime-ble@5cbfb182d3876f73eed31e3bd4e5fff71f24cbab -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/konnexio-inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5cbfb182d3876f73eed31e3bd4e5fff71f24cbab -
Trigger Event:
push
-
Statement type: