From d1caa31d6a4763f9836ae74d387acda78d9bb984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20T=C3=B3th?= Date: Sat, 10 Feb 2024 15:17:43 +0100 Subject: [PATCH] [solax] Add support for Solax X3MIC / G2 inverter and workmode channel (#16248) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Support for Solax X3MIC / G2 inverter, and workmode channel for the existing X1, X3 also * Add update instructions and make raise the target version to 1 * Refactor the workmode to be enum instead of string constants Signed-off-by: Henrik Tóth Signed-off-by: Konstantin Polihronov Signed-off-by: Leo Siepel --- .../solax/internal/SolaxBindingConstants.java | 3 + .../internal/SolaxLocalAccessHandler.java | 6 + .../solax/internal/model/InverterData.java | 16 ++ .../solax/internal/model/InverterType.java | 3 +- .../model/impl/X1HybridG4InverterData.java | 5 + .../model/impl/X3HybridG4InverterData.java | 5 + .../model/impl/X3MicOrProG2InverterData.java | 153 ++++++++++++++++++ .../model/parsers/X1HybridG4DataParser.java | 2 +- .../model/parsers/X3HybridG4DataParser.java | 2 +- .../model/parsers/X3MicOrProG2DataParser.java | 55 +++++++ .../resources/OH-INF/i18n/solax.properties | 36 ++++- .../resources/OH-INF/thing/channel_types.xml | 33 ++++ .../OH-INF/thing/localConnectInverter.xml | 27 +++- .../local_connect_inverter_type_update.xml | 19 +++ .../solax/internal/TestX1HybridG4Parser.java | 3 + .../solax/internal/TestX3HybridG4Parser.java | 3 + .../internal/TestX3MicOrProG2Parser.java | 97 +++++++++++ 17 files changed, 452 insertions(+), 16 deletions(-) create mode 100644 bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X3MicOrProG2InverterData.java create mode 100644 bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X3MicOrProG2DataParser.java create mode 100644 bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX3MicOrProG2Parser.java diff --git a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/SolaxBindingConstants.java b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/SolaxBindingConstants.java index e04633e377b..39d0b3ba6eb 100644 --- a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/SolaxBindingConstants.java +++ b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/SolaxBindingConstants.java @@ -61,6 +61,9 @@ public class SolaxBindingConstants { public static final String CHANNEL_INVERTER_OUTPUT_FREQUENCY_PHASE1 = "inverter-frequency-phase1"; public static final String CHANNEL_INVERTER_OUTPUT_FREQUENCY_PHASE2 = "inverter-frequency-phase2"; public static final String CHANNEL_INVERTER_OUTPUT_FREQUENCY_PHASE3 = "inverter-frequency-phase3"; + public static final String CHANNEL_INVERTER_TEMPERATURE1 = "inverter-temperature1"; + public static final String CHANNEL_INVERTER_TEMPERATURE2 = "inverter-temperature2"; + public static final String CHANNEL_INVERTER_WORKMODE = "inverter-workmode"; // Generic public static final String CHANNEL_INVERTER_PV1_POWER = "pv1-power"; diff --git a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/SolaxLocalAccessHandler.java b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/SolaxLocalAccessHandler.java index 94b418f3651..dd17e7bc27b 100644 --- a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/SolaxLocalAccessHandler.java +++ b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/SolaxLocalAccessHandler.java @@ -190,12 +190,18 @@ public class SolaxLocalAccessHandler extends BaseThingHandler { supportedChannels); updateChannel(SolaxBindingConstants.CHANNEL_BATTERY_TEMPERATURE, inverterData.getBatteryTemperature(), SIUnits.CELSIUS, supportedChannels); + updateChannel(SolaxBindingConstants.CHANNEL_INVERTER_TEMPERATURE1, inverterData.getInverterTemperature1(), + SIUnits.CELSIUS, supportedChannels); + updateChannel(SolaxBindingConstants.CHANNEL_INVERTER_TEMPERATURE2, inverterData.getInverterTemperature2(), + SIUnits.CELSIUS, supportedChannels); updateChannel(SolaxBindingConstants.CHANNEL_BATTERY_STATE_OF_CHARGE, inverterData.getBatteryLevel(), Units.PERCENT, supportedChannels); updateChannel(SolaxBindingConstants.CHANNEL_FEED_IN_POWER, inverterData.getFeedInPower(), Units.WATT, supportedChannels); updateChannel(SolaxBindingConstants.CHANNEL_POWER_USAGE, inverterData.getPowerUsage(), Units.WATT, supportedChannels); + updateState(SolaxBindingConstants.CHANNEL_INVERTER_WORKMODE, + new StringType(inverterData.getInverterWorkMode())); // Totals updateChannel(SolaxBindingConstants.CHANNEL_TOTAL_ENERGY, inverterData.getTotalEnergy(), Units.KILOWATT_HOUR, diff --git a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/InverterData.java b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/InverterData.java index 04c60aed7b4..429e3367819 100644 --- a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/InverterData.java +++ b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/InverterData.java @@ -82,6 +82,22 @@ public interface InverterData { return Short.MIN_VALUE; } + default short getInverterTemperature1() { + return Short.MIN_VALUE; + } + + default short getInverterTemperature2() { + return Short.MIN_VALUE; + } + + default short getInverterWorkModeCode() { + return Short.MIN_VALUE; + } + + default String getInverterWorkMode() { + return String.valueOf(getInverterWorkModeCode()); + } + default short getBatteryLevel() { return Short.MIN_VALUE; } diff --git a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/InverterType.java b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/InverterType.java index 072a0e9abbd..9d87543dfe7 100644 --- a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/InverterType.java +++ b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/InverterType.java @@ -21,6 +21,7 @@ import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.solax.internal.model.parsers.RawDataParser; import org.openhab.binding.solax.internal.model.parsers.X1HybridG4DataParser; import org.openhab.binding.solax.internal.model.parsers.X3HybridG4DataParser; +import org.openhab.binding.solax.internal.model.parsers.X3MicOrProG2DataParser; /** * The {@link InverterType} class is enum representing the different inverter types with a simple logic to convert from @@ -46,7 +47,7 @@ public enum InverterType { J1_ESS(13), X3_HYBRID_G4(14, new X3HybridG4DataParser()), X1_HYBRID_G4(15, new X1HybridG4DataParser()), - X3_MIC_OR_PRO_G2(16), + X3_MIC_OR_PRO_G2(16, new X3MicOrProG2DataParser()), X1_SPT(17), X1_BOOST_OR_MINI_G4(18), A1_HYB_G2(19), diff --git a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X1HybridG4InverterData.java b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X1HybridG4InverterData.java index 238176b0472..ead4e053024 100644 --- a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X1HybridG4InverterData.java +++ b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X1HybridG4InverterData.java @@ -83,6 +83,11 @@ public class X1HybridG4InverterData extends CommonInverterData { return getData(9); } + @Override + public short getInverterWorkModeCode() { + return getData(10); + } + @Override public double getBatteryVoltage() { return ((double) getData(14)) / 100; diff --git a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X3HybridG4InverterData.java b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X3HybridG4InverterData.java index 92f57373f1c..48ec4b707bd 100644 --- a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X3HybridG4InverterData.java +++ b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X3HybridG4InverterData.java @@ -125,6 +125,11 @@ public class X3HybridG4InverterData extends CommonInverterData { return ((double) getData(18)) / 100; } + @Override + public short getInverterWorkModeCode() { + return getData(19); + } + // Battery @Override diff --git a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X3MicOrProG2InverterData.java b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X3MicOrProG2InverterData.java new file mode 100644 index 00000000000..ddf6fb379cc --- /dev/null +++ b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/impl/X3MicOrProG2InverterData.java @@ -0,0 +1,153 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.solax.internal.model.impl; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.solax.internal.connectivity.rawdata.LocalConnectRawDataBean; + +/** + * The {@link X3HybridG4InverterData} is responsible for handling commands, which are + * sent to one of the channels. + * + * @author Henrik Tóth - Initial contribution + * (based on X1/X3 G4 parser from Konstantin Polihronov) + */ +@NonNullByDefault +public class X3MicOrProG2InverterData extends CommonInverterData { + + public X3MicOrProG2InverterData(LocalConnectRawDataBean data) { + super(data); + } + + // Inverter data + + @Override + public double getVoltagePhase1() { + return ((double) getData(0)) / 10; + } + + @Override + public double getVoltagePhase2() { + return ((double) getData(1)) / 10; + } + + @Override + public double getVoltagePhase3() { + return ((double) getData(2)) / 10; + } + + @Override + public double getCurrentPhase1() { + return ((double) getData(3)) / 10; + } + + @Override + public double getCurrentPhase2() { + return ((double) getData(4)) / 10; + } + + @Override + public double getCurrentPhase3() { + return ((double) getData(5)) / 10; + } + + @Override + public short getOutputPowerPhase1() { + return getData(6); + } + + @Override + public short getOutputPowerPhase2() { + return getData(7); + } + + @Override + public short getOutputPowerPhase3() { + return getData(8); + } + + @Override + public double getPV1Voltage() { + return ((double) getData(9)) / 10; + } + + @Override + public double getPV2Voltage() { + return ((double) getData(10)) / 10; + } + + @Override + public double getPV1Current() { + return ((double) getData(12)) / 10; + } + + @Override + public double getPV2Current() { + return ((double) getData(13)) / 10; + } + + @Override + public short getPV1Power() { + return getData(15); + } + + @Override + public short getPV2Power() { + return getData(16); + } + + @Override + public double getFrequencyPhase1() { + return ((double) getData(18)) / 100; + } + + @Override + public double getFrequencyPhase2() { + return ((double) getData(19)) / 100; + } + + @Override + public double getFrequencyPhase3() { + return ((double) getData(20)) / 100; + } + + @Override + public short getInverterWorkModeCode() { + return getData(21); + } + + @Override + public double getTotalEnergy() { + return ((double) getData(22)) / 10; + } + + @Override + public double getTodayEnergy() { + return ((double) getData(24)) / 10; + } + + @Override + public short getInverterTemperature1() { + return getData(26); + } + + @Override + public short getInverterTemperature2() { + return getData(27); + } + + @Override + public short getTotalOutputPower() { + return getData(78); + } +} diff --git a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X1HybridG4DataParser.java b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X1HybridG4DataParser.java index fd68cf15e32..538e937231f 100644 --- a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X1HybridG4DataParser.java +++ b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X1HybridG4DataParser.java @@ -36,7 +36,7 @@ public class X1HybridG4DataParser implements RawDataParser { CHANNEL_INVERTER_PV_TOTAL_CURRENT, CHANNEL_BATTERY_POWER, CHANNEL_BATTERY_VOLTAGE, CHANNEL_BATTERY_CURRENT, CHANNEL_BATTERY_TEMPERATURE, CHANNEL_BATTERY_STATE_OF_CHARGE, CHANNEL_FEED_IN_POWER, CHANNEL_TIMESTAMP, CHANNEL_RAW_DATA, CHANNEL_INVERTER_OUTPUT_POWER, CHANNEL_INVERTER_OUTPUT_CURRENT, - CHANNEL_INVERTER_OUTPUT_VOLTAGE, CHANNEL_INVERTER_OUTPUT_FREQUENCY); + CHANNEL_INVERTER_OUTPUT_VOLTAGE, CHANNEL_INVERTER_OUTPUT_FREQUENCY, CHANNEL_INVERTER_WORKMODE); @Override public InverterData getData(LocalConnectRawDataBean rawData) { diff --git a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X3HybridG4DataParser.java b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X3HybridG4DataParser.java index 4c814feade2..7f0680aa489 100644 --- a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X3HybridG4DataParser.java +++ b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X3HybridG4DataParser.java @@ -44,7 +44,7 @@ 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_TODAY_BATTERY_CHARGE_ENERGY, CHANNEL_TODAY_BATTERY_DISCHARGE_ENERGY, CHANNEL_INVERTER_WORKMODE); @Override public InverterData getData(LocalConnectRawDataBean rawData) { diff --git a/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X3MicOrProG2DataParser.java b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X3MicOrProG2DataParser.java new file mode 100644 index 00000000000..6a1660b1b4f --- /dev/null +++ b/bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/parsers/X3MicOrProG2DataParser.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.solax.internal.model.parsers; + +import static org.openhab.binding.solax.internal.SolaxBindingConstants.*; + +import java.util.Set; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.solax.internal.connectivity.rawdata.LocalConnectRawDataBean; +import org.openhab.binding.solax.internal.model.InverterData; +import org.openhab.binding.solax.internal.model.impl.X3MicOrProG2InverterData; + +/** + * The {@link X3MicOrProG2DataParser} is the implementation that parses raw data into a SinglePhaseInverterData for the + * X3 Mic / Pro G2 inverter. + * + * @author Henrik Tóth - Initial contribution + * (based on X1/X3 G4 parser from Konstantin Polihronov) + */ +@NonNullByDefault +public class X3MicOrProG2DataParser implements RawDataParser { + + private static final Set X3_MIC_OR_PRO_G2_SUPPORTED_CHANNELS = Set.of( + CHANNEL_INVERTER_OUTPUT_VOLTAGE_PHASE1, CHANNEL_INVERTER_OUTPUT_FREQUENCY_PHASE2, + CHANNEL_INVERTER_OUTPUT_VOLTAGE_PHASE3, CHANNEL_INVERTER_OUTPUT_CURRENT_PHASE1, + CHANNEL_INVERTER_OUTPUT_CURRENT_PHASE2, CHANNEL_INVERTER_OUTPUT_CURRENT_PHASE3, + CHANNEL_INVERTER_OUTPUT_POWER_PHASE1, CHANNEL_INVERTER_OUTPUT_POWER_PHASE2, + CHANNEL_INVERTER_OUTPUT_POWER_PHASE3, CHANNEL_INVERTER_PV1_VOLTAGE, CHANNEL_INVERTER_PV2_VOLTAGE, + CHANNEL_INVERTER_PV1_CURRENT, CHANNEL_INVERTER_PV2_CURRENT, CHANNEL_INVERTER_PV1_POWER, + CHANNEL_INVERTER_PV2_POWER, CHANNEL_INVERTER_OUTPUT_FREQUENCY_PHASE1, + CHANNEL_INVERTER_OUTPUT_VOLTAGE_PHASE2, CHANNEL_INVERTER_OUTPUT_FREQUENCY_PHASE3, CHANNEL_TOTAL_ENERGY, + CHANNEL_TODAY_ENERGY, CHANNEL_INVERTER_TOTAL_OUTPUT_POWER, CHANNEL_INVERTER_TEMPERATURE1, + CHANNEL_INVERTER_TEMPERATURE2, CHANNEL_INVERTER_WORKMODE, CHANNEL_RAW_DATA); + + @Override + public InverterData getData(LocalConnectRawDataBean rawData) { + return new X3MicOrProG2InverterData(rawData); + } + + @Override + public Set getSupportedChannels() { + return X3_MIC_OR_PRO_G2_SUPPORTED_CHANNELS; + } +} diff --git a/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/i18n/solax.properties b/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/i18n/solax.properties index 518f83a8399..7344060f394 100644 --- a/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/i18n/solax.properties +++ b/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/i18n/solax.properties @@ -27,12 +27,12 @@ thing-type.solax.local-connect-inverter.channel.inverter-current-phase2.label = thing-type.solax.local-connect-inverter.channel.inverter-current-phase2.description = Current to/from the inverter phase 2 thing-type.solax.local-connect-inverter.channel.inverter-current-phase3.label = Inverter Input/Output Current Phase 3 thing-type.solax.local-connect-inverter.channel.inverter-current-phase3.description = Current to/from the inverter phase 3 -thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase1.label = Inverter Voltage Phase 3 -thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase1.description = Voltage of the inverter's phase 3 -thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase2.label = Inverter Voltage Phase 2 -thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase2.description = Voltage of the inverter's phase 3 -thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase3.label = Inverter Voltage Phase 3 -thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase3.description = Voltage of the inverter's phase 3 +thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase1.label = Inverter Frequency Phase 1 +thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase1.description = Frequency of the inverter's phase 1 +thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase2.label = Inverter Frequency Phase 2 +thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase2.description = Frequency of the inverter's phase 2 +thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase3.label = Inverter Frequency Phase 3 +thing-type.solax.local-connect-inverter.channel.inverter-frequency-phase3.description = Frequency of the inverter's phase 3 thing-type.solax.local-connect-inverter.channel.inverter-output-power.label = Inverter Input/Output Power thing-type.solax.local-connect-inverter.channel.inverter-output-power.description = Power to/from the inverter thing-type.solax.local-connect-inverter.channel.inverter-output-power-phase1.label = Inverter Input/Output Power Phase 1 @@ -41,6 +41,10 @@ thing-type.solax.local-connect-inverter.channel.inverter-output-power-phase2.lab thing-type.solax.local-connect-inverter.channel.inverter-output-power-phase2.description = Power to/from the inverter phase 2 thing-type.solax.local-connect-inverter.channel.inverter-output-power-phase3.label = Inverter Input/Output Power Phase 3 thing-type.solax.local-connect-inverter.channel.inverter-output-power-phase3.description = Power to/from the inverter phase 3 +thing-type.solax.local-connect-inverter.channel.inverter-temperature1.label = Inverter Temperature 1 +thing-type.solax.local-connect-inverter.channel.inverter-temperature1.description = Temperature 1 of the inverter +thing-type.solax.local-connect-inverter.channel.inverter-temperature2.label = Inverter Temperature 2 +thing-type.solax.local-connect-inverter.channel.inverter-temperature2.description = Temperature 2 of the inverter thing-type.solax.local-connect-inverter.channel.inverter-total-output-power.label = Inverter Input/Output Total Power thing-type.solax.local-connect-inverter.channel.inverter-total-output-power.description = Power to/from the inverter on all phases thing-type.solax.local-connect-inverter.channel.inverter-voltage.label = Inverter Voltage @@ -51,6 +55,8 @@ thing-type.solax.local-connect-inverter.channel.inverter-voltage-phase2.label = thing-type.solax.local-connect-inverter.channel.inverter-voltage-phase2.description = Voltage of the inverter's phase 2 thing-type.solax.local-connect-inverter.channel.inverter-voltage-phase3.label = Inverter Voltage Phase 3 thing-type.solax.local-connect-inverter.channel.inverter-voltage-phase3.description = Voltage of the inverter's phase 3 +thing-type.solax.local-connect-inverter.channel.inverter-workmode.label = Inverter Workmode +thing-type.solax.local-connect-inverter.channel.inverter-workmode.description = Inverter Workmode thing-type.solax.local-connect-inverter.channel.power-usage.label = Power Usage thing-type.solax.local-connect-inverter.channel.power-usage.description = Current power consumption of the building thing-type.solax.local-connect-inverter.channel.pv-total-current.label = PV Total Current @@ -107,6 +113,24 @@ channel-type.solax.battery-temperature.label = Battery Temperature channel-type.solax.battery-temperature.description = Battery Temperature channel-type.solax.frequency.label = Electric Frequency channel-type.solax.frequency.description = Frequency of the electricity to/from the inverter +channel-type.solax.inverter-temperature.label = Inverter Temperature +channel-type.solax.inverter-temperature.description = Inverter Temperature +channel-type.solax.inverter-workmode.label = Inverter Workmode +channel-type.solax.inverter-workmode.description = Inverter Workmode +channel-type.solax.inverter-workmode.state.option.0 = Waiting +channel-type.solax.inverter-workmode.state.option.1 = Checking +channel-type.solax.inverter-workmode.state.option.2 = Normal +channel-type.solax.inverter-workmode.state.option.3 = Fault +channel-type.solax.inverter-workmode.state.option.4 = Permanent Fault +channel-type.solax.inverter-workmode.state.option.5 = Updating +channel-type.solax.inverter-workmode.state.option.6 = EPS Check +channel-type.solax.inverter-workmode.state.option.7 = EPS Normal +channel-type.solax.inverter-workmode.state.option.8 = Self Test +channel-type.solax.inverter-workmode.state.option.9 = Idle +channel-type.solax.inverter-workmode.state.option.10 = Standby +channel-type.solax.inverter-workmode.state.option.11 = PV Wake-up Battery +channel-type.solax.inverter-workmode.state.option.12 = GEN Check +channel-type.solax.inverter-workmode.state.option.13 = GEN Run channel-type.solax.last-retrieve-time-stamp.label = Last Retrieve Time Stamp channel-type.solax.last-retrieve-time-stamp.description = Last time with a successful retrieval of data channel-type.solax.raw-data-type.label = Raw Data diff --git a/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/thing/channel_types.xml b/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/thing/channel_types.xml index a1a814436d5..472c9eea76d 100644 --- a/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/thing/channel_types.xml +++ b/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/thing/channel_types.xml @@ -24,6 +24,39 @@ + + Number:Temperature + + Inverter Temperature + + Measurement + Temperature + + + + + String + + Inverter Workmode + + + + + + + + + + + + + + + + + + + DateTime diff --git a/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/thing/localConnectInverter.xml b/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/thing/localConnectInverter.xml index 67e4b20f18a..f3f10681598 100644 --- a/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/thing/localConnectInverter.xml +++ b/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/thing/localConnectInverter.xml @@ -67,16 +67,16 @@ Voltage of the inverter's phase 3 - - Voltage of the inverter's phase 3 + + Frequency of the inverter's phase 1 - - Voltage of the inverter's phase 3 + + Frequency of the inverter's phase 2 - - Voltage of the inverter's phase 3 + + Frequency of the inverter's phase 3 @@ -113,6 +113,19 @@ The sum of PV currents from all strings + + + Temperature 1 of the inverter + + + + Temperature 2 of the inverter + + + + Inverter Workmode + + Power to/from the battery @@ -193,7 +206,7 @@ - 1 + 2 diff --git a/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/update/local_connect_inverter_type_update.xml b/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/update/local_connect_inverter_type_update.xml index 1a1e54416d1..dc79f7bebfd 100644 --- a/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/update/local_connect_inverter_type_update.xml +++ b/bundles/org.openhab.binding.solax/src/main/resources/OH-INF/update/local_connect_inverter_type_update.xml @@ -130,5 +130,24 @@ Energy consumed for the day + + + + + solax:inverter-temperature + + Temperature 1 of the inverter + + + solax:inverter-temperature + + Temperature 2 of the inverter + + + solax:inverter-workmode + + Inverter Workmode + + diff --git a/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX1HybridG4Parser.java b/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX1HybridG4Parser.java index 08def71318e..c8c8c3ac974 100644 --- a/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX1HybridG4Parser.java +++ b/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX1HybridG4Parser.java @@ -69,6 +69,9 @@ public class TestX1HybridG4Parser { assertEquals(487, data.getPV1Power()); // [8] assertEquals(65, data.getPV2Power()); // [9] + assertEquals(2, data.getInverterWorkModeCode()); // [10] + assertEquals("2", data.getInverterWorkMode()); // [10] + assertEquals(121.8, data.getBatteryVoltage()); // [14] assertEquals(5, data.getBatteryCurrent()); // [15] assertEquals(605, data.getBatteryPower()); // [16] diff --git a/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX3HybridG4Parser.java b/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX3HybridG4Parser.java index 7bb4e972c5c..8c02197c80f 100644 --- a/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX3HybridG4Parser.java +++ b/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX3HybridG4Parser.java @@ -89,6 +89,9 @@ public class TestX3HybridG4Parser { assertEquals(49.96, data.getFrequencyPhase2()); // [17] assertEquals(49.96, data.getFrequencyPhase3()); // [18] + assertEquals(2, data.getInverterWorkModeCode()); // [19] + assertEquals("2", data.getInverterWorkMode()); // [19] + assertEquals(-41, data.getFeedInPower()); // [34] - [35] assertEquals(313.3, data.getBatteryVoltage()); // [39] diff --git a/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX3MicOrProG2Parser.java b/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX3MicOrProG2Parser.java new file mode 100644 index 00000000000..c3d353d7a94 --- /dev/null +++ b/bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/TestX3MicOrProG2Parser.java @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.solax.internal; + +import static org.junit.jupiter.api.Assertions.*; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.junit.jupiter.api.Test; +import org.openhab.binding.solax.internal.connectivity.rawdata.LocalConnectRawDataBean; +import org.openhab.binding.solax.internal.model.InverterData; +import org.openhab.binding.solax.internal.model.InverterType; +import org.openhab.binding.solax.internal.model.parsers.RawDataParser; + +/** + * The {@link TestX3HybridG4Parser} simple test that tests for proper parsing against a real data from the inverter + * + * @author Konstantin Polihronov - Initial contribution + */ +@NonNullByDefault +public class TestX3MicOrProG2Parser { + + String rawData = """ + { + sn:XYZ, + ver:3.003.02, + type:16,Data:[ + 2515,2449,2484,5,5,9,54,44,20,4080,4340, + 0,1,2,0,67,102,0,4999,4999,4999,2,19035, + 0,50,8000,5,9, + 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,1,0, + 0,0,0,0,0,0,0,0,120,40,1,6,5,0,6772,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0 + ], + Information:[8.000,16,XY,8,1.15,0.00,1.11,1.01,0.00,1] + } + """; + + @Test + public void testParser() { + LocalConnectRawDataBean bean = LocalConnectRawDataBean.fromJson(rawData); + int type = bean.getType(); + InverterType inverterType = InverterType.fromIndex(type); + assertEquals(InverterType.X3_MIC_OR_PRO_G2, inverterType, "Inverter type not recognized properly"); + + RawDataParser parser = inverterType.getParser(); + assertNotNull(parser); + + InverterData data = parser.getData(bean); + assertEquals("XYZ", data.getWifiSerial()); + assertEquals("3.003.02", data.getWifiVersion()); + + assertEquals(251.5, data.getVoltagePhase1()); // [0] + assertEquals(244.9, data.getVoltagePhase2()); // [1] + assertEquals(248.4, data.getVoltagePhase3()); // [2] + + assertEquals(0.5, data.getCurrentPhase1()); // [3] + assertEquals(0.5, data.getCurrentPhase2()); // [4] + assertEquals(0.9, data.getCurrentPhase3()); // [5] + + assertEquals(54, data.getOutputPowerPhase1()); // [6] + assertEquals(44, data.getOutputPowerPhase2()); // [7] + assertEquals(20, data.getOutputPowerPhase3()); // [8] + + assertEquals(408, data.getPV1Voltage()); // [9] + assertEquals(434, data.getPV2Voltage()); // [10] + assertEquals(0.1, data.getPV1Current()); // [12] + assertEquals(0.2, data.getPV2Current()); // [13] + assertEquals(67, data.getPV1Power()); // [15] + assertEquals(102, data.getPV2Power()); // [16] + + assertEquals(49.99, data.getFrequencyPhase1()); // [18] + assertEquals(49.99, data.getFrequencyPhase2()); // [19] + assertEquals(49.99, data.getFrequencyPhase3()); // [20] + + assertEquals(2, data.getInverterWorkModeCode()); // [21] + assertEquals("2", data.getInverterWorkMode()); // [21] + + assertEquals(5, data.getInverterTemperature1()); // [26] + assertEquals(9, data.getInverterTemperature2()); // [27] + + assertEquals(120, data.getTotalOutputPower()); // [78] + + assertEquals(1903.5, data.getTotalEnergy()); // [22] + assertEquals(5.0, data.getTodayEnergy()); // [24] + } +}