Python REST-Client for Kostal Plenticore Solar Inverters
Project description
Python Library for Accessing Kostal Plenticore Inverters
This repository provides a python library and command line interface for the REST-API of Kostal Plenticore Solar Inverter.
This library is not affiliated with Kostal and is no offical product. It uses the interfaces of the inverter like other libs (eg. https://github.com/kilianknoll/kostal-RESTAPI) and uses information from their swagger documentation (ip-addr/api/v1/).
Features
- Authenticate
- Read/Write settings
- Read process data
- Read events
- Download of log data
- Full async-Support for reading and writing data
- Commandline interface for shell access
- Dynamic data model - adapts automatically to new process data or settings
- Virtual Process Data values
Getting Started
Prerequisites
You will need Python >=3.7.
Installing the library
Packages of this library are released on PyPI and can be
installed with pip
. Alternatively the packages can also be downloaded from
GitHub.
I recommend to use a virtual environment for this, because it installs the dependecies independently from the system. The installed CLI tools can then be called without activating the virtual environment it.
# Install with command line support
$ pip install pykoplenti[CLI]
# Install without command line support
$ pip install pykoplenti
Using the command line interface
Installing the libray with CLI
provides a new command.
$ pykoplenti --help
Usage: pykoplenti [OPTIONS] COMMAND [ARGS]...
Handling of global arguments with click
Options:
--host TEXT hostname or ip of the inverter
--port INTEGER port of the inverter (default 80)
--password TEXT the password
--password-file TEXT password file (default "secrets" in the current
working directory)
--help Show this message and exit.
Commands:
all-processdata Returns a list of all available process data.
all-settings Returns the ids of all settings.
read-processdata Returns the values of the given process data.
read-settings Read the value of the given settings.
repl Provides a simple REPL for executing API requests to...
write-settings Write the values of the given settings.
Visit Command Line Help for example usage.
Using the library from python
The library is fully async, there for you need an async loop and an async ClientSession
. Please refer to the
example directory for full code.
Import the client module:
from pykoplenti import ApiClient
To communicate with the inverter you need to instantiate the client:
# session is a aiohttp ClientSession
client = ApiClient(session, '192.168.1.100')
Login to gain full access to process data and settings:
await client.login(passwd)
Now you can access the API. For example to read process data values:
data = await client.get_process_data_values('devices:local', ['Inverter:State', 'Home_P'])
device_local = data['devices:local']
inverter_state = device_local['Inverter:State']
home_p = device_local['Home_P']
See the full example here: read_process_data.py.
If you should need installer access use the master key (printed on a label at the side of the inverter) and additionally pass your service code:
await client.login(my_master_key, service_code=my_service_code)
Documentation
Built With
- AIOHTTPO - asyncio for HTTP
- click - command line interface framework
- black - Python code formatter
- ruff - Python linter
- pydantic - Data validation library
- pytest - Python test framework
- mypy - Python type checker
- setuptools - Python packager
- tox - Automate testing
License
apache-2.0
Acknowledgments
- kilianknoll for the kostal-RESTAPI project
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
Built Distribution
File details
Details for the file pykoplenti-1.3.0.tar.gz
.
File metadata
- Download URL: pykoplenti-1.3.0.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1725085c5e956956d5b832259f0c04d803112836d9544e9f2fa79e0fa02a7aa9 |
|
MD5 | 4ae25d13ece2d3a7a100e48df0b07b58 |
|
BLAKE2b-256 | 699177b4718c686a8ae70393dc5716561e83a118863d1b222c36de56a8cb166d |
Provenance
The following attestation bundles were made for pykoplenti-1.3.0.tar.gz
:
Publisher:
ci.yaml
on stegm/pykoplenti
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pykoplenti-1.3.0.tar.gz
- Subject digest:
1725085c5e956956d5b832259f0c04d803112836d9544e9f2fa79e0fa02a7aa9
- Sigstore transparency entry: 148747915
- Sigstore integration time:
- Predicate type:
File details
Details for the file pykoplenti-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: pykoplenti-1.3.0-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 944980937f6e2768c04dfeec12de6453ec97c2f919a343fa60d40dd350edfde0 |
|
MD5 | 6f82dbc65cef749f9bee168c270fd64a |
|
BLAKE2b-256 | f2802fa4e49aa9ade3851e2fffb80073e9ad9c17740b6a522e32ce416cda67b6 |
Provenance
The following attestation bundles were made for pykoplenti-1.3.0-py3-none-any.whl
:
Publisher:
ci.yaml
on stegm/pykoplenti
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pykoplenti-1.3.0-py3-none-any.whl
- Subject digest:
944980937f6e2768c04dfeec12de6453ec97c2f919a343fa60d40dd350edfde0
- Sigstore transparency entry: 148747916
- Sigstore integration time:
- Predicate type: