dlms-cosem
A Python library for DLMS/COSEM
What it is and what it does
dlms-cosem is a Python client library for the DLMS/COSEM protocol, which is the international standard for smart meter communication. It provides low-level protocol handling—APDU encoding and decoding, encryption/decryption, and session state management—so you can read and write data on energy meters. The library implements a sans-io design, meaning the protocol logic is separate from I/O, but ships with a blocking client for serial (HDLC) and TCP transports. It supports authentication methods including HLS-GMAC, LLS, and HLS-Common, as well as global ciphering for encrypted communication.
You use it by composing a transport (TCP or serial), an authentication method, and a DlmsClient, then call methods like get(), set(), and action() to interact with meter attributes. The library is designed for reading invocation counters, energy consumption data, and other meter-specific attributes defined by OBIS codes. It has been tested on several real meters (Iskraemeco AM550, Itron SL7000, Hexing HXF300, and others) and is actively maintained, though it does not yet support building a full meter emulator.
Use it for:
- Read energy consumption data from smart meters in production networks using IDIS or DSMR standards.
- Implement automated meter reading (AMR) systems that poll multiple meters over TCP or serial connections.
- Develop meter integration layers for distribution service operators (DSOs) with manufacturer-specific meter configurations.
- Test and debug DLMS/COSEM protocol communication with meters or test servers in development environments.
- Build non-commercial research or educational tools for studying smart meter protocols and data models.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Python library for implementing DLMS/COSEM protocol clients to read and write data on energy meters over serial or TCP connections, handling protocol state management, APDU encoding/decoding, and encryption.
Yes, if you need to communicate with DLMS/COSEM meters and accept the Business Source License restrictions. The library is actively maintained, has low install friction, no known vulnerabilities, and provides a well-structured sans-io implementation. However, verify that the license permits your use case (commercial meter reading is restricted unless you contact the maintainer) and that your target meters are supported or compatible with the library's abstraction layer.
Install
dlms-cosem on PyPI
pip
pip install dlms-cosemuv
uv add dlms-cosempoetry
poetry add dlms-cosemInstalling dlms-cosem
Before you install
Low friction installation with a pure-Python wheel and seven common dependencies. The library is actively maintained with recent releases and no known vulnerabilities, though it has been 506 days since the latest release.
License in practice
Licensed under Business Source License 1.1 (not fully open source), which permits internal use, non-commercial education, and research but restricts competing commercial uses. Will eventually transition to Apache License 2.0; contact the maintainer for alternative licensing.
Quickstart
pip install dlms-cosem
from dlms_cosem.client import DlmsClient
from dlms_cosem.io import BlockingTcpIO, TcpTransport
from dlms_cosem.security import NoSecurityAuthentication
tcp_io = BlockingTcpIO(host="localhost", port=4059)
transport = TcpTransport(io=tcp_io, server_logical_address=1, client_logical_address=16)
client = DlmsClient(transport=transport, authentication=NoSecurityAuthentication())
Requires a DLMS/COSEM-enabled meter or server accessible over TCP or serial connection; blocking I/O model means synchronous operations only.
Verify before relying
- Whether the library supports all DLMS/COSEM companion standards (DSMR, IDIS, UNI/TS 11291) equally or if meter-specific quirks require custom code.
- Performance characteristics and scalability limits for concurrent meter connections or high-frequency polling.
- Current state of server/meter emulator support beyond the stated lack of full implementation.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (~=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — attrs, pyserial, cryptography, asn1crypto, python-dateutil, typing-extensions, structlog |
| Maintenance | actively maintained — 506 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 84,187/month — #14,021 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dlms_cosem-25.1.0-py3-none-any.whl
Keywords: AMR, Metering, smart meters, MDM, dlms, cosem
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pysmlReads and parses Smart Message Language (SML)…
permissive · top 15,000 on PyPI
dsmr-parserParses Dutch Smart Meter Requirements (DSMR)…
permissive · top 15,000 on PyPI
pydiscovergyAsynchronous Python client for querying…
permissive · top 15,000 on PyPI
p1monitorAsynchronous Python client library for reading…
permissive · top 15,000 on PyPI
pysmaConnects to SMA solar inverters via their…
permissive · top 15,000 on PyPI
ovoenergyA Python client library for querying energy…
permissive · top 15,000 on PyPI
openmeterOpenMeter Python SDK provides a client library…
permissive · top 15,000 on PyPI
greeneye_monitorParses and processes binary data packets from…
permissive · top 15,000 on PyPI
python-homewizard-energyAsyncio client library for communicating with…
permissive · top 15,000 on PyPI
pyTibberPython library for querying Tibber's…
copyleft · top 15,000 on PyPI