[Solax] Changes in values parser for X3-Hybrid-G4 (#17549)

* Fixes in indexes from Ruepert #1

Signed-off-by: Konstantin Polihronov <polychronov@gmail.com>
This commit is contained in:
Konstantin Polihronov 2024-10-26 00:32:50 +03:00 committed by GitHub
parent 58f59055a4
commit 51e1205abf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 83 additions and 62 deletions

View File

@ -45,11 +45,11 @@ public interface LocalData {
LocalConnectRawDataBean getData();
default double getPV1Voltage() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getPV1Current() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default short getPV1Power() {
@ -57,11 +57,11 @@ public interface LocalData {
}
default double getPV2Voltage() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getPV2Current() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default short getPV2Power() {
@ -77,11 +77,11 @@ public interface LocalData {
}
default double getBatteryVoltage() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getBatteryCurrent() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default short getBatteryPower() {
@ -104,7 +104,7 @@ public interface LocalData {
return Short.MIN_VALUE;
}
default short getFeedInPower() {
default int getFeedInPower() {
return Short.MIN_VALUE;
}
@ -113,55 +113,55 @@ public interface LocalData {
}
default double getTotalEnergy() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default short getTotalBatteryDischargeEnergy() {
return Short.MIN_VALUE;
default double getTotalBatteryDischargeEnergy() {
return Integer.MIN_VALUE;
}
default short getTotalBatteryChargeEnergy() {
return Short.MIN_VALUE;
default double getTotalBatteryChargeEnergy() {
return Integer.MIN_VALUE;
}
default double getTotalPVEnergy() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default short getTotalFeedInEnergy() {
return Short.MIN_VALUE;
default double getTotalFeedInEnergy() {
return Integer.MIN_VALUE;
}
default double getTotalConsumption() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getTodayEnergy() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getTodayFeedInEnergy() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getTodayConsumption() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getTodayBatteryDischargeEnergy() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getTodayBatteryChargeEnergy() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getInverterVoltage() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getInverterCurrent() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default short getInverterOutputPower() {
@ -169,31 +169,31 @@ public interface LocalData {
}
default double getInverterFrequency() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getVoltagePhase1() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getVoltagePhase2() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getVoltagePhase3() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getCurrentPhase1() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getCurrentPhase2() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getCurrentPhase3() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default short getOutputPowerPhase1() {
@ -213,15 +213,15 @@ public interface LocalData {
}
default double getFrequencyPhase1() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getFrequencyPhase2() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default double getFrequencyPhase3() {
return Short.MIN_VALUE;
return Integer.MIN_VALUE;
}
default short getInverterWorkModeCode() {

View File

@ -49,7 +49,7 @@ public class X1HybridG4Data extends CommonLocalDeviceData {
}
@Override
public short getFeedInPower() {
public int getFeedInPower() {
return getFromRawData(32);
}

View File

@ -14,6 +14,7 @@ package org.openhab.binding.solax.internal.model.local;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.solax.internal.connectivity.rawdata.local.LocalConnectRawDataBean;
import org.openhab.binding.solax.internal.util.ByteUtil;
/**
* The {@link X3HybridG4Data} is an implementation of the single phased inverter data interface for X3 Hybrid G4
@ -129,7 +130,7 @@ public class X3HybridG4Data extends CommonLocalDeviceData {
@Override
public double getBatteryVoltage() {
return ((double) getFromRawData(39)) / 100;
return ((double) ByteUtil.read32BitSigned(getFromRawData(169), getFromRawData(170))) / 100;
}
@Override
@ -155,8 +156,8 @@ public class X3HybridG4Data extends CommonLocalDeviceData {
// Feed in power
@Override
public short getFeedInPower() {
return (short) (getFromRawData(34) - getFromRawData(35));
public int getFeedInPower() {
return ByteUtil.read32BitSigned(getFromRawData(34), getFromRawData(35));
}
// Totals
@ -168,47 +169,47 @@ public class X3HybridG4Data extends CommonLocalDeviceData {
@Override
public double getTotalEnergy() {
return ((double) getFromRawData(68)) / 10;
return ((double) ByteUtil.read32BitSigned(getFromRawData(68), getFromRawData(69))) / 10;
}
@Override
public short getTotalBatteryDischargeEnergy() {
return getFromRawData(74);
public double getTotalBatteryDischargeEnergy() {
return ((double) ByteUtil.read32BitSigned(getFromRawData(74), getFromRawData(75))) / 10;
}
@Override
public short getTotalBatteryChargeEnergy() {
return getFromRawData(76);
public double getTotalBatteryChargeEnergy() {
return ((double) ByteUtil.read32BitSigned(getFromRawData(76), getFromRawData(77))) / 10;
}
@Override
public double getTotalPVEnergy() {
return ((double) getFromRawData(80)) / 10;
return ((double) ByteUtil.read32BitSigned(getFromRawData(80), getFromRawData(81))) / 10;
}
@Override
public short getTotalFeedInEnergy() {
return getFromRawData(86);
public double getTotalFeedInEnergy() {
return ((double) ByteUtil.read32BitSigned(getFromRawData(86), getFromRawData(87))) / 100;
}
@Override
public double getTotalConsumption() {
return ((double) getFromRawData(88)) / 10;
return ((double) ByteUtil.read32BitSigned(getFromRawData(88), getFromRawData(89))) / 10;
}
@Override
public double getTodayEnergy() {
return ((double) getFromRawData(82)) / 10;
return ((double) getFromRawData(70)) / 10;
}
@Override
public double getTodayFeedInEnergy() {
return ((double) getFromRawData(90)) / 100;
return ((double) ByteUtil.read32BitSigned(getFromRawData(90), getFromRawData(91))) / 100;
}
@Override
public double getTodayConsumption() {
return ((double) getFromRawData(92)) / 100;
return ((double) ByteUtil.read32BitSigned(getFromRawData(92), getFromRawData(93))) / 100;
}
@Override

View File

@ -45,7 +45,8 @@ public class X3HybridG4DataParser implements RawDataParser {
CHANNEL_INVERTER_OUTPUT_FREQUENCY_PHASE3, CHANNEL_POWER_USAGE, CHANNEL_TOTAL_ENERGY,
CHANNEL_TOTAL_BATTERY_CHARGE_ENERGY, CHANNEL_TOTAL_PV_ENERGY, CHANNEL_TOTAL_CONSUMPTION,
CHANNEL_TODAY_ENERGY, CHANNEL_TODAY_FEED_IN_ENERGY, CHANNEL_TODAY_CONSUMPTION,
CHANNEL_TODAY_BATTERY_CHARGE_ENERGY, CHANNEL_TODAY_BATTERY_DISCHARGE_ENERGY, CHANNEL_INVERTER_WORKMODE);
CHANNEL_TODAY_BATTERY_CHARGE_ENERGY, CHANNEL_TODAY_BATTERY_DISCHARGE_ENERGY, CHANNEL_INVERTER_WORKMODE,
CHANNEL_TOTAL_FEED_IN_ENERGY, CHANNEL_TOTAL_BATTERY_DISCHARGE_ENERGY);
@Override
public LocalData getData(LocalConnectRawDataBean rawData) {

View File

@ -31,14 +31,15 @@ public class TestX3HybridG4Parser extends AbstractParserTest {
{
sn:XYZ,
ver:3.005.01,
type:14,Data:[
type:14,
Data:[
2316,2329,2315,18,18,18,372,363,365,1100,
12,23,34,45,56,67,4996,4996,4996,2,
0,0,0,0,0,0,0,0,0,0,
0,0,0,1,65494,65535,0,0,0,31330,
320,1034,3078,1,44,1100,256,1294,0,0,
7445,5895,100,0,38,0,0,0,0,0,
0,0,0,0,0,0,0,0,505,0,
0,0,0,0,0,0,0,0,588,1,
396,0,0,0,102,0,142,0,62,110,
570,0,463,0,0,0,1925,0,369,0,
506,1925,304,309,0,0,0,0,0,0,
@ -47,6 +48,24 @@ public class TestX3HybridG4Parser extends AbstractParserTest {
Information:[12.000,14,XY,8,1.23,0.00,1.24,1.09,0.00,1]
}
""";
private static final String RAW_DATA_X3_RUEPERT = """
{
"sn":"SRABCDEFGH",
"ver":"3.009.03",
"type":14,
"Data":[
2367,2360,2375,10,10,10,48,48,58,154,
6077,5297,19,19,1177,1058,5003,5003,5003,2,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,32310,
600,1971,3213,61,1959,1,46,154,256,10528,
3083,6154,100,0,34,0,0,0,0,0,
0,0,0,0,0,0,0,0,2380,1,
52,77,0,0,6253,0,7500,0,37,46,
6854,1,64,4,0,0,2662,8,10050,0,
30,0,518,0,0,0,0,0,0,0,
0,0,1,51,1,23,47,256,3504,2400,300,300,249,227,34,33,74,1620,1024,16448,16448,16448,0,0,0,3352,3344,57729,21,20564,12339,18753,12354,16694,13124,12848,20564,12339,19010,12857,16690,13124,13368,20564,12339,19010,12601,16691,12356,12597,20564,12339,19010,12601,16691,12356,14387,0,0,0,0,0,0,0,515,257,1281,1027,0,32310,0,0,0,0,0,0,0,0,0,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"Information":[10.000,14,"H34A10IA999999",8,1.41,0.00,1.40,1.09,0.00,1]}
""";
@Override
protected InverterType getInverterType() {
@ -86,9 +105,9 @@ public class TestX3HybridG4Parser extends AbstractParserTest {
assertEquals(2, data.getInverterWorkModeCode()); // [19]
assertEquals("2", data.getInverterWorkMode()); // [19]
assertEquals(-41, data.getFeedInPower()); // [34] - [35]
assertEquals(-42, data.getFeedInPower()); // [34][35]
assertEquals(313.3, data.getBatteryVoltage()); // [39]
assertEquals(2.59, data.getBatteryVoltage()); // [39]
assertEquals(3.2, data.getBatteryCurrent()); // [40]
assertEquals(1034, data.getBatteryPower()); // [41]
assertEquals(45, data.getBatteryLevel()); // [103]
@ -96,15 +115,15 @@ public class TestX3HybridG4Parser extends AbstractParserTest {
// Totals
assertEquals(1294, data.getPowerUsage()); // [47]
assertEquals(50.5, data.getTotalEnergy()); // [68]
assertEquals(102, data.getTotalBatteryDischargeEnergy()); // [74]
assertEquals(142, data.getTotalBatteryChargeEnergy()); // [76]
assertEquals(57, data.getTotalPVEnergy()); // [80]
assertEquals(1925, data.getTotalFeedInEnergy()); // [86]
assertEquals(6612.4, data.getTotalEnergy()); // [68][69]
assertEquals(10.2, data.getTotalBatteryDischargeEnergy()); // [74][75]
assertEquals(14.2, data.getTotalBatteryChargeEnergy()); // [76][77]
assertEquals(57, data.getTotalPVEnergy()); // [80][81]
assertEquals(19.25, data.getTotalFeedInEnergy()); // [86][87]
assertEquals(36.9, data.getTotalConsumption()); // [88]
assertEquals(46.3, data.getTodayEnergy()); // [82] / 10
assertEquals(5.06, data.getTodayFeedInEnergy()); // [90] / 100
assertEquals(3.04, data.getTodayConsumption()); // [92] / 100
assertEquals(39.6, data.getTodayEnergy()); // [82] / 10
assertEquals(1261573.06, data.getTodayFeedInEnergy()); // [90][91] / 100
assertEquals(202509.28, data.getTodayConsumption()); // [92][93] / 100
assertEquals(6.2, data.getTodayBatteryDischargeEnergy()); // [78] / 100
assertEquals(11, data.getTodayBatteryChargeEnergy()); // [79] / 100
}