Package: pykoplenti
Python Library for Accessing Kostal Plenticore InvertersThis 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/).FeaturesAuthenticateRead/Write settingsRead process dataRead eventsDownload of log dataFull async-Support for reading and writing dataCommandline interfacefor shell accessDynamic data model - adapts automatically to new process data or settingsVirtual Process DatavaluesGetting StartedPrerequisitesYou will need Python >=3.7.Installing the libraryPackages of this library are released onPyPIand can be
installed withpip. Alternatively the packages can also be downloaded fromGitHub.I recommend to use avirtual environmentfor 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$pipinstallpykoplenti[CLI]# Install without command line support$pipinstallpykoplentiUsing the command line interfaceInstalling the libray withCLIprovides a new command.$pykoplenti--help
Usage:pykoplenti[OPTIONS]COMMAND[ARGS]...Handlingofglobalargumentswithclick

Options:--hostTEXThostnameoripoftheinverter--portINTEGERportoftheinverter(default80)--passwordTEXTthepassword--password-fileTEXTpasswordfile(default"secrets"inthecurrentworkingdirectory)--helpShowthismessageandexit.

Commands:all-processdataReturnsalistofallavailableprocessdata.all-settingsReturnstheidsofallsettings.read-processdataReturnsthevaluesofthegivenprocessdata.read-settingsReadthevalueofthegivensettings.replProvidesasimpleREPLforexecutingAPIrequeststo...write-settingsWritethevaluesofthegivensettings.VisitCommand Line Helpfor example usage.Using the library from pythonThe library is fully async, there for you need an async loop and an asyncClientSession. Please refer to the
example directory for full code.Import the client module:frompykoplentiimportApiClientTo communicate with the inverter you need to instantiate the client:# session is a aiohttp ClientSessionclient=ApiClient(session,'192.168.1.100')Login to gain full access to process data and settings:awaitclient.login(passwd)Now you can access the API. For example to read process data values:data=awaitclient.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:awaitclient.login(my_master_key,service_code=my_service_code)DocumentationCommand Line InterfaceExamplesVirtual Process DataNotes about Process DataBuilt WithAIOHTTPO- asyncio for HTTPclick- command line interface frameworkblack- Python code formatterruff- Python linterpytest- Python test frameworkmypy- Python type checkersetuptools- Python packagerLicenseapache-2.0Acknowledgmentskilianknollfor the kostal-RESTAPI project