Skip to main content

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 address
  • port (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" or 47015)
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

indevolt_api-1.0.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

indevolt_api-1.0.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file indevolt_api-1.0.0.tar.gz.

File metadata

  • Download URL: indevolt_api-1.0.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for indevolt_api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 65062660b6d8a8fee8062fa1d04b7dca907f280007ca445b2af8ba9eea1d889f
MD5 99288df628c1734bfe9bb919026163b1
BLAKE2b-256 fe8788ab2eebeefdd322f4fefebb2f09c4000e8b9dd25407da370e8b3194b273

See more details on using hashes here.

File details

Details for the file indevolt_api-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: indevolt_api-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for indevolt_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a38a8378f119bd829884c0bdc43b5ff5e9f84137238f4117bc05e416ba0c8e2
MD5 66a576c078e10baf70c9405ae8315d34
BLAKE2b-256 628eea825919bda2671236e05cb5e34b9d91edcbf630b049de282807fcd9d368

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page