Skip to main content

eCactus ECOS Python Client

ci

This Python client provides both synchronous and asynchronous interfaces to interact with the eCactus ECOS platform from WEIHENG Group for energy management. However, this project is in its early stages, is not fully tested, and is not safe for production use. Use it at your own risk.

Features

  • Synchronous Access: Use the Ecos class for straightforward, blocking operations.
  • Asynchronous Access: Use the AsyncEcos class for non-blocking, concurrent operations.

Installation

python -m venv venv
source venv/bin/activate
pip install ecactus-ecos-py

Usage

Synchronous Client

from ecactus import Ecos

# Initialize the client
session = Ecos(datacenter="EU")
session.login("email@domain.com", "mypassword")

# Fetch user details
user = session.get_user()
print(user)

# Retrieve all the devices
devices = session.get_all_devices()
print(devices)

Asynchronous Client

import asyncio
from ecactus import AsyncEcos


async def main():
    # Initialize the client
    session = AsyncEcos(datacenter="EU")
    await session.login("email@domain.com", "mypassword")

    # Fetch user details
    user = await session.get_user()
    print(user)

    # Retrieve all the devices
    devices = await session.get_all_devices()
    print(devices)


asyncio.run(main())

Examples

A set of ready-to-use scripts is available in the examples/ directory.

Error handling

A client method raises one of three kinds of exceptions:

  • ecactus.exceptions.EcosApiError, or one of its subclasses, when the API refuses the call or answers something the client cannot use: AuthenticationError, UnauthorizedError, HomeDoesNotExistError, UnauthorizedDeviceError, ParameterVerificationFailedError, ApiResponseError, HttpError, InvalidJsonError.
  • pydantic.ValidationError when a successful response carries data that does not have the expected shape, for instance after a change on the server side. It names the field that failed, without the received value.
  • Transport errors, which the client does not wrap: requests.exceptions.RequestException for Ecos, aiohttp.ClientError and TimeoutError for AsyncEcos.
import pydantic
import requests

from ecactus import Ecos
from ecactus.exceptions import EcosApiError

session = Ecos(datacenter="EU", email="email@domain.com", password="mypassword")
try:
    devices = session.get_all_devices()
except EcosApiError:
    ...  # refused by the API, or an unusable response
except pydantic.ValidationError:
    ...  # data in an unexpected shape
except requests.exceptions.RequestException:
    ...  # network failure or timeout

Logging

The library logs through the standard logging module, under the ecactus logger. At DEBUG level it logs every API call and response, with tokens shortened to their last 4 characters and passwords, secrets and personal data (email, phone, names, serial numbers, location) masked, home and device IDs left in clear:

import logging

logging.getLogger("ecactus").setLevel(logging.DEBUG)

Raw response bodies go to a separate ecactus.wire logger, which stays off even when the root or ecactus logger is at DEBUG. Turn it on by naming it:

logging.getLogger("ecactus.wire").setLevel(logging.DEBUG)

Warning: ecactus.wire output contains live access and refresh tokens. Never share it.

Documentation

The API references for both Ecos and AsyncEcos clients, is available at: eCactus ECOS API Client Documentation

Development & Contributing

To set up the project for development, install uv, then clone the repository and install dependencies:

git clone https://github.com/gmasse/ecactus-ecos-py.git
cd ecactus-ecos-py
uv sync   # creates .venv from uv.lock, dev tools included

We invite you to contribute to the project by opening an issue or pull request to propose new features, fix bugs, or enhance the documentation.

Pull requests should target the dev branch — main is reserved for releases. See CONTRIBUTING.md for the full contribution workflow.

For pending tasks and improvements, please check the TODO.md file.

Automatic Synchronous Code Generation

The ecactus.Ecos synchronous class, defined in src/ecactus/client.py, is automatically generated from the ecactus.AsyncEcos class using scripts/unasync.py. When making changes to the ecactus.AsyncEcos class, you should re-run this script to regenerate the ecactus.Ecos class:

uv run python scripts/unasync.py

This ensures that both the synchronous and asynchronous APIs remain consistent.

To verify that the generated synchronous class matches the asynchronous class, use the --check option:

uv run python scripts/unasync.py --check

This will report any differences between the two classes, allowing you to catch any inconsistencies before submitting your changes.

Code Quality

  • Linting: Run ruff to check for code style issues:
    uv run ruff check
    
  • Formatting: Run ruff format to apply the code style (CI runs ruff format --check):
    uv run ruff format
    
  • Typing Checks: Use mypy to ensure type correctness:
    uv run mypy
    
  • Unit Tests: Run pytest to execute tests:
    uv run pytest
    

Documentation Contribution

Use mkdocs to serve a local preview of the documentation:

uv run mkdocs serve

License

This project is licensed under the GPL-3.0 License. See the LICENSE file for details.

⚠️ Disclaimer

  • This project is not affiliated with, endorsed by, or associated with WEIHENG Group, eCactus, ECOS, or any related companies.
  • The names WEIHENG, eCactus, and ECOS may be registered trademarks of their respective owners.
  • This software is developed independently and does not interact with any proprietary or official services provided by WEIHENG Group or eCactus.

Metadata

Release files for ecactus-ecos-py 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ecactus-ecos-py 0.5.1
File Size Uploaded Provenance Actions
ecactus_ecos_py-0.5.1.tar.gz 68.3 kB With provenance Details for ecactus_ecos_py-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ecactus-ecos-py 0.5.1
File Interpreter ABI Platform Actions
ecactus_ecos_py-0.5.1-py3-none-any.whl Python 3 none any Details for ecactus_ecos_py-0.5.1-py3-none-any.whl

Total release size: 116.0 kB

Release files / ecactus_ecos_py-0.5.1.tar.gz

Download URL ecactus_ecos_py-0.5.1.tar.gz
Size 68.3 kB
Tags Source
SHA-256 checksum
How to use checksums
af080115749b806c74724e258043c881d53a9cac4a02c3cb8468774f663430d9
BLAKE2b-256 checksum
How to use checksums
302e78857f7810b306d4a3fd2012a6a4cf6fdc9bdaf7f9a4d0613f0289bcf467
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / ecactus_ecos_py-0.5.1-py3-none-any.whl

Download URL ecactus_ecos_py-0.5.1-py3-none-any.whl
Size 47.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d66e9e7d22ed3bfdbb4c607fb4a7fdb16c1753913dbd9817c06fed0adf2774d
BLAKE2b-256 checksum
How to use checksums
08a144d140dcddc4c6e806799e6ae8e81a246ae081faf0dfc56056deda14711c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for ecactus-ecos-py 0.5.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ecactus_ecos_py-0.5.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page