Skip to main content

rctclient - Python implementation of the RCT Power GmbH "Serial Communication Protocol"

This Python module implements the "Serial Communication Protocol" by RCT Power GmbH, used in their line of solar inverters. Appart from the API, it also includes a registry of object IDs and a command line tool. For development, a simple simulator is included.

This project is not in any way affiliated with or supported by RCT Power GmbH.

Documentation

Below is a quickstart guide, the project documentation is on Read the Docs.

Installing

Install and update using pip:

$ pip install -U rctclient

To install the dependencies required for the CLI tool:

$ pip install -U rctclient[cli]

Example

Let's read the current battery state of charge:

import socket, select, sys
from rctclient.frame import ReceiveFrame, make_frame
from rctclient.registry import REGISTRY as R
from rctclient.types import Command
from rctclient.utils import decode_value

# open the socket and connect to the remote device:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('192.168.0.1', 8899))

# query information about an object ID (here: battery.soc):
object_info = R.get_by_name('battery.soc')

# construct a frame that will send a read command for the object ID we want, and send it
send_frame = make_frame(command=Command.READ, id=object_info.object_id)
sock.send(send_frame)

# loop until we got the entire response frame
frame = ReceiveFrame()
while True:
    ready_read, _, _ = select.select([sock], [], [], 2.0)
    if sock in ready_read:
        # receive content of the input buffer
        buf = sock.recv(256)
        # if there is content, let the frame consume it
        if len(buf) > 0:
            frame.consume(buf)
            # if the frame is complete, we're done
            if frame.complete():
                break
        else:
            # the socket was closed by the device, exit
            sys.exit(1)

# decode the frames payload
value = decode_value(object_info.response_data_type, frame.data)

# and print the result:
print(f'Response value: {value}')

Reading values from the command line

The module installs the rctclient command (requires click). The subcommand read-values reads a single value from the device and returns its output. Here is a call example using the object ID with verbose output:

$ rctclient read-value --verbose --host 192.168.0.1 --id 0x959930BF
#413 0x959930BF battery.soc         SOC (State of charge)              0.29985150694847107

Without --verbose, the only thing that's printed is the received value. This is demonstrated below, where the --name parameter is used instead of the --id:

$ rctclient read-value --host 192.168.0.1 --name battery.soc
0.2998138964176178

This makes it suitable for use with scripting environments where one just needs some values. If --debug is added before the subcommands name, the log level is set to DEBUG and all log messages are sent to stderr, which allows for scripts to continue processing the value on stdout, while allowing for observations of the inner workings of the code.

Generating the documentation

The documentation is generated using Sphinx, and requires that the software be installed to the local environment (e.g. via virtualenv). With a local clone of the repository, do the following (activate your virtualenv before if so desired):

$ pip install -e .[docs,cli]
$ cd docs
$ make clean html

The documentation is put into the docs/_build/html directory, simply point your browser to the index.html file.

The documentation is also auto-generated after every commit and can be found at https://rctclient.readthedocs.io/.

Metadata

Release files for rctclient 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rctclient 0.0.6
File Size Uploaded
rctclient-0.0.6.tar.gz 66.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rctclient 0.0.6
File Interpreter ABI Platform
rctclient-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 127.8 kB

Release files / rctclient-0.0.6.tar.gz

Download URL rctclient-0.0.6.tar.gz
Size 66.4 kB
Tags Source
SHA-256 checksum
How to use checksums
60f9d8cb02ce691946e7cff705d3fb0c705e2f5ad33475b40c8b021815f4c621
BLAKE2b-256 checksum
How to use checksums
39be58c8f343509ab09bc291a760af2aa82d02d2593ee45f0c715ba23460602c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / rctclient-0.0.6-py3-none-any.whl

Download URL rctclient-0.0.6-py3-none-any.whl
Size 61.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d59e9d5cb4809cf50798a5382873e86e1a2ee60255eb1c1a588ad338631de76
BLAKE2b-256 checksum
How to use checksums
0d0b91d0c13e03e02595d97f75389a451a3087427d251e7156e736a9f4706514
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page