Skip to main content

Python bindings for libiec61850 - IEC 61850 protocol implementation

Project description

pyiec61850-ng

This library is experimental. Use at your own risk. No warranty of any kind is provided.

Next Generation Python bindings for libiec61850, packaged as a Python wheel.

Build and Test PyPI version Python Versions

This repository provides Python bindings for the libiec61850 library, which is an open-source implementation of the IEC 61850 standard for communication networks and systems in substations.

Installation

Install from PyPI (Recommended)

pip install pyiec61850-ng

Install from GitHub Release

pip install pyiec61850-ng --find-links https://github.com/f0rw4rd/pyiec61850-ng/releases/latest/download/

Install directly from GitHub

pip install git+https://github.com/f0rw4rd/pyiec61850-ng.git

Install from local wheel

pip install pyiec61850-ng-*.whl

Usage

Quick Start (Recommended - Safe API)

from pyiec61850.mms import MMSClient

# Use context manager for automatic cleanup
with MMSClient() as client:
    client.connect("192.168.1.100", 102)
    print("Connected successfully!")

    # Get server identity
    identity = client.get_server_identity()
    print(f"Server: {identity.vendor} {identity.model}")

    # Discover logical devices
    devices = client.get_logical_devices()
    for device in devices:
        print(f"Device: {device}")

        # Get logical nodes
        nodes = client.get_logical_nodes(device)
        for node in nodes:
            print(f"  Node: {node}")

# Connection automatically closed

Low-Level API

For advanced use cases, you can use the raw bindings directly:

import pyiec61850.pyiec61850 as pyiec61850

# Create and connect to an IEC 61850 server
connection = pyiec61850.IedConnection_create()
error = pyiec61850.IedConnection_connect(connection, "192.168.1.100", 102)

if error == pyiec61850.IED_ERROR_OK:
    print("Connected successfully!")
    # Perform operations...
    pyiec61850.IedConnection_close(connection)

pyiec61850.IedConnection_destroy(connection)

Examples

For comprehensive examples, see the examples directory:

Run examples:

python examples/01_basic_connection.py 192.168.1.100
python examples/02_device_discovery.py 192.168.1.100

Building from Source

The wheel package is built using Docker:

docker build -t pyiec61850-builder --build-arg LIBIEC61850_VERSION=v1.6 .

To extract the wheel file:

mkdir -p ./dist
docker create --name wheel-container pyiec61850-builder
docker cp wheel-container:/wheels/. ./dist/
docker rm wheel-container

Versioning

This package uses the format: LIBIEC61850_VERSION.REVISION

  • Example: 1.6.0.1 = libiec61850 v1.6.0, first package revision
  • 1.6.0: The exact libiec61850 version included (static)
  • .1: Package revision for bug fixes, rebuilds, binding improvements

This clearly shows which libiec61850 version you're getting and our package iteration.

Check current version:

python version.py        # Package version: 1.6.0.1
python version.py --libiec61850  # libiec61850 version: v1.6.0

TASE.2/ICCP Support (Highly Experimental)

Warning: TASE.2 support is highly experimental and may change significantly.

pyiec61850-ng includes support for TASE.2 (IEC 60870-6), also known as ICCP (Inter-Control Center Communications Protocol), used for real-time data exchange between control centers in the electric utility industry.

TASE.2 Quick Start

from pyiec61850.tase2 import TASE2Client

client = TASE2Client(
    local_ap_title="1.1.1.999",
    remote_ap_title="1.1.1.998"
)
client.connect("192.168.1.100", port=102)

# Discover domains (VCC/ICC)
domains = client.get_domains()
for domain in domains:
    print(f"Domain: {domain.name} ({domain.domain_type})")

# Read a data point
value = client.read_point("ICC1", "Voltage")
print(f"Value: {value.value}, Quality: {value.quality}")

# Security analysis
security = client.analyze_security()
print(f"Readable points: {security['readable_points']}")
print(f"Concerns: {security['concerns']}")

client.disconnect()

TASE.2 Features

  • Domain Discovery: VCC (Virtual Control Center) and ICC (Indication Control Center)
  • Variable Enumeration: List and read data points with quality information
  • Data Point Access: Read/write individual points or bulk enumeration
  • Transfer Sets (Block 2): RBE (Report-by-Exception) management
  • Device Control (Block 5): Select-Before-Operate, commands, setpoints
  • Bilateral Tables: Access control configuration queries
  • Security Analysis: Automated security assessment and recommendations

TASE.2 Data Types

from pyiec61850.tase2 import (
    Domain,          # VCC/ICC domain
    PointValue,      # Data point with value and quality
    TransferSet,     # Block 2 transfer set
    BilateralTable,  # Access control table
    ServerInfo,      # Server information
)

MMS Module (Safe Wrappers)

The pyiec61850.mms module provides safe Python wrappers around the raw SWIG bindings, preventing common crashes from NULL pointer dereferences and memory leaks.

Why Use the Safe Wrappers?

The raw pyiec61850 bindings require careful memory management:

  • LinkedList_destroy() must be called after iteration
  • MmsValue_delete() must be called after reading values
  • toCharP() crashes on NULL pointers

The MMS module handles all of this automatically.

MMS Client Example

from pyiec61850.mms import MMSClient, ConnectionFailedError

with MMSClient() as client:
    try:
        client.connect("192.168.1.100", 102)

        # All memory management is automatic
        for device in client.get_logical_devices():
            for node in client.get_logical_nodes(device):
                print(f"{device}/{node}")

    except ConnectionFailedError as e:
        print(f"Connection failed: {e}")

MMS over TLS

The wheels ship libiec61850 with mbedTLS compiled in. Configure TLS with TLSConfig and pass it to the client — both server-authentication-only and mutual TLS are supported:

from pyiec61850.mms import MMSClient
from pyiec61850.mms.tls import TLSConfig, TLSVersion

tls = TLSConfig(
    own_cert="client.pem",          # omit cert+key for server-auth-only TLS
    own_key="client-key.pem",
    ca_certs=["ca.pem"],
    min_version=TLSVersion.TLS_1_2,
)

with MMSClient("192.168.1.100", tls=tls) as client:  # default TLS port 3782
    print(client.get_logical_devices())

The raw TLSConfiguration_* API (TLSConfiguration_create, TLSConfiguration_setOwnCertificateFromFile, …) is also exposed for low-level use, e.g. for IedServer_createWithTlsSupport.

Variable Type Introspection

get_variable_spec() reads a variable's MMS type specification (recursively for structures and arrays) and returns a plain dataclass:

spec = client.get_variable_spec("simpleIOGenericIO/GGIO1.AnIn1.mag[MX]")
print(spec.type_name)                    # "STRUCTURE"
print([c.name for c in spec.children])   # ["f"]

Safe Utilities for Raw Bindings

If you need to use raw bindings, use the safe utilities:

from pyiec61850.mms.utils import (
    safe_to_char_p,        # NULL-safe string conversion
    LinkedListGuard,       # Auto-cleanup context manager
    MmsValueGuard,         # Auto-cleanup for MmsValue
)
import pyiec61850.pyiec61850 as iec61850

# Safe iteration with automatic cleanup
result = iec61850.IedConnection_getLogicalDeviceList(connection)
device_list, error = result

with LinkedListGuard(device_list) as guard:
    for device_name in guard:  # NULL pointers automatically skipped
        print(device_name)
# LinkedList automatically destroyed

License

This project is licensed under the GNU General Public License v3.0 (GPLv3) - see the LICENSE file for details.

Third-Party Components

  • libiec61850 by MZ Automation GmbH - GPLv3 (commercial license available)
  • Mbed TLS - Apache License 2.0

The compiled libiec61850.so and SWIG bindings included in wheel distributions are built from the libiec61850 source code. See the NOTICE file for full attribution details.

For commercial use cases where GPLv3 is not suitable, a commercial license for libiec61850 is available from MZ Automation GmbH.

Trademarks

All marks belong to their owners; used nominatively to describe interoperability; no endorsement implied.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyiec61850_ng-1.6.1.8-cp314-cp314-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.14Windows x86-64

pyiec61850_ng-1.6.1.8-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

pyiec61850_ng-1.6.1.8-cp313-cp313-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.13Windows x86-64

pyiec61850_ng-1.6.1.8-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

pyiec61850_ng-1.6.1.8-cp312-cp312-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.12Windows x86-64

pyiec61850_ng-1.6.1.8-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

pyiec61850_ng-1.6.1.8-cp311-cp311-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.11Windows x86-64

pyiec61850_ng-1.6.1.8-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

pyiec61850_ng-1.6.1.8-cp310-cp310-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.10Windows x86-64

pyiec61850_ng-1.6.1.8-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

pyiec61850_ng-1.6.1.8-cp39-cp39-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.9Windows x86-64

pyiec61850_ng-1.6.1.8-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file pyiec61850_ng-1.6.1.8-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 48c0d00cf68b17459cc6d99a5dbe4e34773e46fcef3e8b10a66ae1250c358576
MD5 f96139828684de4d443b829047436b67
BLAKE2b-256 62bfa7a52ad01b6d93b4385ab4400500b212cfdb930e3fe0f2037048b4801973

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp314-cp314-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80d428f66e6998681d53dc9401fabb556f9b23f5fe67593db3ef396fafc1b6e6
MD5 1e4475d62429f2cd48c0a8c30ec6b24b
BLAKE2b-256 2c81de3db1894d22bc1455e221aa645851ebb8f3a85488970c2a1f8331f30373

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 09d1059d0779d25fb377c723a2dd688ee9792bc09affc925f49ed9d14dc1fbda
MD5 796aa1c5526c7dfd3c0a4b08e0d7c071
BLAKE2b-256 24fc256993102dd94eee8db19c1ae1d6b45ae5625eee90900cddcd1c588ffe1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp313-cp313-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 08c39da31ea3f03fa4d431f3a7c2d38ccc89c22671da1b06161651693e4cf21f
MD5 9e8322b1ef1b006fa50987d3899a4a59
BLAKE2b-256 0e813a40b2602c43fdf495bcc5809f311898edb8d83bb7dfc65d1bf652bbd152

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 370e0c441356b2bda704e5e84be80857cc87bec7580995012d6f4d3a6a5f5107
MD5 248d813d625d8f78f8f982dcf86c56a4
BLAKE2b-256 1808b9a20010fa92f49e0673272b4f4e0f35f1838311452e1c7ba6af4e575a56

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp312-cp312-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 04ccca85fef26f85173b427834c8fe328d64857f1a6fbe5c2308dceb50c08e95
MD5 cc79b621ed45c262043ae0536c4ffcb3
BLAKE2b-256 9699ab5669a99511bb3e8efd54f3a12078e2524da21f388fc6b234bf46fb99e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 de9fa46c9f916a3ce8045efa69a9434eb01393885d92ff7867e7afb2d8bc08f2
MD5 6f9ef6ec8a57e8115315e4477533e006
BLAKE2b-256 aa2a2ff4358692398c746255d747fd3068e7d3c26137f5436f59c3f1e66baa0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp311-cp311-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 688a429a55e7e92963e4954f51c51ea3c4cf7897a83dda6898d896c4eff48641
MD5 f03f5e8a8640e8835e6c6ce2c96b5167
BLAKE2b-256 697c4158148c403133e2b3efbab51f3f59191cc69391574a0788cc5782d0e6a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c30e66769cdc1116c2379a54c561b7681acda31ac299a55edf2a11b905803180
MD5 33775101b93eb886841d2024f2878940
BLAKE2b-256 b31ae31474fa3a4b27e0f730bbb1109a11270b499ea005ae562867a5833f33dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp310-cp310-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0e99db0d3944f2eca8cc65c6c13385d990524b3152c2dd9af5d465b5af413263
MD5 c300a1cdffa49074aae53f9b1819cb20
BLAKE2b-256 3f3977daede20b5bfc4d1a0bedafeb918bbbc4ea28fa23d8c731b1b9b2ad7371

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c53597a3cc0f235bba6c55478a2cd55b866213ce11d7c850b6d0e9af30f86ab2
MD5 6f5e8e06e0b4f7f4421bc8292f8b9112
BLAKE2b-256 ce75276ae854302da399be8763da6ee678870875415774947efd2deaf8faa609

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp39-cp39-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.8-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.8-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4c54ab7d9f6db85a7b1d1b507536818726010cd68056ca26e8275798df05e8e7
MD5 eef5958e6e81e05a3342eef5fe9d24ad
BLAKE2b-256 e528986636db59f77d1d66e16c32d85debde7564ef9e64ea748b5140766cccc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.8-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page