Elecnova Client
Python client library for the Elecnova ECO EMS Cloud API.
Version 0.3.0 - API V2.2.0 project → site → device hierarchy.
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
- 🌞 Photovoltaic power generation endpoints (v1.3.1+)
- 🏗️ Project → site → device hierarchy (v2.2.0+) for durable site attribution
- 🔧 Component type standardization with official codes
- ✅ 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
Migration Guide
v0.1.5 → v0.1.6 (AUTHENTICATION FIX - NOW WORKING!)
Version 0.1.6 includes critical authentication fixes that make the client fully functional with the Elecnova API.
What Changed:
- ✅ Fixed business API authentication (raw token + all signature headers)
- ✅ Fixed MQTT subscription endpoint (GET instead of POST)
- ✅ Fixed response parsing for raw API responses
- ✅ Updated models to match actual API response format
No code changes required - simply upgrade to v0.1.6:
pip install --upgrade elecnova-client
Verified Working:
- ✅ Authentication (
/comm/client) - ✅ Get cabinets (
/api/v1/dev) - Successfully retrieves all cabinets - ✅ Get components (
/api/v1/dev/{sn}) - Successfully retrieves all components - ✅ All v1.3.1 features (
component,component_descfields)
v0.1.4 → v0.1.5 (ENDPOINT CORRECTIONS)
Version 0.1.5 fixed critical endpoint paths to match official documentation:
| Method | Old (v0.1.4) | New (v0.1.5) |
|---|---|---|
get_cabinets() |
/api/v1/cabinet/list |
/api/v1/dev |
get_components() |
/api/v1/cabinet/{sn}/components |
/api/v1/dev/{sn} |
Usage
Async Client
from elecnova_client import ElecnovaClient
async def main():
client = ElecnovaClient(client_id="your_client_id", client_secret="your_client_secret")
# Fetch ESS cabinets (devices)
cabinets = await client.get_cabinets(page=1, page_size=100)
for cabinet in cabinets:
print(f"Cabinet: {cabinet.sn} - {cabinet.name}")
print(f" Model: {cabinet.model}")
print(f" Timezone: {cabinet.time_zone}")
# Fetch components for a specific cabinet
components = await client.get_components(cabinet_sn="ESS123456")
for component in components:
print(f"Component: {component.sn}")
print(f" Type: {component.type}")
print(f" Component Code: {component.component}") # v1.3.1+
print(f" Description: {component.component_desc}") # v1.3.1+
print(f" State: {component.state}")
# Subscribe to MQTT topics for real-time data
result = await client.subscribe_mqtt_topics(device_id="123", sn="ESS123456")
# Walk the project -> site -> device hierarchy (v2.2.0+)
for project in await client.get_projects():
print(f"Project: {project.name} ({project.id})")
for site in await client.get_project_sites(project.id):
# site.id is the same UUID as the web UI station ID: a durable join key
print(f" Site: {site.name} ({site.id}) {site.rated_power} kW")
for device in await client.get_site_devices(site.id):
# device.id matches Cabinet.id from get_cabinets()
print(f" Device: {device.sn} ({device.model}) id={device.id}")
# Fetch PV power generation with 5-minute intervals (v1.3.1+)
power_data = await client.get_pv_power_cap(
sn="PV123456", begin="2025-11-01T00:00:00Z", end="2025-11-01T23:59:59Z"
)
for point in power_data:
print(f"{point.time}: {point.value}W")
# Get PV daily generation for past 7 days (v1.3.1+)
daily_data = await client.get_pv_power_gen_daily(sn="PV123456")
for point in daily_data:
print(f"{point.time}: {point.value} kWh")
# Get PV monthly generation (v1.3.1+)
monthly_data = await client.get_pv_power_gen_monthly(sn="PV123456", month="2025-11")
# Get PV yearly generation (v1.3.1+)
yearly_data = await client.get_pv_power_gen_yearly(sn="PV123456", year="2025")
# Always close the client when done
await client.close()
Context Manager (Recommended)
async def main():
async with ElecnovaClient(
client_id="your_client_id", client_secret="your_client_secret"
) as client:
cabinets = await client.get_cabinets()
# Client automatically closes when exiting context
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 (Device) data model with pagination support.
Fields:
id: Unique device IDsn: Serial numbername: Cabinet namemodel: Cabinet modeltime_zone: Installation timezonecreated_at: Creation timestampupdated_at: Last update timestamp
Component
Component (BMS, PCS, Meter, Sensors, etc.) data model.
Fields:
sn: Component serial number (unique identifier)name: Component namemodel: Component modeltype: Component type (legacy field)state: Component state (online/offline)location_code: Location code for data point mappingcabinet_sn: Parent cabinet serial numbercomponent: Component type code [v1.3.1+] - see Component Types sectioncomponent_desc: Component type description [v1.3.1+] - see Component Types section
Project
Top level of the hierarchy [v2.2.0+].
Fields:
id: Project UUIDname: Project namecode: Project coderegion: Project region (may be an empty string)addr: Project address (may be an empty string)begin_at: Project start date (YYYY-MM-DD)
Site
Power station, the middle level of the hierarchy [v2.2.0+].
Fields:
id: Site UUID — the same UUID as the station ID in the Elecnova web UI, so it is a durable join key for site attribution (names are not)name: Site namerated_power: Rated power (kW)rated_capacity: Rated capacity (kWh) — documented, absent from the live payloadtime_zone: Site timezone (e.g.,Europe/Brussels)begin_at: Site start date — documented, absent from the live payloadaddr: Site address — documented, absent from the live payload
Device
Leaf level of the hierarchy [v2.2.0+].
Fields:
id: Device UUID — the same UUID asCabinet.idfromGET /api/v1/dev, so the v2 hierarchy joins cleanly onto the existing v1 device surfacesn: Device serial numbername: Device namemodel: Device model (e.g.,ECO-E215WS)
Pagination / PaginatedV2Response
The envelope of a paginated v2 response: {"data": [...], "pagination": {"page": 1, "page_size": 10, "total_count": 1}}. The API's own default page_size is 10, max 1000.
Note that the v2 endpoints name their fields in snake_case on the wire (time_zone,
begin_at, rated_power, page_size, total_count), unlike v1 which uses camelCase
for some fields (timeZone, lastSeen). The models follow what the API actually
returns; they do not normalise it.
PowerDataPoint
PV power generation data point [v1.3.1+].
Fields:
time: Timestamp in RFC3339 formatvalue: Power value (unit varies by endpoint)
TokenResponse
OAuth token response (internal use).
Fields:
id: MQTT Client IDusername: MQTT usernamepassword: MQTT passwordtoken: Bearer token (24-hour TTL)
Component Types (v1.3.1+)
The API now provides standardized component type codes in the component field:
| Code | Description | Usage |
|---|---|---|
ess.ems |
EMS | Energy Management System |
ess.bms |
BMS | Battery Management System |
ess.pcs |
PCS | Power Conversion System |
pv.inv |
PV | Photovoltaic Inverter |
ess.meter |
Meter | Energy Meter |
ess.battery |
Battery | Battery Pack |
ess.fire |
Fire Host | Fire Suppression System |
ess.ac |
Air Conditioning | HVAC System |
Access these via component.component (code) and component.component_desc (description).
Client Methods
Authentication
get_token(): Obtain/refresh access token (automatically called, 24-hour TTL)
Device Management
get_cabinets(page=1, page_size=100): List ESS cabinets with pagination- Endpoint:
GET /api/v1/dev - Returns: List of
Cabinetobjects
- Endpoint:
get_components(cabinet_sn): List components for a specific cabinet- Endpoint:
GET /api/v1/dev/{sn} - Returns: List of
Componentobjects
- Endpoint:
Hierarchy [v2.2.0+]
get_projects(): List all projects- Endpoint:
GET /api/v2/projects - Response shape: bare JSON array (no envelope)
- Returns: List of
Projectobjects
- Endpoint:
get_project_sites(project_id, page=1, page_size=100): List the sites of a project- Endpoint:
GET /api/v2/project/{id}/sites - Response shape:
{"data": [...], "pagination": {...}} - Returns: List of
Siteobjects for the requested page. AWARNINGis logged whenpagination.total_countexceeds the page requested, so a short page cannot silently pass for the whole set.
- Endpoint:
get_site_devices(site_id): List the devices of a site- Endpoint:
GET /api/v2/site/{id}/devices - Response shape: bare JSON array (no envelope)
- Returns: List of
Deviceobjects
- Endpoint:
MQTT Subscription
subscribe_mqtt_topics(device_id, sn): Subscribe to MQTT topics for real-time data- Endpoint:
POST /api/v1/dev/topic/{device_id}/{sn} - Returns: Subscription result dictionary
- Endpoint:
PV Power Generation [v1.3.1+]
get_pv_power_cap(sn, begin, end): Get PV power generation with 5-minute intervals- Endpoint:
GET /api/v1/dev/pv/power-cap/{sn} - Params:
beginandendin RFC3339 format (e.g., "2025-11-01T00:00:00Z") - Returns: List of
PowerDataPoint(power in watts)
- Endpoint:
get_pv_power_gen_daily(sn): Get PV daily generation for past 7 days- Endpoint:
GET /api/v1/dev/pv/power-gen/daily/{sn} - Returns: List of
PowerDataPoint(daily energy in kWh)
- Endpoint:
get_pv_power_gen_monthly(sn, month): Get PV monthly daily generation- Endpoint:
GET /api/v1/dev/pv/power-gen/monthly/{sn} - Params:
monthin YYYY-MM format (e.g., "2025-11") - Returns: List of
PowerDataPoint(daily energy for the month)
- Endpoint:
get_pv_power_gen_yearly(sn, year): Get PV annual monthly generation- Endpoint:
GET /api/v1/dev/pv/power-gen/yearly/{sn} - Params:
yearin YYYY format (e.g., "2025") - Returns: List of
PowerDataPoint(monthly energy for the year)
- Endpoint:
Exception Handling
from elecnova_client import (
ElecnovaAPIError,
ElecnovaAuthError,
ElecnovaRateLimitError,
ElecnovaTimeoutError,
)
try:
cabinets = await client.get_cabinets()
except ElecnovaAuthError as e:
print(f"Authentication failed: {e}")
print(f"Status code: {e.status_code}")
print(f"Response: {e.response}")
except ElecnovaRateLimitError as e:
print(f"Rate limit exceeded: {e}")
except ElecnovaTimeoutError as e:
print(f"Request timeout: {e}")
except ElecnovaAPIError as e:
print(f"API error: {e}")
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=elecnova_client --cov-report=html
# Run linter
ruff check .
# Format code
ruff format .
# Type checking
mypy src/
API Documentation
Based on Elecnova ECO EMS Cloud API Interface Document V1.3.1
Authentication Flow
- Client Registration: Obtain
Client IDandClient Secretfrom Elecnova - IP Whitelisting: Provide source IP address for access approval
- Token Request: Call
GET /comm/clientwith HMAC-SHA256 signature - Token Usage: Include Bearer token in
Authorizationheader for all API calls - Token Refresh: Automatic refresh 5 minutes before 24-hour expiry
Technical Specifications
- Authentication: HMAC-SHA256 signature with Base64 encoding
- Token Validity: 24 hours (86400 seconds)
- Token Refresh: Automatic, 5 minutes before expiry
- Rate Limit: 100 requests/second
- MQTT Protocol: MQTTS (secure MQTT)
- MQTT Port: 1884
- Base URL:
https://api.elecnova.com(configurable) - Timeout: 30 seconds (configurable)
API Endpoints (v1.3.1)
| Endpoint | Method | Description |
|---|---|---|
/comm/client |
GET | Request authentication token and MQTT credentials |
/api/v1/dev |
GET | Get device list (ESS cabinets) with pagination |
/api/v1/dev/{sn} |
GET | Get device component information |
/api/v1/dev/topic/{device_id}/{sn} |
POST | Subscribe to MQTT topics |
/api/v1/dev/pv/power-cap/{sn} |
GET | Get PV power generation (5-min intervals) |
/api/v1/dev/pv/power-gen/daily/{sn} |
GET | Get PV daily generation (past 7 days) |
/api/v1/dev/pv/power-gen/monthly/{sn} |
GET | Get PV monthly generation |
/api/v1/dev/pv/power-gen/yearly/{sn} |
GET | Get PV yearly generation |
API Endpoints (v2.2.0)
| Endpoint | Method | Response shape | Description |
|---|---|---|---|
/api/v2/projects |
GET | bare array | List projects |
/api/v2/project/{id}/sites |
GET | {data, pagination} |
List a project's sites (power stations) |
/api/v2/site/{id}/devices |
GET | bare array | List a site's devices |
Changelog
See CHANGELOG.md for detailed version history.
License
LGPL-3.0-or-later
Support
For issues, feature requests, or contributions, please visit: https://github.com/elektriciteit-steen/elecnova-client
Author
Steen Elektriciteit
- Email: info@steenelektriciteit.be
- Website: https://www.steenelektriciteit.be
Metadata
Release files for elecnova-client 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| elecnova_client-0.3.0.tar.gz | 20.9 kB | Without provenance | Details for elecnova_client-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| elecnova_client-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for elecnova_client-0.3.0-py3-none-any.whl |
Total release size: 37.6 kB
Release files / elecnova_client-0.3.0.tar.gz
| Download URL | elecnova_client-0.3.0.tar.gz |
|---|---|
| Size | 20.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3bb3a9b8d587b6ea27eb4ad506a3a00e744300c0e2e12831aa171bd289a9716
|
|
BLAKE2b-256 checksum How to use checksums |
772af5f67a2cb3b771b0d75ef6a2a00357c207e76f1a2ae77501db982b5122ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Release files / elecnova_client-0.3.0-py3-none-any.whl
| Download URL | elecnova_client-0.3.0-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9efea6594f4b105cfef22797b91df5874584e4cd4333a3fe18423fac4edbfd6c
|
|
BLAKE2b-256 checksum How to use checksums |
6e4ffac94f44e747ddadf14cc898fc249268c751ec9c251e88638b5e7148f918
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Security for elecnova-client 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.