Skip to content
This repository has been archived by the owner on Jan 25, 2025. It is now read-only.

Commit

Permalink
Initial work to support custom register reads & channels
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinsanda committed May 31, 2023
1 parent 486dffa commit 282ed15
Show file tree
Hide file tree
Showing 16 changed files with 477 additions and 132 deletions.
54 changes: 34 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,46 @@ a browser (default user/pass: admin/admin) and getting it from the Status page.

### `solarman:logger` Thing Configuration

| Name | Type | Description | Default | Required | Advanced |
|-----------------|---------|-----------------------------------------------|--------------|----------|----------|
| hostname | text | Hostname or IP address of the Solarman logger | N/A | yes | no |
| serialNumber | text | Serial number of the Solarman logger | N/A | yes | no |
| inverterType | text | The type of inverter connected to the logger | deye_sg04lp3 | no | no |
| port | integer | Port of the Solarman logger | 8899 | no | yes |
| refreshInterval | integer | Interval the device is polled in sec. | 60 | no | yes |
| Name | Type | Description | Default | Required | Advanced |
|--------------------|---------|---------------------------------------------------------|--------------|----------|----------|
| hostname | text | Hostname or IP address of the Solarman logger | N/A | yes | no |
| serialNumber | text | Serial number of the Solarman logger | N/A | yes | no |
| inverterType | text | The type of inverter connected to the logger | deye_sg04lp3 | no | no |
| port | integer | Port of the Solarman logger | 8899 | no | yes |
| refreshInterval | integer | Interval the device is polled in sec. | 60 | no | yes |
| additionalRequests | text | Additional requests besides the ones in the deffinition | N/A | no | yes |


The `inverterType` parameter governs what registers the binding will read from the logger and what channels it will
expose.

Possible values:

| Inverter Type | Inverters supported | Notes |
|---------------------|---------------------------------------------|------------------------------------------------------------------|
| deye_hybrid | DEYE/Sunsynk/SolArk Hybrid inverters | used when no lookup specified |
| deye_sg04lp3 | DEYE/Sunsynk/SolArk Hybrid 8/12K-SG04LP3 | e.g. 12K-SG04LP3-EU |
| deye_string | DEYE/Sunsynk/SolArk String inverters | e.g. SUN-4/5/6/7/8/10/12K-G03 Plus |
| deye_2mppt | DEYE Microinverter with 2 MPPT Trackers | e.g. SUN600G3-EU-230 / SUN800G3-EU-230 / SUN1000G3-EU-230 |
| deye_4mppt | DEYE Microinverter with 4 MPPT Trackers | e.g. SUN1300G3-EU-230 / SUN1600G3-EU-230 / SUN2000G3-EU-230 |
| sofar_lsw3 | SOFAR Inverters | |
| sofar_g3hyd | SOFAR Hybrid Three-Phase inverter | HYD 6000 or rebranded (three-phase), ex. ZCS Azzurro 3PH HYD-ZSS |
| sofar_hyd3k-6k | SOFAR Hybrid Single-Phase inverter | HYD 6000 or rebranded (single-phase), ex. ZCS Azzurro HYD-ZSS |
| solis_hybrid | SOLIS Hybrid inverter | |
| solid_1p8k-5g | SOLIS 1P8K-5G | |
| zcs_azzurro-ktl-v3 | ZCS Azzurro KTL-V3 inverters | ZCS Azzurro 3.3/4.4/5.5/6.6 KTL-V3 (rebranded Sofar KTLX-G3) |
| Inverter Type | Inverters supported | Notes |
|--------------------|---------------------------------------------|------------------------------------------------------------------|
| deye_hybrid | DEYE/Sunsynk/SolArk Hybrid inverters | used when no lookup specified |
| deye_sg04lp3 | DEYE/Sunsynk/SolArk Hybrid 8/12K-SG04LP3 | e.g. 12K-SG04LP3-EU |
| deye_string | DEYE/Sunsynk/SolArk String inverters | e.g. SUN-4/5/6/7/8/10/12K-G03 Plus |
| deye_2mppt | DEYE Microinverter with 2 MPPT Trackers | e.g. SUN600G3-EU-230 / SUN800G3-EU-230 / SUN1000G3-EU-230 |
| deye_4mppt | DEYE Microinverter with 4 MPPT Trackers | e.g. SUN1300G3-EU-230 / SUN1600G3-EU-230 / SUN2000G3-EU-230 |
| sofar_lsw3 | SOFAR Inverters | |
| sofar_g3hyd | SOFAR Hybrid Three-Phase inverter | HYD 6000 or rebranded (three-phase), ex. ZCS Azzurro 3PH HYD-ZSS |
| sofar_hyd3k-6k-es | SOFAR Hybrid Single-Phase inverter | HYD 6000 or rebranded (single-phase), ex. ZCS Azzurro HYD-ZSS |
| solis_hybrid | SOLIS Hybrid inverter | |
| solid_1p8k-5g | SOLIS 1P8K-5G | |
| zcs_azzurro-ktl-v3 | ZCS Azzurro KTL-V3 inverters | ZCS Azzurro 3.3/4.4/5.5/6.6 KTL-V3 (rebranded Sofar KTLX-G3) |

The `additionalRequests` allows the user to specify additional address ranges to be polled. The format of the value is `mb_functioncode1:start1-end1, mb_functioncode2:start2-end2,...`
For example `"0x03:0x27D-0x27E"` will issue an additional read for Holding Registers between `0x27D` and `0x27E`.

This is useful when coupled with user defined channels, for example a thing definition like the one below will also read the register
for the AC frequency on a Deye inverter, besides the ones pre-defined in the `deye_sg04lp3` inverter definition.
```java
Thing solarman:logger:local [ hostname="x.x.x.x", inverterType="deye_sg04lp3", serialNumber="1234567890", additionalRequests="0x03:0x27D-0x27E" ] {
Channels:
Type number : Inverter_Frequency [scale="0.01", uom="Hz", rule="3", registers="0x27E"]
}
```

**Please note**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ public DefinitionParser() {

public InverterDefinition parseDefinition(String definitionId) {
ClassLoader cl = Objects.requireNonNull(getClass().getClassLoader());
try (InputStream is = cl.getResourceAsStream(String.format("definitions/%s.yaml", definitionId))) {
String definitionFileName = String.format("definitions/%s.yaml", definitionId);
try (InputStream is = cl.getResourceAsStream(definitionFileName)) {
if (is == null) {
logger.error("Unable to read definition file {}", definitionFileName);
return null;
}
return mapper.readValue(is, InverterDefinition.class);
} catch (IOException e) {
logger.error("Error parsing definition with ID: {}", definitionId, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.solarman.internal.modbus.SolarmanLoggerConnector;
import org.openhab.binding.solarman.internal.typeprovider.SolarmanChannelGroupTypeProvider;
import org.openhab.binding.solarman.internal.typeprovider.SolarmanChannelTypeProvider;
import org.openhab.binding.solarman.internal.typeprovider.SolarmanThingTypeProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.openhab.binding.solarman.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

/**
* The {@link SolarmanLoggerConfiguration} class contains fields mapping thing configuration parameters.
Expand All @@ -30,17 +31,20 @@ public class SolarmanLoggerConfiguration {
public String serialNumber = "";
public String inverterType = "sg04lp3";
public int refreshInterval = 30;
@Nullable
public String additionalRequests = "";

public SolarmanLoggerConfiguration() {
}

public SolarmanLoggerConfiguration(String hostname, Integer port, String serialNumber, String inverterType,
int refreshInterval) {
int refreshInterval, @Nullable String additionalRequests) {
this.hostname = hostname;
this.port = port;
this.serialNumber = serialNumber;
this.inverterType = inverterType;
this.refreshInterval = refreshInterval;
this.additionalRequests = additionalRequests;
}

public String getHostname() {
Expand All @@ -62,4 +66,9 @@ public String getInverterType() {
public int getRefreshInterval() {
return refreshInterval;
}

@Nullable
public String getAdditionalRequests() {
return additionalRequests;
}
}
Loading

0 comments on commit 282ed15

Please sign in to comment.