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.

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, clone the repository and install dependencies:

git clone https://github.com/gmasse/ecactus-ecos-py.git
cd ecactus-ecos-py
python -m venv venv
source venv/bin/activate
python -m pip install '.[dev]'

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:

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:

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:
    ruff check
    
  • Typing Checks: Use mypy to ensure type correctness:
    mypy
    
  • Unit Tests: Run pytest to execute tests:
    pytest
    

Documentation Contribution

Use mkdocs to serve a local preview of the documentation:

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.4.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.4.1
File Size Uploaded
ecactus_ecos_py-0.4.1.tar.gz 37.5 kB Details

Built distribution (wheel)

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

Total release size: 68.3 kB

Release files / ecactus_ecos_py-0.4.1.tar.gz

Download URL ecactus_ecos_py-0.4.1.tar.gz
Size 37.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d5ef380966e8d1710872de31daecad9bd5179edb947dfff5ec10f3be529ad95a
BLAKE2b-256 checksum
How to use checksums
61c5a98d63b2e6c557c20b34dabf425b003e5b56cd18eda19f79652850f89ca8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL ecactus_ecos_py-0.4.1-py3-none-any.whl
Size 30.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b45f7a7927ca7399cc4b9462d8faba0f72f50c4a5055cad1f12ccfec348a7c6
BLAKE2b-256 checksum
How to use checksums
c17522c4e06633ca90be57416a3bf1052adf66449d9362be9d9934ae3f608946
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

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