Dragino LoRaWAN
Read and control Dragino devices through ChirpStack or The Things Stack using
lorawan-connection.
This library powers the Dragino LoRaWAN Home Assistant integration.
| Model | Readings | Commands | Automatic discovery |
|---|---|---|---|
| LT-22222-L | Relays, digital outputs/inputs, voltages, currents, counters, firmware | Set relay, set digital output | ChirpStack, TTS |
| LDS02 | Door state, open alarm, event count, last opening duration, battery | — | ChirpStack, TTS |
| LWL02 | Water leak, alarm, event count, last leak duration, battery | Reporting interval, reset count | ChirpStack, TTS |
| LHT65 | Temperature, humidity, battery, external probe readings | — | TTS |
| CPL03-LB | Single contact/alarm, three pulse counters or contact inputs, durations, battery, firmware | Request device status | ChirpStack, TTS |
Every model also exposes rssi and snr from the strongest gateway reception of
the latest uplink, when the connection reports gateway metadata.
Raw payloads are decoded locally; a server-side payload formatter is not required.
Devices are matched by their catalog identity (ChirpStack vendor 676 or TTS brand
dragino), so custom profiles are not discovered automatically.
Command-line reader
The dragino-lorawan command lists devices or prints readings as they arrive.
Install uv to run it with
uvx, or use pip install "dragino-lorawan[chirpstack]" for ChirpStack and
pip install "dragino-lorawan[tts]" for The Things Stack.
ChirpStack
Use a ChirpStack v4 gRPC endpoint, an API key, and the tenant UUID.
export CHIRPSTACK_API_KEY="your-api-key"
uvx --from "dragino-lorawan[chirpstack]" dragino-lorawan \
--backend chirpstack \
--server https://chirpstack.example.com:8080 \
--tenant YOUR_TENANT_UUID \
--application YOUR_APPLICATION_UUID
The Things Stack
Use the Application Server gRPC endpoint and an application API key with device read and application traffic read rights.
export TTS_API_KEY="your-api-key"
uvx --from "dragino-lorawan[tts]" dragino-lorawan \
--backend tts \
--server https://eu1.cloud.thethings.network:8884 \
--identity-server https://eu1.cloud.thethings.network:8884 \
--application YOUR_APPLICATION_ID
Add --list to print the current devices and exit, or --json for newline-delimited
JSON output. Run dragino-lorawan --help for all options.
python -m dragino_lorawan also works.
Python
from lorawan_connection.backend.chirpstack import ChirpStackConnection
from dragino_lorawan import LT22222, DraginoDevices
async def switch_relay(
endpoint: str, api_key: str, tenant: str, application: str
) -> None:
connection = ChirpStackConnection(
endpoint,
api_key,
tenant_id=tenant,
application_ids=[application],
network_id=endpoint,
)
devices = DraginoDevices(connection)
try:
await connection.async_connect()
await devices.async_setup()
for device in devices.devices.values():
print(device.descriptor.name, device.model_name)
if isinstance(device, LT22222):
await device.async_set_relay(1, True)
finally:
devices.close()
await connection.close()
The collection also accepts a TTSConnection. Subscribe with
devices.subscribe_device_added(listener) and device.add_update_listener(listener)
to receive live readings. Values remain None until the device reports them.
Reading values
Model properties such as LHT65.temperature, LDS02.active, and
LT22222.relays remain available. All models also expose the latest decoded
values and device metadata (such as firmware_version) as dictionaries, and
device.value(name) reads a single value.
Every model has a decode(f_port, data) class method that decodes a raw payload
without a connection and returns a DecodedPayload:
from dragino_lorawan import LHT65
payload = LHT65.decode(2, bytes.fromhex("cbf60b0d0376010add7fff"))
print(payload.values["temperature"], payload.values["external_temperature"])
# 28.29 27.81
Direct decoding raises ValueError for malformed frames. Configuration, datalog,
and other non-measurement frames decode to an empty payload. Live models discard
malformed payloads atomically. Partial updates retain other readings, and older
uplinks cannot replace newer values. Absent or disconnected readings are None.
Downlink commands require an API key with downlink write permission. LT-22222-L relay and digital-output commands wait for acknowledgement; LWL02 and CPL03-LB commands are queued for the device's next receive window.
Development
All payload decoders live in src/dragino_lorawan/decoders.py, with separate
functions for LHT65, LDS02, LWL02, CPL03-LB, and LT-22222-L. Live device
handling remains in device.py, model properties and commands in models.py,
and the shared decoded payload types in payload.py.
uv sync
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv run mypy
uv build
Tests include reference outputs from the vendor JavaScript codecs for every decoder family, and malformed, partial, and out-of-order messages. See fixture provenance and regeneration.
License
Apache-2.0. See NOTICE for attribution.
Metadata
Release files for dragino-lorawan 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 | Provenance | Actions |
|---|---|---|---|---|
| dragino_lorawan-0.1.0.tar.gz | 14.8 kB | With provenance | Details for dragino_lorawan-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dragino_lorawan-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for dragino_lorawan-0.1.0-py3-none-any.whl |
Total release size: 31.8 kB
Release files / dragino_lorawan-0.1.0.tar.gz
| Download URL | dragino_lorawan-0.1.0.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51f6d3a717932553f5433be92e6649a60065715baaabbacaca9bad0ab596640e
|
|
BLAKE2b-256 checksum How to use checksums |
cd1871e82cb64f891883106f1a4e8a08691929372eb1e575ec3218bb8c95631a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 25, 2026.
Transparency logRelease files / dragino_lorawan-0.1.0-py3-none-any.whl
| Download URL | dragino_lorawan-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d71fb3d6c610b4f3fc3f340df21f8caeaaef80565cd3c0c29a51fc8de1369c9
|
|
BLAKE2b-256 checksum How to use checksums |
b0751db26200622ce4ef6be4fc551f1fde42e1ca022d706fb359412399e34e69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 25, 2026.
Transparency logSecurity for dragino-lorawan 0.1.0
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
Both files in this release have been uploaded with provenance metadata.
Attestation for dragino_lorawan-0.1.0.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 Nov 25, 2026.
Transparency logA 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.