Python client library for eCactus ECOS API
Project description
eCactus ECOS Python Client
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
Ecosclass for straightforward, blocking operations. - Asynchronous Access: Use the
AsyncEcosclass 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.
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
ruffto check for code style issues:ruff check - Typing Checks: Use
mypyto ensure type correctness:mypy
- Unit Tests: Run
pytestto 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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ecactus_ecos_py-0.2.1.tar.gz.
File metadata
- Download URL: ecactus_ecos_py-0.2.1.tar.gz
- Upload date:
- Size: 32.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
052827c6f8873c3156f9bf543add183408974b050d05e8caf0aaa6362e099df0
|
|
| MD5 |
3735db49cdc37e45a1bb0b4f325cb64f
|
|
| BLAKE2b-256 |
b1c50f397628d8154657edd7c6c2eefe99983941c0d7dd6306fed9b007163247
|
File details
Details for the file ecactus_ecos_py-0.2.1-py3-none-any.whl.
File metadata
- Download URL: ecactus_ecos_py-0.2.1-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
152161241371757f71694e155ce16a5ddafd6886118051508896073af04c2c81
|
|
| MD5 |
238e84bea6c027d6b30d7256109c035f
|
|
| BLAKE2b-256 |
b406865cd77a5ff83a2893dddb511e33f87042e2c67e6331476b76818160651a
|