Python API client for Indevolt devices
Project description
Indevolt API
Python client library for communicating with Indevolt devices (home battery systems).
Features
- Async/await support using aiohttp
- Fully typed with type hints
- Simple and intuitive API
- Comprehensive error handling
Installation
pip install indevolt-api
Quick Start
import asyncio
import aiohttp
from indevolt_api import IndevoltAPI
async def main():
async with aiohttp.ClientSession() as session:
api = IndevoltAPI(host="192.168.1.100", port=8080, session=session)
# Get device configuration
config = await api.get_config()
print(f"Device config: {config}")
# Fetch data from specific cJson points
data = await api.fetch_data(["7101", "1664"])
print(f"Data: {data}")
# Write data (single data point) to device
response = await api.set_data("1142", 50)
print(f"Set data response: {response}")
# Write data (multiple data points) to device
response = await api.set_data("47015", [2, 700, 5])
print(f"Set data response: {response}")
asyncio.run(main())
API Reference
IndevoltAPI
__init__(host: str, port: int, session: aiohttp.ClientSession)
Initialize the API client.
Parameters:
host(str): Device hostname or IP addressport(int): Device port number (typically 80)session(aiohttp.ClientSession): An aiohttp client session
async fetch_data(t: str | list[str]) -> dict[str, Any]
Fetch data from the device.
Parameters:
t: Single cJson point or list of cJson points to retrieve (e.g.,"7101"or["7101", "1664"])
Returns:
- Dictionary with device response containing cJson point data
Example:
# Single point
data = await api.fetch_data("7101")
# Multiple points
data = await api.fetch_data(["7101", "1664", "7102"])
async set_data(t: str | int, v: Any) -> dict[str, Any]
Write data to the device.
Parameters:
t: cJson point identifier (e.g.,"47015"or47015)v: Value(s) to write (automatically converted to list of integers)
Returns:
- Dictionary with device response
Example:
# Single value
await api.set_data("47016", 100)
# Multiple values
await api.set_data("47015", [2, 700, 5])
# String or int identifiers
await api.set_data(47016, "100")
async get_config() -> dict[str, Any]
Get system configuration from the device.
Returns:
- Dictionary with device system configuration
Example:
config = await api.get_config()
print(config)
Exception Handling
The library provides two custom exceptions:
APIException
Raised when there's a client error during API communication (network errors, HTTP errors).
TimeOutException
Raised when an API request times out (default timeout: 60 seconds).
Example:
from indevolt_api import IndevoltAPI, APIException, TimeOutException
try:
data = await api.fetch_data("7101")
except TimeOutException:
print("Request timed out")
except APIException as e:
print(f"API error: {e}")
Requirements
- Python 3.11+
- aiohttp >= 3.9.0
License
MIT License - see LICENSE file for details
Project details
Release history Release notifications | RSS feed
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 indevolt_api-1.1.0.tar.gz.
File metadata
- Download URL: indevolt_api-1.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3fec56a2598766de1a3ad9492e76ae3aa69be6c7d91dd3b8b96e9ee15cf0b86
|
|
| MD5 |
d52c1af4ce68c624b575cb3f89ef68fa
|
|
| BLAKE2b-256 |
23b0920fef1901b1967465bbc629afc9215c7a216edad3f248e29f3183d8097a
|
File details
Details for the file indevolt_api-1.1.0-py3-none-any.whl.
File metadata
- Download URL: indevolt_api-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05aece415baa843d433baea9c0777efd9d08d03d6bd3cec430c48292ae74c622
|
|
| MD5 |
f4167c6d95eee146f5412104273342c5
|
|
| BLAKE2b-256 |
193b5b63f73a0a136c6fd999adfc9b84bd520a4602c8a587ed320a6c5fbe967a
|