# 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](https://github.com/stegm/pykoplenti/workflows/CI/badge.svg)
## Features
- Authenticate
- Read/Write settings
- Read process data
- Read events
- Download of log data
- Full async-Support for reading and writing data
- [Commandline interface](doc/command_line.md) for shell access
- Dynamic data model - adapts automatically to new process data or settings
- [Virtual Process Data](doc/virtual_process_data.md) values
## Getting Started
### Prerequisites
You will need Python >=3.7.
### Installing the library
Packages of this library are released on [PyPI](https://pypi.org/project/kostal-plenticore/) and can be
installed with `pip`. Alternatively the packages can also be downloaded from
[GitHub](https://github.com/stegm/pykoplenti/releases/).
I recommend to use a [virtual environment](https://docs.python.org/3/library/venv.html) 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.
```shell
# 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.
```shell
$ 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](doc/command_line.md) 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:
```python
from pykoplenti import ApiClient
```
To communicate with the inverter you need to instantiate the client:
```python
# session is a aiohttp ClientSession
client = ApiClient(session, '192.168.1.100')
```
Login to gain full access to process data and settings:
```python
await client.login(passwd)
```
Now you can access the API. For example to read process data values:
```python
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](examples/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:
```python
await client.login(my_master_key, service_code=my_service_code)
```
## Documentation
- [Command Line Interface](doc/command_line.md)
- [Examples](examples/)
- [Virtual Process Data](doc/virtual_process_data.md)
- [Notes about Process Data](doc/process_data.md)
## Built With
- [AIOHTTPO](https://docs.aiohttp.org/en/stable/) - asyncio for HTTP
- [click](https://click.palletsprojects.com/) - command line interface framework
- [black](https://github.com/psf/black) - Python code formatter
- [ruff](https://github.com/astral-sh/ruff) - Python linter
- [pytest](https://docs.pytest.org/) - Python test framework
- [mypy](https://mypy-lang.org/) - Python type checker
- [setuptools](https://github.com/pypa/setuptools) - Python packager
## License
apache-2.0
## Acknowledgments
- [kilianknoll](https://github.com/kilianknoll) for the kostal-RESTAPI project
Raw data
{
"_id": null,
"home_page": "https://github.com/stegm/pyclient_koplenti",
"name": "pykoplenti",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "rest kostal plenticore solar",
"author": "@stegm",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/fd/fd/8e508564fa6c5cb1a363ee1f8b1abc03e9522d2e54cb18b71bd7cc4bf813/pykoplenti-1.2.2.tar.gz",
"platform": null,
"description": "# Python Library for Accessing Kostal Plenticore Inverters\n\nThis repository provides a python library and command line interface for the REST-API of Kostal Plenticore Solar Inverter.\n\nThis 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/).\n\n![CI](https://github.com/stegm/pykoplenti/workflows/CI/badge.svg)\n\n## Features\n\n- Authenticate\n- Read/Write settings\n- Read process data\n- Read events\n- Download of log data\n- Full async-Support for reading and writing data\n- [Commandline interface](doc/command_line.md) for shell access\n- Dynamic data model - adapts automatically to new process data or settings\n- [Virtual Process Data](doc/virtual_process_data.md) values\n\n## Getting Started\n\n### Prerequisites\n\nYou will need Python >=3.7.\n\n### Installing the library\n\nPackages of this library are released on [PyPI](https://pypi.org/project/kostal-plenticore/) and can be\ninstalled with `pip`. Alternatively the packages can also be downloaded from\n[GitHub](https://github.com/stegm/pykoplenti/releases/).\n\nI recommend to use a [virtual environment](https://docs.python.org/3/library/venv.html) for this,\nbecause it installs the dependecies independently from the system. The installed CLI tools can then be called\nwithout activating the virtual environment it.\n\n```shell\n# Install with command line support\n$ pip install pykoplenti[CLI]\n\n# Install without command line support\n$ pip install pykoplenti\n```\n\n### Using the command line interface\n\nInstalling the libray with `CLI` provides a new command.\n\n```shell\n$ pykoplenti --help\nUsage: pykoplenti [OPTIONS] COMMAND [ARGS]...\n\n Handling of global arguments with click\n\nOptions:\n --host TEXT hostname or ip of the inverter\n --port INTEGER port of the inverter (default 80)\n --password TEXT the password\n --password-file TEXT password file (default \"secrets\" in the current\n working directory)\n\n --help Show this message and exit.\n\nCommands:\n all-processdata Returns a list of all available process data.\n all-settings Returns the ids of all settings.\n read-processdata Returns the values of the given process data.\n read-settings Read the value of the given settings.\n repl Provides a simple REPL for executing API requests to...\n write-settings Write the values of the given settings.\n```\n\nVisit [Command Line Help](doc/command_line.md) for example usage.\n\n### Using the library from python\n\nThe library is fully async, there for you need an async loop and an async `ClientSession`. Please refer to the\nexample directory for full code.\n\nImport the client module:\n\n```python\nfrom pykoplenti import ApiClient\n```\n\nTo communicate with the inverter you need to instantiate the client:\n\n```python\n# session is a aiohttp ClientSession\nclient = ApiClient(session, '192.168.1.100')\n```\n\nLogin to gain full access to process data and settings:\n\n```python\nawait client.login(passwd)\n```\n\nNow you can access the API. For example to read process data values:\n\n```python\ndata = await client.get_process_data_values('devices:local', ['Inverter:State', 'Home_P'])\n\ndevice_local = data['devices:local']\ninverter_state = device_local['Inverter:State']\nhome_p = device_local['Home_P']\n```\n\nSee the full example here: [read_process_data.py](examples/read_process_data.py).\n\nIf you should need installer access use the master key (printed on a label at the side of the inverter)\nand additionally pass your service code:\n\n```python\nawait client.login(my_master_key, service_code=my_service_code)\n```\n\n## Documentation\n\n- [Command Line Interface](doc/command_line.md)\n- [Examples](examples/)\n- [Virtual Process Data](doc/virtual_process_data.md)\n- [Notes about Process Data](doc/process_data.md)\n\n## Built With\n\n- [AIOHTTPO](https://docs.aiohttp.org/en/stable/) - asyncio for HTTP\n- [click](https://click.palletsprojects.com/) - command line interface framework\n- [black](https://github.com/psf/black) - Python code formatter\n- [ruff](https://github.com/astral-sh/ruff) - Python linter\n- [pytest](https://docs.pytest.org/) - Python test framework\n- [mypy](https://mypy-lang.org/) - Python type checker\n- [setuptools](https://github.com/pypa/setuptools) - Python packager\n\n## License\n\napache-2.0\n\n## Acknowledgments\n\n- [kilianknoll](https://github.com/kilianknoll) for the kostal-RESTAPI project\n",
"bugtrack_url": null,
"license": "",
"summary": "Python REST-Client for Kostal Plenticore Solar Inverters",
"version": "1.2.2",
"project_urls": {
"Homepage": "https://github.com/stegm/pyclient_koplenti",
"changelog": "https://github.com/stegm/pykoplenti/blob/master/CHANGELOG.md",
"issues": "https://github.com/stegm/pykoplenti/issues",
"repository": "https://github.com/stegm/pyclient_koplenti"
},
"split_keywords": [
"rest",
"kostal",
"plenticore",
"solar"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "71cd298b442ed683854c99f3cdb01a7361b28dc6c50ba007f24766d159b8c95f",
"md5": "580b211631a2a24e2933aa594cb7496e",
"sha256": "688c79be8f49b4ea65ed45dedf6be859443ed89351c93f08eeb62531d026e422"
},
"downloads": -1,
"filename": "pykoplenti-1.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "580b211631a2a24e2933aa594cb7496e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 20613,
"upload_time": "2023-11-12T09:56:36",
"upload_time_iso_8601": "2023-11-12T09:56:36.804955Z",
"url": "https://files.pythonhosted.org/packages/71/cd/298b442ed683854c99f3cdb01a7361b28dc6c50ba007f24766d159b8c95f/pykoplenti-1.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fdfd8e508564fa6c5cb1a363ee1f8b1abc03e9522d2e54cb18b71bd7cc4bf813",
"md5": "9e6295134b1472a0e2ae534dea774c3a",
"sha256": "e8da596a22030547430d84927256e8d0bedeb9333b1bb5c230c74c711850ba6b"
},
"downloads": -1,
"filename": "pykoplenti-1.2.2.tar.gz",
"has_sig": false,
"md5_digest": "9e6295134b1472a0e2ae534dea774c3a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 25034,
"upload_time": "2023-11-12T09:56:38",
"upload_time_iso_8601": "2023-11-12T09:56:38.259466Z",
"url": "https://files.pythonhosted.org/packages/fd/fd/8e508564fa6c5cb1a363ee1f8b1abc03e9522d2e54cb18b71bd7cc4bf813/pykoplenti-1.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-12 09:56:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "stegm",
"github_project": "pyclient_koplenti",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pykoplenti"
}