Skip to main content

atorch-ble

A standalone Python parser for the Atorch BLE protocol used by USB/AC/DC power meters such as the J7-C and UC96. The package provides byte-level notification-frame reassembly, packet decoding, and typed dataclasses for measurements, with no Home Assistant dependency so it can be used from any async or sync Python program. This package is consumed by the atorch_ble Home Assistant integration, which declares it as a manifest.json requirement following the Bluetooth-Devices org pattern that keeps raw byte parsing out of HA Core.

Status: v0.1 — initial release, J7-C / packet type 0x03 only.

Installation

pip install atorch-ble

Requires Python 3.12 or newer.

Usage

from atorch_ble import AtorchBleParser, UnsupportedPacketType, UsbMeterReading

# A canonical 36-byte J7-C USB-meter frame (synthetic, derived from the
# documented byte layout). In real use you'd feed the bytes you receive
# from a bleak notification callback.
frame = bytes.fromhex(
    "ff55010300020000007b0001c800000315010f0110001b01020304"
    "000000000000ec0000"
)

parser = AtorchBleParser()
try:
    readings: list[UsbMeterReading] = parser.feed(frame)
except UnsupportedPacketType as exc:
    # Raised for non-J7-C packet types (e.g. DL24/UD18 DC meters).
    print(f"unsupported packet type: 0x{exc.packet_type:02x}")
    readings = []

for r in readings:
    print(f"voltage:     {r.voltage_v} V")
    print(f"current:     {r.current_a} A")
    print(f"capacity:    {r.capacity_mah} mAh")
    print(f"energy:      {r.energy_wh} Wh")
    print(f"D+ / D-:     {r.voltage_dplus_v} V / {r.voltage_dminus_v} V")
    print(f"temperature: {r.temperature_c} C")
    print(f"duration:    {r.duration_s} s")

AtorchBleParser.feed() accepts raw bytes from a single BLE notification callback (zero, partial, one, or multiple frames) and returns the list of fully decoded UsbMeterReading instances. Recoverable decode failures (bad length, magic, direction byte, or checksum mismatch) are swallowed and recorded on parser.error_count / parser.last_error; UnsupportedPacketType is re-raised so callers can surface it to the user.

Supported devices

Device Packet type Status
J7-C 0x03 Confirmed against documented byte layout
UC96 0x03 Same protocol family, untested
DL24 / UD18 0x01–0x02 Detected; raises UnsupportedPacketType

Development

git clone https://github.com/dallanwagz/atorch-ble
cd atorch-ble
pip install -e ".[dev]"
pytest

Quality gates: ruff for lint and formatting, mypy --strict for typing, and pytest with a 95% coverage floor.

License

MIT — see LICENSE.

Metadata

Release files for atorch-ble 0.1.2

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

Source distribution (sdist)

Source distribution for atorch-ble 0.1.2
File Size Uploaded Provenance Actions
atorch_ble-0.1.2.tar.gz 19.8 kB With provenance Details for atorch_ble-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for atorch-ble 0.1.2
File Interpreter ABI Platform Actions
atorch_ble-0.1.2-py3-none-any.whl Python 3 none any Details for atorch_ble-0.1.2-py3-none-any.whl

Total release size: 29.5 kB

Release files / atorch_ble-0.1.2.tar.gz

Download URL atorch_ble-0.1.2.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f66625ba6e25f11e9ccc9083f66c6369c0250b23d233ba58ebf81df606cd953d
BLAKE2b-256 checksum
How to use checksums
b5f41e204a0a1df94910c70317b4af74fbe23dc1b7e319fb207d21c9872c8287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 15, 2026.

Transparency log

Release files / atorch_ble-0.1.2-py3-none-any.whl

Download URL atorch_ble-0.1.2-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96e0a8458e7e170a8453ee38c669679baef7a661cc963645cc55211e932dc72b
BLAKE2b-256 checksum
How to use checksums
b69f649afea8dbd4575686a9bfc820335b389e836ad1bae60bfdbeea81828891
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 15, 2026.

Transparency log

Security for atorch-ble 0.1.2

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for atorch_ble-0.1.2.tar.gz

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 Jun 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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