lorawan-connection
Documentation · Building a device library · Home Assistant integration
Backend-neutral LoRaWAN events and device collections for Python 3.12+. No runtime dependencies.
Feed inventory and live events into a vendor DeviceCollection. It creates
supported models and reports them through device-added callbacks. Consumers then
observe model state. The caller owns the network connection.
from lorawan_connection import DeviceCollection, DeviceDescriptor, DeviceEvent
class Sensor:
def __init__(self, descriptor: DeviceDescriptor) -> None:
self.descriptor = descriptor
def handle_event(self, event: DeviceEvent) -> None:
# Interpret events and update typed state here.
pass
def close(self) -> None:
# Release model listeners and other model resources here.
pass
class Sensors(DeviceCollection[Sensor]):
def _create_device(self, descriptor: DeviceDescriptor) -> Sensor | None:
if descriptor.vendor_id == 123 and descriptor.catalog_model_id == "known-model":
return Sensor(descriptor)
return None
sensors = Sensors("my-network")
stop = sensors.subscribe_device_added(lambda device: print(device.descriptor.name))
# Feed all matching events into sensors.handle_event(event).
# Supported devices appear automatically when their inventory events arrive.
Install
pip install lorawan-connection
For development before the first PyPI publication:
git clone https://github.com/home-assistant-libs/lorawan-connection.git
cd lorawan-connection
uv sync --group compatibility
uv run python examples/replay.py
The replay creates a SenseCAP S2101 model and prints 21.4 °C and 31.4% humidity. It uses captured bytes and needs no server or Home Assistant installation.
What ships in 0.1
- Read-only event and payload
Protocols. Generated payloads can pass by reference. - Immutable descriptors and fixture dataclasses for every supported event payload.
- A generic
DeviceCollectionwith inventory replay, model replacement, and retirement. - Synchronous callback helpers with independent, idempotent unsubscribe functions.
- Typed exports (
py.typed), a tested SenseCAP example, and Astro/Starlight documentation.
ChirpStack API helpers belong to the Home Assistant LoRaWAN integration. This
package has no ChirpStack, protobuf, MQTT, or Home Assistant dependency. It does
not open connections, provision devices, parse QR codes, or provide vendor decoders.
The SenseCAP implementation under examples/ illustrates a separate device library.
Events are live notifications. The package does not persist history, reconnect a transport, or request replay after a gap. Providers report inventory before activity. Collections select models from catalog identity, never from names or payload guesses.
Library authors and Home Assistant authors
The Building a library guide covers catalog matching, decoding, partial state, and model subscriptions. It uses no Home Assistant APIs.
The Home Assistant guide covers provider subscriptions, discovery, config-entry lifecycle, and entities that observe library models. The provider API described there exists on the linked Core POC branch; it is not yet an upstream HA API.
Development
uv sync --group compatibility
uv run ruff check .
uv run ruff format --check .
uv run mypy
uv run pytest --cov --cov-report=term-missing
uv run python examples/replay.py
cd docs
npm ci
npm run build
CI tests Python 3.12, 3.13, and 3.14. Compatibility tests check the payload contracts
against chirpstack-api==4.19.0. This is a development dependency only.
The documentation build validates internal links and produces llms.txt.
The repository follows the packaging, documentation, and release approach of
modbus-connection.
The source version stays 0.0.0; the publish workflow sets the version from the
release tag. See releasing for the first PyPI release setup.
Metadata
Release files for lorawan-connection 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lorawan_connection-0.1.0.tar.gz | 31.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lorawan_connection-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.6 kB
Release files / lorawan_connection-0.1.0.tar.gz
| Download URL | lorawan_connection-0.1.0.tar.gz |
|---|---|
| Size | 31.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
346270c2ee307a322c38a122d59e8f9c088d8cc31a8e752b65a87cbd9230407f
|
|
BLAKE2b-256 checksum How to use checksums |
660fb2c6f1b32285c273d3ffa7c468e098bc7e40628e323a7741a46f7a7ae3a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 3, 2026.
Transparency logRelease files / lorawan_connection-0.1.0-py3-none-any.whl
| Download URL | lorawan_connection-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2d6eeacd55d87279d8ba406216fb4eb606daaf6f7cb9a82606053f453df6643
|
|
BLAKE2b-256 checksum How to use checksums |
0f428626ec12a95d82c4b064d72ced402cd7e5c5e4ca943873c68da53c9df27d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 3, 2026.
Transparency log