Skip to main content

IEEE 2030.5 client for GridAppSD

Project description

GridAPPSD IEEE 2030.5 Client

Python Tests PyPI version License Code style: black

A Python client library for IEEE 2030.5 (Smart Energy Profile 2.0) servers with persistent connections and extensible event handling.

Features

  • Persistent Connections: Uses modern HTTP client with connection pooling
  • Extensible Event Handling: Abstract base class for custom event processing
  • Async Support: Full asyncio integration for non-blocking operations
  • Subscription Management: Automatic tracking and renewal of subscriptions
  • Multi-format Support: Handles XML, JSON, and EXI content types
  • TLS Authentication: Certificate-based authentication for secure communications
  • Type Annotations: Modern Python typing for better IDE support and validation

Installation

# Install from PyPI
pip install gridappsd-2030-5-client

# Or with Poetry
poetry add gridappsd-2030-5-client

Quick Start

Basic Usage

import logging
from gridappsd_2030_5_client import IEEE2030Client, IEEE2030EventHandler

# Configure logging
logging.basicConfig(level=logging.INFO)

# Create a custom event handler
class MyEventHandler(IEEE2030EventHandler):
    def on_connect(self, client):
        print("Connected to IEEE 2030.5 server!")

    def on_subscription_update(self, client, resource, data):
        print(f"Received update for {resource}: {data}")

# Create and use the client
client = IEEE2030Client(
    base_url="https://ieee2030server.example.com/api",
    event_handler=MyEventHandler(),
    cert_path="client_cert.pem",
    key_path="client_key.pem",
    ca_cert_path="ca_cert.pem"
)

try:
    # Connect to the server
    if client.connect():
    # Get device capability
    capability = client.get_device_capability()
    print(f"Device capability: {capability}")

    # Subscribe to resources
    client.create_subscription("drp/1/dre") # Demand response events

    # Start polling for updates
    client.start_polling()

    # Wait for events
    input("Press Enter to stop...")
finally:
    # Disconnect and clean up
    client.disconnect()

Async Usage

import asyncio
from gridappsd_2030_5_client import IEEE2030Client, IEEE2030EventHandler

# Create a custom event handler
class MyEventHandler(IEEE2030EventHandler):
    def on_connect(self, client):
        print("Connected to IEEE 2030.5 server!")

async def main():
    # Create client
    client = IEEE2030Client(
        base_url="https://ieee2030server.example.com/api",
        event_handler=MyEventHandler(),
        cert_path="client_cert.pem",
        key_path="client_key.pem",
        ca_cert_path="ca_cert.pem"
    )

    try:
        # Connect to the server asynchronously
        if await client.async_connect():
            # Start polling for updates
            client.start_polling()

        # Wait for some time
        await asyncio.sleep(300) # Run for 5 minutes
    finally:
    # Disconnect and clean up
    client.disconnect()

# Run the async program
asyncio.run(main())

Development

# Clone the repository
git clone https://github.com/GRIDAPPSD/gridappsd-2030-5-client.git
cd gridappsd-2030-5-client

# Install dependencies with Poetry
poetry install

# Run tests
poetry run pytest

# Run tests with coverage
poetry run pytest --cov=gridappsd_2030_5_client

# Format code
poetry run black gridappsd_2030_5_client

License

BSD 3-Clause License

Copyright (c) 2023, GridAPPSD Contributors All rights reserved.

Project details


Download files

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

Source Distribution

gridappsd_2030_5_client-0.2.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

gridappsd_2030_5_client-0.2.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file gridappsd_2030_5_client-0.2.1.tar.gz.

File metadata

  • Download URL: gridappsd_2030_5_client-0.2.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gridappsd_2030_5_client-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0656b1a205d4de0e5fb1eb8123a1217675709221a3f3af73f2390633958708c5
MD5 38c320ce326cc625ca6144b5500eea58
BLAKE2b-256 0f8f02170e1adb70eb1c2d02340ace7fd1e9376cf339570618e77b526856baa9

See more details on using hashes here.

Provenance

The following attestation bundles were made for gridappsd_2030_5_client-0.2.1.tar.gz:

Publisher: publish-to-pypi.yml on GRIDAPPSD/gridappsd-2030_5-client

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

File details

Details for the file gridappsd_2030_5_client-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gridappsd_2030_5_client-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 90907efad00f9a0969bce0a2c3b28cc2d253417f0b75cc44cf5cbd679af59fac
MD5 9bf804e16f682c6b463ec165a93304bc
BLAKE2b-256 aa837e7d05c6c98815f6309803466bfd99ae13582f3dd3811e09ef6c26bfcb2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for gridappsd_2030_5_client-0.2.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on GRIDAPPSD/gridappsd-2030_5-client

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