Baumus / rctjavalib

A library for communication with solar power inverters of the RCT power brand, not endorsed by or affiliated with the eponymous company.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rctjavalib

A library for communication with solar power inverters of the RCT power brand. This library is designed to interface with RCT power inverters using JavaScript.

RCT power is a registered trademark of RCT Power GmbH. This library is not provided by, endorsed by, supported by, or affiliated with the company in any way.

This library is a Java adaptation of the original Go-based library developed by Markus Noga, enhanced with additional features.

It is provided without any warranties, entirely for use at your own risk under an LGPL 2.1 license.

Credits

This project is based on the work of Markus Noga. His Go-based library can be found at https://github.com/mlnoga/rct. I thank Markus Noga for his valuable contribution to the community. Likewise, thanks to Stefan Valouch for his extensive insights and documentation provided with his project available at https://github.com/svalouch/python-rctclient that have contributed to the completion of this project.

Installation

To use the rctjavalib library in your project, you can install it via npm:

npm install rctjavalib

Usage

After installation, you can import and use the library in your JavaScript project:

const Connection = require('rctjavalib/connection.js');
const { Identifier } = require('rctjavalib/datagram.js');

// Establish a connection
const conn = new Connection('my-RCT-hostname-or-IP-address');
await conn.connect();

// Example: Query the power generated by Solar Generator A
const power = await conn.queryFloat32(Identifier.SOLAR_GEN_A_POWER_W);
console.log(`Solar generator A power: ${Math.round(power)} W`);

// Close the connection when done
conn.close();

Architecture

  • datagram.js: Defines basic constants such as commands, on-device identifiers, and datagram packets. It also handles conversions of datagram payloads to JavaScript types.
  • crc.js: Implements the cyclic redundancy check algorithm to ensure data integrity used by the RCT.
  • build.js: Provides functionality for assembling datagrams to send.
  • parse.js: Parses incoming bytes into datagrams.
  • connection.js: Integrates builders and parsers into a bidirectional connection with the device. It also offers convenience methods for synchronously querying identifiers.

Testing

The library uses Jest for testing. To run tests, use the following command:

npm test

This example demonstrates how to establish a connection, query the power generated by Solar Generator A, and then close the connection. You can use similar methods to query other data points by referencing the appropriate identifiers from the Identifier class in datagram.js.

About

A library for communication with solar power inverters of the RCT power brand, not endorsed by or affiliated with the eponymous company.

License:GNU Lesser General Public License v2.1


Languages

Language:JavaScript 100.0%