golrackpi

package module
v0.0.0-...-bfd875d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 14 Imported by: 2

README

golrackpi is a Go (Golang) Library Rest Api Client (for) Kostal Plenticore Inverters (with CLI)

Go Reference

This repository provides a Go (Golang) library for the undocumented REST-API of Kostal Plenticore Inverters. It uses the PIKO IQ / PLENTICORE plus API with its swagger documentation found at "inverter ip address"/api/v1/.

This library is not affiliated with Kostal and is no offical product of KOSTAL Solar Electric GmbH or any subsidiary company of Kostal Gruppe.

Features

  • Authenticate (Login, Logout, Check authentication)
  • Read settings
  • Read processdata
  • Read events

Additional:

  • Commandline interface (CLI) to get any kind of returned inverter data

Getting Started

Please be patient. The library is in development and currently in the last stage before a release will be published. So I'm cleaning up a bit and try to add some senseful comments and documentation in the next step.

...todo...

Installing the library

...todo...

Using the command line interface

 golrackpi is a small CLI application to read values from Kostal Plenticore Inverters.

Usage:
  golrackpi [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  events      Get the latest events
  help        Help about any command
  info        Returns miscellaneous information
  modules     List modules content
  processdata List processdata values
  settings    List settings content

Flags:
  -h, --help              help for golrackpi
  -p, --password string   Password (required)
  -m, --scheme string     Scheme (http or https, default http)
  -s, --server string     Server (e.g. inverter IP address) (required)

Use "golrackpi [command] --help" for more information about a command.


Using the library from Go

...todo...

Documentation

...todo...

License

MIT

Thanks to

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthClient

type AuthClient struct {
	Scheme    string
	Server    string
	Password  string
	SessionId string
}

AuthClient is the library's instance, it contains the configuration settings with SessionId after successful authentication

func New

func New() *AuthClient

New returns a blank AuthClient instance with default http scheme

func NewWithParameter

func NewWithParameter(param AuthClient) *AuthClient

NewWithParameter returns an AuthClient instance. It takes an AuthClient structure as parameter, so it's possible to submit all connection settings in one step.

func (*AuthClient) Events

func (c *AuthClient) Events() ([]EventData, error)

Events returns the latest events as a slice of EventData type

func (*AuthClient) EventsWithParam

func (c *AuthClient) EventsWithParam(language string, max int) ([]EventData, error)

EventsWithParam returns the latest events with localized descriptions. It returns a slice of EventData type. It takes as arguments the language string (currently available de-de, en-gb, es-es, fr-fr, hu-hu, it-it, nl-nl, pl-pl, pt-pt, cs-cz, el-gr and zh-cn) and the maximum number of events (default: 10)

func (*AuthClient) Login

func (c *AuthClient) Login() (string, error)

Login handles the complete authenciation and login process. In case of success it returns the session id.

func (*AuthClient) Logout

func (c *AuthClient) Logout() (bool, error)

Logout deletes the current session

func (*AuthClient) Me

func (c *AuthClient) Me() (map[string]interface{}, error)

Me returns information about the current user

func (*AuthClient) Modules

func (c *AuthClient) Modules() ([]ModuleData, error)

Modules returns a list of modules with their type

func (*AuthClient) ProcessData

func (c *AuthClient) ProcessData() ([]ProcessData, error)

ProcessData returns a slice of ProcessData type, i.e. a list of modules with a list of their process-data identifiers

func (*AuthClient) ProcessDataModule

func (c *AuthClient) ProcessDataModule(moduleId string) ([]ProcessDataValues, error)

ProcessDataModule returns a slice of ProcessDataValues returned by the request to the "processdata/moduleid" endpoint. It takes a moduleid and returns all processdata ids and their values according to the moduleid.

func (*AuthClient) ProcessDataModuleValues

func (c *AuthClient) ProcessDataModuleValues(moduleId string, processDataIds ...string) ([]ProcessDataValues, error)

ProcessDataModuleValues returns a slice of ProcessDataValues returned by a request of a moduleid and one or more of the processdataids which belongs to the moduleid.

func (*AuthClient) ProcessDataValues

func (c *AuthClient) ProcessDataValues(v []ProcessData) ([]ProcessDataValues, error)

ProcessDataValues returns a slice of ProcessDataValues by a request of an arbitrary number of modules with one or more processdataids according to the moduleid. It takes a slice of ProcessData as argument, so it's possible to submit several moduleids with an arbitrary number of their processdataids and get all processdata values with one request to the inverter.

func (*AuthClient) SetPassword

func (c *AuthClient) SetPassword(password string)

SetServer sets the password for user access of the Kostal inverter

func (*AuthClient) SetScheme

func (c *AuthClient) SetScheme(scheme string)

SetServer sets the scheme (http or https) of the Kostal inverter

func (*AuthClient) SetServer

func (c *AuthClient) SetServer(server string)

SetServer sets the IP address or FQDN of the Kostal inverter

func (*AuthClient) Settings

func (c *AuthClient) Settings() ([]SettingsData, error)

Settings returns a list of all modules with their setting identifiers and further parameters of the setting, i.e. max, min, default etc. Warning: The request returns a lot of data, so it takes some time.

func (*AuthClient) SettingsModule

func (c *AuthClient) SettingsModule(moduleid string) ([]SettingsValues, error)

SettingsModule returns a list of settings with settingids and their values of a moduleid

func (*AuthClient) SettingsModuleSetting

func (c *AuthClient) SettingsModuleSetting(moduleid string, settingid string) ([]SettingsValues, error)

SettingsModuleSetting returns a SettingsValues slice with length 1 according to the submitted moduleid and settingid parameter.

func (*AuthClient) SettingsModuleSettings

func (c *AuthClient) SettingsModuleSettings(moduleid string, settingids ...string) ([]SettingsValues, error)

SettingsModuleSettings returns a SettingsValues slice according to the submitted moduleid and settingids parameter. This function takes an arbitrary number of setting ids as arguments.

func (*AuthClient) Version

func (c *AuthClient) Version() (map[string]interface{}, error)

Version returns information about the API; currently name, hostname, sw_version and api_version

type AuthCreateSessionType

type AuthCreateSessionType struct {
	TransactionId string `json:"transactionId"`
	Iv            string `json:"iv"`
	Tag           string `json:"tag"`
	Payload       string `json:"payload"`
}

AuthCreateSessionType defines the JSON structure of the last step in the authentication process

type AuthFinishRequestType

type AuthFinishRequestType struct {
	TransactionId string `json:"transactionId"`
	Proof         string `json:"proof"`
}

AuthFinishRequestType defines the JSON structure of the second step in the authentication process

type AuthStartRequestType

type AuthStartRequestType struct {
	Nonce    string `json:"nonce"`
	Username string `json:"username"`
}

AuthStartRequestType defines the JSON structure of the first step in the authentication process

type EventData

type EventData struct {
	Description     string               `json:"description"`
	Category        string               `json:"category"`
	LongDescription string               `json:"long_description"`
	StartTime       timefix.InverterTime `json:"start_time"`
	Group           string               `json:"group"`
	EndTime         timefix.InverterTime `json:"end_time"`
	Code            int                  `json:"code"`
	IsActive        bool                 `json:"is_active"`
}

EventData specifies the structure of the response returned by a request to the "events" endpoint

type ModuleData

type ModuleData struct {
	Id   string `json:"id"`
	Type string `json:"type"`
}

ModuleData specifies the structure of the response returned by a request to the "modules" endpoint

type ProcessData

type ProcessData struct {
	ModuleId       string   `json:"moduleid"`
	ProcessDataIds []string `json:"processdataids"`
}

ProcessData specifies the structure of the response returned by a request to the "processdata" endpoint. Furthermore this type is used in the ProcessDataValues function to define an arbitrary number of moduleids and also an arbitrary number of their processdataids.

type ProcessDataValue

type ProcessDataValue struct {
	Unit  string      `json:"unit"`
	Id    string      `json:"id"`
	Value interface{} `json:"value"`
}

ProcessDataValue specifies the structure of a single processdata value with its Unit, Processdata-ID and Value

type ProcessDataValues

type ProcessDataValues struct {
	ModuleId    string             `json:"moduleid"`
	ProcessData []ProcessDataValue `json:"processdata"`
}

ProcessDataValues specifies the structure of the response returned by a request for processdata with moduleid and a slice of ProcessDataValue which contains the fields Unid, Id and Value

type SettingsData

type SettingsData struct {
	ModuleId string               `json:"moduleid"`
	Settings []SettingsDataValues `json:"settings"`
}

SettingsData specifies the structure of the response returned by a request to the "settings" endpoint. It embeds a slice of SettingsDataValues type.

type SettingsDataValues

type SettingsDataValues struct {
	Id      string      `json:"id"`
	Max     string      `json:"max"`
	Min     string      `json:"min"`
	Unit    string      `json:"unit"`
	Type    interface{} `json:"type"`
	Access  interface{} `json:"access"`
	Default string      `json:"default"`
}

SettingsDataValues specifies the structure of a setting element returned by a request to the "settings" endpoint

type SettingsValues

type SettingsValues struct {
	Id    string `json:"id"`
	Value string `json:"value"`
}

SettingsValues specifies the structure of the response returned by a request to the "settings/moduleid/..." endpoint. The structure defines a settingid and its value.

Directories

Path Synopsis
cmd
cli
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL