Metadata-Version: 2.4
Name: async-sunspec
Version: 0.1.0b2
Summary: Async implementation of SunSpec Modbus communication.
Author-email: CERTI Foundation <certi@certi.org.br>
Keywords: sunspec,modbus,asyncio,energy,der
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Networking
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: pymodbus==3.12.1
Provides-Extra: dev
Requires-Dist: pytest==8.4.2; extra == "dev"
Requires-Dist: pytest-cov==7.0.0; extra == "dev"
Requires-Dist: ruff==0.15.7; extra == "dev"
Requires-Dist: build==1.3.0; extra == "dev"
Requires-Dist: twine==6.2.0; extra == "dev"
Dynamic: license-file

# async-sunspec

Async SunSpec Modbus communication library for Python 3.12+.

This package provides:

- Runtime model system (`SunSpecPoint`, `SunSpecGroup`, `SunSpecModel`, `SunSpecDevice`)
- Async Modbus TCP client (`async_sunspec.client.device.SunSpecClient`)
- Async Modbus TCP server wrapper (`async_sunspec.server.server.SunSpecServer`)
- Generated SunSpec model classes under `async_sunspec.models`

## Requirements

- Python `>=3.12`
- `pymodbus==3.12.1`

## Installation

```bash
python -m pip install async-sunspec
```

## Quickstart

### Run the bundled server example (from repository checkout)

```bash
.venv/bin/python examples/basic_server/run.py
```

Options:

```bash
.venv/bin/python examples/basic_server/run.py \
  --host 127.0.0.1 \
  --port 15020 \
  --device-id 1 \
  --address 40000 \
  --update-interval 1.0
```

This starts a SunSpec TCP server with:

- `Model1` (identity/common information)
- `Model701` (DER AC measurements)

and simulates changing telemetry values (`St`, `W`, `A`).

### Connect and scan with `SunSpecClient`

```bash
.venv/bin/python - <<'PY'
import asyncio
from async_sunspec.client.device import SunSpecClient

async def main():
    client = SunSpecClient("127.0.0.1", port=15020)
    await client.connect()
    try:
        device = await client.scan(device_id=1, address=40000)
        print(f"Found {len(device._sunspec_models)} model(s)")
        for model_id in device._sunspec_models:
            print(f"- Model {model_id}")
    finally:
        client.close()

asyncio.run(main())
PY
```

## Project Status

This project is currently in beta (`0.1.0b1`). API and behavior may evolve across beta releases.

## Development Docs

- Development setup and quality commands: `docs/DEVELOPMENT.md`
- Agent instructions for building a client: `docs/AGENT_CLIENT_IMPLEMENTATION.md`
