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.1.2.tar.gz (4.6 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.1.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: indevolt_api-1.1.2.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

Hashes for indevolt_api-1.1.2.tar.gz
Algorithm Hash digest
SHA256 2021761f7cf4defc1edfc762eb6cc46d15d635134743981cbd53431f695b8e45
MD5 dd6c941c5ad570bbe3a72f59542f891c
BLAKE2b-256 9fc25f2cf1b5316ccf1a520ed511ac91532f13a50a5f8f614633b101b4d03913

See more details on using hashes here.

File details

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

File metadata

  • Download URL: indevolt_api-1.1.2-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

Hashes for indevolt_api-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 235ed366facafab23824b87d51986935621e724318b7afcaeacffd77cfadfe21
MD5 61b7c524df544ac4539111fed58318c3
BLAKE2b-256 ebe25063688032b66f219c2b4683af08ba8ad87e54da9b4dbbce0b43d05bfa4d

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