Skip to main content

Python client for Elecnova ECO EMS Cloud API

Project description

Elecnova Client

Python client library for the Elecnova ECO EMS Cloud API.

Features

  • 🔐 HMAC-SHA256 authentication with automatic token management
  • 📦 Type-safe Pydantic models for API responses
  • ⚡ Async HTTP client using httpx
  • 🔄 Synchronous wrapper for non-async environments
  • ✅ Comprehensive test coverage
  • 🚀 Zero dependencies on specific frameworks (works with any Python application)

Installation

# From PyPI (recommended)
pip install elecnova-client

# From GitHub
pip install git+https://github.com/elektriciteit-steen/elecnova-client.git

# From source (for development)
git clone https://github.com/elektriciteit-steen/elecnova-client.git
cd elecnova-client
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

Usage

Async Client

from elecnova_client import ElecnovaClient

async def main():
    client = ElecnovaClient(
        client_id="your_client_id",
        client_secret="your_client_secret"
    )

    # Fetch cabinets
    cabinets = await client.get_cabinets(page=1, page_size=100)
    for cabinet in cabinets:
        print(f"Cabinet: {cabinet.sn} - {cabinet.name}")

    # Fetch components for a cabinet
    components = await client.get_components(cabinet_sn="ESS123456")
    for component in components:
        print(f"Component: {component.sn} ({component.type})")

    # Subscribe to MQTT topics
    result = await client.subscribe_mqtt_topics(device_id="123", sn="ESS123456")

Sync Client

from elecnova_client import ElecnovaClientSync

client = ElecnovaClientSync(
    client_id="your_client_id",
    client_secret="your_client_secret"
)

# Fetch cabinets (synchronous)
cabinets = client.get_cabinets(page=1, page_size=100)
for cabinet in cabinets:
    print(f"Cabinet: {cabinet.sn} - {cabinet.name}")

API Reference

Models

  • Cabinet: ESS Cabinet data model
  • Component: Component (BMS, PCS, Meter, etc.) data model
  • TokenResponse: OAuth token response
  • ApiResponse[T]: Generic API response wrapper

Client Methods

  • get_token(): Obtain/refresh access token
  • get_cabinets(page, page_size): List cabinets with pagination
  • get_components(cabinet_sn): List components for a cabinet
  • subscribe_mqtt_topics(device_id, sn): Subscribe to MQTT topics

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run linter
ruff check .

# Format code
ruff format .

API Documentation

Based on Elecnova ECO EMS Cloud API Interface Document V1.2.1

  • Authentication: HMAC-SHA256 with client credentials
  • Token validity: 24 hours
  • Rate limit: 100 requests/second
  • MQTT: MQTTS protocol (port 8883)

License

LGPL-3.0-or-later

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

elecnova_client-0.1.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

elecnova_client-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file elecnova_client-0.1.0.tar.gz.

File metadata

  • Download URL: elecnova_client-0.1.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for elecnova_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc041805fbe30ef9391d56e13f379011629730c8dd465743756ff78a1762a3c7
MD5 2e236779967a93c4799a03b11653eeb0
BLAKE2b-256 fb014e061fc9d579e12e6090fd3c31b72699bf95568d95588a0b0f3d42196d18

See more details on using hashes here.

File details

Details for the file elecnova_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for elecnova_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af6f6775e7815f81b0f0a5746e499f9314567a31ce3d54e66e5d4345b26c779b
MD5 de6ecc5706f6fca033b80e7f2c7d9370
BLAKE2b-256 ba37262fffe6f7eba2bf57402cec72719b2c1a2b42bcaa35ade1d45bebb836a4

See more details on using hashes here.

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