skillfed

dlms-cosem

A Python library for DLMS/COSEM

dlms-cosem v25.1.0 84.2K downloads/30d#14,021 on PyPI119
Permissive license MIT Active released

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-cosem

uv

uv add dlms-cosem

poetry

poetry add dlms-cosem

Installing 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

Intended Audience :: DevelopersLicense :: Other/Proprietary LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: CommunicationsTopic :: Software Development :: Libraries :: Python Modules

Tags

dlms cosem energy meter clientsmart meter protocol librarydlms apdu encoding decodingenergy meter communicationhdlc tcp meter readingcosem protocol implementationamr metering data collection
smart-meteringprotocol-implementationenergy-data

More Python Modules packages