Skip to main content

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/).

CI

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.9.

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 (library only)
$ pip install pykoplenti

Using the command line interface

After installing with CLI support, you can use the command:

$ pykoplenti --help
Usage: python -m pykoplenti.cli [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       Password or master key (also device id)
  --service-code TEXT   service code for installer access
  --password-file FILE  Path to password file - deprecated, use --credentials
                        [default: secrets]
  --credentials FILE    Path to the credentials file. This has a simple ini-
                        format without sections. For user access, use the
                        'password'. For installer access, use the 'master-key'
                        and 'service-key'.
  --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.
  download-log      Download the log data from the inverter to a file.
  read-events       Returns the last events
  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
  • hatchling - Modern Python build backend
  • tox - Automate testing

License

apache-2.0

Acknowledgments

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

pykoplenti-1.5.0rc1.tar.gz (154.2 kB view details)

Uploaded Source

Built Distribution

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

pykoplenti-1.5.0rc1-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file pykoplenti-1.5.0rc1.tar.gz.

File metadata

  • Download URL: pykoplenti-1.5.0rc1.tar.gz
  • Upload date:
  • Size: 154.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pykoplenti-1.5.0rc1.tar.gz
Algorithm Hash digest
SHA256 6fb5839c090a91f7bab5c1a400ca526fae0fd376d855e8b89eeb79c279b63aa9
MD5 0e66a76ae5d85bd0b02989c194385d4c
BLAKE2b-256 c0763dfb749ff0d693e7d728daf2f0fd3042de3605816518f8148382809d31b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pykoplenti-1.5.0rc1.tar.gz:

Publisher: ci.yaml on stegm/pykoplenti

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pykoplenti-1.5.0rc1-py3-none-any.whl.

File metadata

  • Download URL: pykoplenti-1.5.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pykoplenti-1.5.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 dde3a984853f61878f07597b3ed84a805e7d40fa422411fa4b67403b706693bf
MD5 4659ac2531e99fd14a2973eb4d5e0b65
BLAKE2b-256 db242edc8cda7b09104069d3878a78f639b1c0873988b9647f407e48c8b49968

See more details on using hashes here.

Provenance

The following attestation bundles were made for pykoplenti-1.5.0rc1-py3-none-any.whl:

Publisher: ci.yaml on stegm/pykoplenti

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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