Metadata-Version: 2.4
Name: ecoflow-python
Version: 0.1.0
Summary: Python library for controlling and monitoring EcoFlow energy devices
Author: Diego Colombo
License: MIT License
        
        Copyright (c) 2026 colombod
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Source, https://github.com/colombod/ecoflow-sdk
Project-URL: Documentation, https://github.com/colombod/ecoflow-sdk/tree/main/python
Project-URL: Bug Tracker, https://github.com/colombod/ecoflow-sdk/issues
Project-URL: Changelog, https://github.com/colombod/ecoflow-sdk/blob/main/python/CHANGELOG.md
Keywords: ecoflow,smart home,energy,battery,mqtt,iot,home automation,stream,delta,river,powerstream
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Home Automation
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.27
Requires-Dist: aiomqtt>=2.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: pytest-timeout>=2.3; extra == "dev"
Requires-Dist: respx>=0.21; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Requires-Dist: pyright>=1.1; extra == "dev"
Requires-Dist: python-dotenv>=1.0; extra == "dev"
Dynamic: license-file

# ecoflow-python

Python library for controlling and monitoring [EcoFlow](https://www.ecoflow.com) energy devices — batteries, smart plugs, smart meters, and more.

## Supported Devices

| Device | Read | Control |
|--------|:----:|:-------:|
| STREAM Ultra | ✅ | ✅ |
| STREAM AC Pro | ✅ | ✅ |
| Smart Plug | ✅ | ✅ |
| Smart Home Meter | ✅ | — |
| Delta Pro / Pro 3 / 2 / 2 Max | ✅ | ✅ |
| River Pro / 2 / 2 Max / 2 Pro | ✅ | ✅ |
| PowerStream (600W / 800W) | ✅ | ✅ |
| Wave 3 AC | ✅ | ✅ |
| Smart Home Panel 2 | ⚠️ partial | — |

## Installation

```bash
pip install ecoflow-python
# or with uv
uv add ecoflow-python
```

## Quick Start

```python
import asyncio
from ecoflow import EcoFlowClient

async def main():
    async with EcoFlowClient(
        access_key="your_access_key",
        secret_key="your_secret_key",
        region="EU",    # or "US"
    ) as client:
        # All devices auto-discovered on connect
        print(f"Batteries:    {client.batteries}")
        print(f"Plugs:        {client.plugs}")
        print(f"Stream units: {client.stream_units}")
        print(f"Meter:        {client.meters}")

        # Read live data
        for battery in client.batteries:
            status = await battery.refresh()
            print(f"{battery.product_name}: {status.batt_soc:.0f}% SOC")

        # Events stream (MQTT, real-time)
        async for event in client.stream_units[0].events():
            print(f"SOC: {event.batt_soc:.0f}%")

asyncio.run(main())
```

## Getting API Keys

1. Create an account at [ecoflow.com](https://www.ecoflow.com)
2. Go to the Developer Portal: [EU](https://developer-eu.ecoflow.com) | [US](https://developer.ecoflow.com)
3. Apply for Developer Access
4. Find your `accessKey` and `secretKey` in the developer console

See the [EcoFlow Developer Portal](https://developer-eu.ecoflow.com) (EU) or [developer.ecoflow.com](https://developer.ecoflow.com) (US) for API key instructions.

## Architecture

- **Transport:** REST (`/iot-open/sign/device/quota/all`) + MQTT (`/open/{account}/{sn}/quota`)
- **Auth:** HMAC-SHA256 signed headers on every REST call
- **Events:** Real-time MQTT push with automatic reconnection and exponential backoff
- **Typing:** Fully typed with `py.typed` marker — works with mypy and pyright

## Development

```bash
git clone https://github.com/colombod/ecoflow-sdk
cd ecoflow-sdk/python
uv sync --all-extras
uv run pytest                              # unit tests
uv run pytest -m integration              # read-only E2E (needs tests/.env)
uv run ruff check . && uv run pyright     # lint + types
```

## License

MIT — see [LICENSE](LICENSE)
