From 2d8c64417249b03a5f4e6acad84e6addf18fb262 Mon Sep 17 00:00:00 2001 From: martijnvdmolen Date: Thu, 31 Aug 2023 20:42:21 +0200 Subject: [PATCH 01/13] Add support for X1 Boost (FW Version 3) --- solax/inverters/x1_boost.py | 5 +- tests/fixtures.py | 12 ++++ tests/samples/expected_values.py | 19 ++++++ tests/samples/responses.py | 109 +++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+), 1 deletion(-) diff --git a/solax/inverters/x1_boost.py b/solax/inverters/x1_boost.py index 0ca8f44..7559504 100644 --- a/solax/inverters/x1_boost.py +++ b/solax/inverters/x1_boost.py @@ -23,7 +23,10 @@ class X1Boost(Inverter): vol.Required("Data"): vol.Schema( vol.All( [vol.Coerce(float)], - vol.Length(min=200, max=200), + vol.Any( + vol.Length(min=100, max=100), + vol.Length(min=200, max=200), + ), ) ), vol.Required("Information"): vol.Schema( diff --git a/tests/fixtures.py b/tests/fixtures.py index 4868ff7..f5047b1 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -6,6 +6,7 @@ from tests.samples.expected_values import ( QVOLTHYBG33P_VALUES, X1_BOOST_VALUES, + X1_BOOST_VALUES_V3, X1_HYBRID_G4_VALUES, X1_MINI_VALUES, X1_MINI_VALUES_V34, @@ -24,6 +25,7 @@ QVOLTHYBG33P_RESPONSE_V34, X1_BOOST_AIR_MINI_RESPONSE, X1_BOOST_RESPONSE, + X1_BOOST_RESPONSE_V3, X1_HYBRID_G3_2X_MPPT_RESPONSE, X1_HYBRID_G3_RESPONSE, X1_HYBRID_G4_RESPONSE, @@ -128,6 +130,16 @@ def simple_http_fixture(httpserver): headers=X_FORWARDED_HEADER, data=None, ), + InverterUnderTest( + uri="/", + method="POST", + query_string="optType=ReadRealTimeData", + response=X1_BOOST_RESPONSE_V3, + inverter=inverter.X1Boost, + values=X1_BOOST_VALUES_V3, + headers=X_FORWARDED_HEADER, + data=None, + ), InverterUnderTest( uri="/", method="POST", diff --git a/tests/samples/expected_values.py b/tests/samples/expected_values.py index f3d7a05..e562067 100644 --- a/tests/samples/expected_values.py +++ b/tests/samples/expected_values.py @@ -403,6 +403,25 @@ "Total Import Energy": 81.84, } +X1_BOOST_VALUES_V3 = { + "AC Voltage": 228.1, + "AC Output Current": 3.1, + "AC Output Power": 703.0, + "PV1 Voltage": 120.7, + "PV2 Voltage": 125.4, + "PV1 Current": 2.9, + "PV2 Current": 2.9, + "PV1 Power": 356.0, + "PV2 Power": 365.0, + "AC Frequency": 50.02, + "Total Generated Energy": 2029.3, + "Today's Generated Energy": 5.0, + "Inverter Temperature": 30.0, + "Exported Power": 0.0, + "Total Export Energy": 0.0, + "Total Import Energy": 0.0, +} + QVOLTHYBG33P_VALUES = { "Network Voltage Phase 1": 221.4, "Network Voltage Phase 2": 223.8, diff --git a/tests/samples/responses.py b/tests/samples/responses.py index ad65b18..8545324 100644 --- a/tests/samples/responses.py +++ b/tests/samples/responses.py @@ -859,6 +859,115 @@ "Information": [5.0, 4, "XXXXXXX", 1, 2.21, 0.00, 1.38, 0.00, 0.00, 1], } +X1_BOOST_RESPONSE_V3 = { + "sn": "XXXXXXX", + "ver": "3.006.04", + "type": 4, + "Data": [ + 2281, + 31, + 703, + 1207, + 1254, + 29, + 29, + 356, + 365, + 5002, + 2, + 20293, + 0, + 50, + 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, + 30, + 0, + 2152, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 36, + 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": [3, 4, "XXXXXXX", 8, 2.27, 0, 1.43, 0, 0, 1], +} + X3_MIC_RESPONSE = { "type": "X3-MIC", "SN": "XXXXXXX", From 6693cc2b9de97ea6198c7956052c35fc3cca1f60 Mon Sep 17 00:00:00 2001 From: rnauber <7414650+rnauber@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:02:35 +0200 Subject: [PATCH 02/13] Update x1_boost.py: relax the requirements on the type field to support v3 --- solax/inverters/x1_boost.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solax/inverters/x1_boost.py b/solax/inverters/x1_boost.py index 36d1470..282823f 100644 --- a/solax/inverters/x1_boost.py +++ b/solax/inverters/x1_boost.py @@ -9,14 +9,14 @@ class X1Boost(Inverter): """ - X1-Boost with Pocket WiFi 2.034.06 + X1-Boost with Pocket WiFi 2.034.06 or 3.009.03 Includes X-Forwarded-For for direct LAN API access """ # pylint: disable=duplicate-code _schema = vol.Schema( { - vol.Required("type", "type"): vol.All(int, 4), + vol.Required("type", "type"): int, vol.Required( "sn", ): str, From 1aeb8788e159283e6023e1381617d5c1c5aa1603 Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Mon, 10 Jun 2024 22:40:19 +0200 Subject: [PATCH 03/13] fix order of imports --- tests/fixtures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index b5d6b36..ed26dfe 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -7,8 +7,8 @@ from tests.samples.expected_values import ( QVOLTHYBG33P_VALUES, X1_BOOST_VALUES, - X1_BOOST_VALUES_V3, X1_BOOST_VALUES_OVERFLOWN, + X1_BOOST_VALUES_V3, X1_HYBRID_G4_VALUES, X1_MINI_VALUES, X1_MINI_VALUES_V34, @@ -29,8 +29,8 @@ QVOLTHYBG33P_RESPONSE_V34, X1_BOOST_AIR_MINI_RESPONSE, X1_BOOST_RESPONSE, - X1_BOOST_RESPONSE_V3, X1_BOOST_RESPONSE_OVERFLOWN, + X1_BOOST_RESPONSE_V3, X1_HYBRID_G3_2X_MPPT_RESPONSE, X1_HYBRID_G3_RESPONSE, X1_HYBRID_G4_RESPONSE, From 700850e610c9ab06f8a692f158f9607472432cad Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Tue, 11 Jun 2024 13:48:27 +0200 Subject: [PATCH 04/13] support x1_boost_g4 --- solax/inverters/__init__.py | 2 + solax/inverters/x1_boost.py | 4 +- solax/inverters/x1_boost_g4.py | 72 ++++++++++++++++++++ tests/fixtures.py | 14 ++++ tests/samples/expected_values.py | 21 +++++- tests/samples/responses.py | 109 +++++++++++++++++++++++++++++++ 6 files changed, 218 insertions(+), 4 deletions(-) create mode 100644 solax/inverters/x1_boost_g4.py diff --git a/solax/inverters/__init__.py b/solax/inverters/__init__.py index 039c947..fc4b45d 100644 --- a/solax/inverters/__init__.py +++ b/solax/inverters/__init__.py @@ -1,6 +1,7 @@ from .qvolt_hyb_g3_3p import QVOLTHYBG33P from .x1 import X1 from .x1_boost import X1Boost +from .x1_boost_g4 import X1BoostG4 from .x1_hybrid_gen4 import X1HybridGen4 from .x1_mini import X1Mini from .x1_mini_v34 import X1MiniV34 @@ -23,6 +24,7 @@ "X3HybridG4", "X3", "X1Boost", + "X1BoostG4", "X1HybridGen4", "X3MicProG2", "X3Ultra", diff --git a/solax/inverters/x1_boost.py b/solax/inverters/x1_boost.py index 282823f..36d1470 100644 --- a/solax/inverters/x1_boost.py +++ b/solax/inverters/x1_boost.py @@ -9,14 +9,14 @@ class X1Boost(Inverter): """ - X1-Boost with Pocket WiFi 2.034.06 or 3.009.03 + X1-Boost with Pocket WiFi 2.034.06 Includes X-Forwarded-For for direct LAN API access """ # pylint: disable=duplicate-code _schema = vol.Schema( { - vol.Required("type", "type"): int, + vol.Required("type", "type"): vol.All(int, 4), vol.Required( "sn", ): str, diff --git a/solax/inverters/x1_boost_g4.py b/solax/inverters/x1_boost_g4.py new file mode 100644 index 0000000..5cd0d6d --- /dev/null +++ b/solax/inverters/x1_boost_g4.py @@ -0,0 +1,72 @@ +from typing import Any, Dict, Optional + +import voluptuous as vol + +from solax.inverter import Inverter +from solax.units import DailyTotal, Total, Units +from solax.utils import div10, div100, pack_u16, to_signed + + +class X1BoostG4(Inverter): + """ + X1-Boost gen 4 with Pocket WiFi 3.009.03 + Includes X-Forwarded-For for direct LAN API access + """ + + # pylint: disable=duplicate-code + _schema = vol.Schema( + { + vol.Required("type", "type"): vol.All(int, 18), + vol.Required( + "sn", + ): str, + vol.Required("ver"): str, + vol.Required("data"): vol.Schema( + vol.All( + [vol.Coerce(float)], + vol.Length(min=100, max=100) + ) + ), + vol.Required("information"): vol.Schema( + vol.All(vol.Length(min=10, max=10)) + ), + }, + extra=vol.REMOVE_EXTRA, + ) + + @classmethod + def response_decoder(cls): + return { + "AC Voltage": (0, Units.V, div10), + "AC Output Current": (1, Units.A, div10), + "AC Output Power": (3, Units.W), + "PV1 Voltage": (4, Units.V, div10), + "PV2 Voltage": (5, Units.V, div10), + "PV1 Current": (8, Units.A, div10), + "PV2 Current": (9, Units.A, div10), + "PV1 Power": (13, Units.W), + "PV2 Power": (14, Units.W), + "AC Frequency": (2, Units.HZ, div100), + "Total Generated Energy": (pack_u16(19, 20), Total(Units.KWH), div10), + "Today's Generated Energy": (21, DailyTotal(Units.KWH), div10), + "Inverter Temperature": (28, Units.C, div10), + "Exported Power": (pack_u16(72, 73), Units.W, to_signed), + "Total Export Energy": (pack_u16(74, 75), Total(Units.KWH), div100), + "Total Import Energy": (pack_u16(76, 77), Total(Units.KWH), div100), + } + + @classmethod + def inverter_serial_number_getter(cls, response: Dict[str, Any]) -> Optional[str]: + return response["information"][2] + + @classmethod + def build_all_variants(cls, host, port, pwd=""): + versions = [ + cls._build(host, port, pwd, True), + cls._build(host, port, pwd, False), + ] + for inverter in versions: + inverter.http_client = inverter.http_client.with_headers( + {"X-Forwarded-For": "5.8.8.8"} + ) + return versions diff --git a/tests/fixtures.py b/tests/fixtures.py index ed26dfe..7ca2301 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -9,6 +9,7 @@ X1_BOOST_VALUES, X1_BOOST_VALUES_OVERFLOWN, X1_BOOST_VALUES_V3, + X1_BOOST_VALUES_G4_V3, X1_HYBRID_G4_VALUES, X1_MINI_VALUES, X1_MINI_VALUES_V34, @@ -31,6 +32,7 @@ X1_BOOST_RESPONSE, X1_BOOST_RESPONSE_OVERFLOWN, X1_BOOST_RESPONSE_V3, + X1_BOOST_RESPONSE_G4_V3, X1_HYBRID_G3_2X_MPPT_RESPONSE, X1_HYBRID_G3_RESPONSE, X1_HYBRID_G4_RESPONSE, @@ -147,6 +149,18 @@ def simple_http_fixture(httpserver): headers=X_FORWARDED_HEADER, data=None, ), + + InverterUnderTest( + uri="/", + method="POST", + query_string="optType=ReadRealTimeData", + response=X1_BOOST_RESPONSE_G4_V3, + inverter=inverter.X1BoostG4, + values=X1_BOOST_VALUES_G4_V3, + headers=X_FORWARDED_HEADER, + data=None, + ), + InverterUnderTest( uri="/", method="POST", diff --git a/tests/samples/expected_values.py b/tests/samples/expected_values.py index fe4f54d..a4d05d7 100644 --- a/tests/samples/expected_values.py +++ b/tests/samples/expected_values.py @@ -27,7 +27,6 @@ "Grid Imported Energy": 42, } - X3_VALUES = { "PV1 Current": 0, "PV2 Current": 1, @@ -378,7 +377,6 @@ "Inverter Temperature": 41, } - X1_MINI_VALUES_V34_VER3 = { "Network Voltage": 234.8, "Output Current": 0.7, @@ -474,6 +472,25 @@ "Total Import Energy": 1850.05, } +X1_BOOST_VALUES_G4_V3 = { + "AC Voltage": 239.7, + "AC Output Current": 0.9, + "AC Output Power": 128.0, + "PV1 Voltage": 164.5, + "PV2 Voltage": 0.0, + "PV1 Current": 0.8, + "PV2 Current": 0.0, + "PV1 Power": 138.0, + "PV2 Power": 0.0, + "AC Frequency": 50.02, + "Total Generated Energy": 7.8, + "Today's Generated Energy": 6.8, + "Inverter Temperature": 17.9, + "Exported Power": 0.0, + "Total Export Energy": 0.0, + "Total Import Energy": 0.0, +} + QVOLTHYBG33P_VALUES = { "Network Voltage Phase 1": 221.4, "Network Voltage Phase 2": 223.8, diff --git a/tests/samples/responses.py b/tests/samples/responses.py index 99c44b1..80eb760 100644 --- a/tests/samples/responses.py +++ b/tests/samples/responses.py @@ -1286,6 +1286,115 @@ "Information": [3, 4, "XXXXXXX", 8, 2.27, 0, 1.43, 0, 0, 1], } +X1_BOOST_RESPONSE_G4_V3 = { + "sn": "XXXXXXX", + "ver": "3.009.03", + "type": 18, + "Data": [ + 2397, + 9, + 5002, + 128, + 1645, + 0, + 0, + 0, + 8, + 0, + 2, + 0, + 0, + 138, + 0, + 0, + 0, + 0, + 0, + 78, + 0, + 68, + 3000, + 43, + 38, + 0, + 1, + 0, + 179, + 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": [3.000, 18, "XXXXXXX", 8, 0.16, 0.00, 0.23, 0.00, 0.00, 1], +} + X3_MIC_RESPONSE = { "type": "X3-MIC", "SN": "XXXXXXX", From e434852dd17d390f7519da8d5d0715a7df176026 Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Tue, 11 Jun 2024 13:56:22 +0200 Subject: [PATCH 05/13] linting --- solax/inverters/x1_boost_g4.py | 5 +---- tests/fixtures.py | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/solax/inverters/x1_boost_g4.py b/solax/inverters/x1_boost_g4.py index 5cd0d6d..3874a62 100644 --- a/solax/inverters/x1_boost_g4.py +++ b/solax/inverters/x1_boost_g4.py @@ -22,10 +22,7 @@ class X1BoostG4(Inverter): ): str, vol.Required("ver"): str, vol.Required("data"): vol.Schema( - vol.All( - [vol.Coerce(float)], - vol.Length(min=100, max=100) - ) + vol.All([vol.Coerce(float)], vol.Length(min=100, max=100)) ), vol.Required("information"): vol.Schema( vol.All(vol.Length(min=10, max=10)) diff --git a/tests/fixtures.py b/tests/fixtures.py index 7ca2301..849c0d8 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -149,7 +149,6 @@ def simple_http_fixture(httpserver): headers=X_FORWARDED_HEADER, data=None, ), - InverterUnderTest( uri="/", method="POST", @@ -160,7 +159,6 @@ def simple_http_fixture(httpserver): headers=X_FORWARDED_HEADER, data=None, ), - InverterUnderTest( uri="/", method="POST", From ea01df2028d491893d5ae7d74b4d1a9d888cc7a7 Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Tue, 11 Jun 2024 18:40:50 +0200 Subject: [PATCH 06/13] add entrypoint --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 7595f8f..c9e470d 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,7 @@ "qvolt_hyb_g3_3p = solax.inverters.qvolt_hyb_g3_3p:QVOLTHYBG33P", "x1 = solax.inverters.x1:X1", "x1_boost = solax.inverters.x1_boost:X1Boost", + "x1_boost_g4 = solax.inverters.x1_boost_g4:X1BoostG4", "x1_hybrid_gen4 = solax.inverters.x1_hybrid_gen4:X1HybridGen4", "x1_mini = solax.inverters.x1_mini:X1Mini", "x1_mini_v34 = solax.inverters.x1_mini_v34:X1MiniV34", From 0e40689707c4db61e1c67ecaf3b15249734eeb66 Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Tue, 11 Jun 2024 18:43:53 +0200 Subject: [PATCH 07/13] linting --- tests/fixtures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index 849c0d8..566040a 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -7,9 +7,9 @@ from tests.samples.expected_values import ( QVOLTHYBG33P_VALUES, X1_BOOST_VALUES, + X1_BOOST_VALUES_G4_V3, X1_BOOST_VALUES_OVERFLOWN, X1_BOOST_VALUES_V3, - X1_BOOST_VALUES_G4_V3, X1_HYBRID_G4_VALUES, X1_MINI_VALUES, X1_MINI_VALUES_V34, @@ -30,9 +30,9 @@ QVOLTHYBG33P_RESPONSE_V34, X1_BOOST_AIR_MINI_RESPONSE, X1_BOOST_RESPONSE, + X1_BOOST_RESPONSE_G4_V3, X1_BOOST_RESPONSE_OVERFLOWN, X1_BOOST_RESPONSE_V3, - X1_BOOST_RESPONSE_G4_V3, X1_HYBRID_G3_2X_MPPT_RESPONSE, X1_HYBRID_G3_RESPONSE, X1_HYBRID_G4_RESPONSE, From 4a1ada08054fd2755580b43277c8276e5e03d9e8 Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Wed, 12 Jun 2024 13:12:16 +0000 Subject: [PATCH 08/13] Remove inverter temperature as it is not exposed in the x1_boost_g4_v3 --- solax/inverters/x1_boost_g4.py | 1 - tests/samples/expected_values.py | 1 - 2 files changed, 2 deletions(-) diff --git a/solax/inverters/x1_boost_g4.py b/solax/inverters/x1_boost_g4.py index 3874a62..61a6499 100644 --- a/solax/inverters/x1_boost_g4.py +++ b/solax/inverters/x1_boost_g4.py @@ -46,7 +46,6 @@ def response_decoder(cls): "AC Frequency": (2, Units.HZ, div100), "Total Generated Energy": (pack_u16(19, 20), Total(Units.KWH), div10), "Today's Generated Energy": (21, DailyTotal(Units.KWH), div10), - "Inverter Temperature": (28, Units.C, div10), "Exported Power": (pack_u16(72, 73), Units.W, to_signed), "Total Export Energy": (pack_u16(74, 75), Total(Units.KWH), div100), "Total Import Energy": (pack_u16(76, 77), Total(Units.KWH), div100), diff --git a/tests/samples/expected_values.py b/tests/samples/expected_values.py index a4d05d7..7d635ed 100644 --- a/tests/samples/expected_values.py +++ b/tests/samples/expected_values.py @@ -485,7 +485,6 @@ "AC Frequency": 50.02, "Total Generated Energy": 7.8, "Today's Generated Energy": 6.8, - "Inverter Temperature": 17.9, "Exported Power": 0.0, "Total Export Energy": 0.0, "Total Import Energy": 0.0, From 002a21392f34aba19501c5b0f53202cce67362ae Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Wed, 1 Jan 2025 19:38:45 +0000 Subject: [PATCH 09/13] Add support for X1-Mini Gen 4 and combine it with X1-Boost Gen 4. --- solax/inverters/x1_boost_g4.py | 8 ++++++-- tests/fixtures.py | 12 ++++++++++++ tests/samples/expected_values.py | 19 +++++++++++++++++++ tests/samples/responses.py | 7 +++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/solax/inverters/x1_boost_g4.py b/solax/inverters/x1_boost_g4.py index 61a6499..62e6248 100644 --- a/solax/inverters/x1_boost_g4.py +++ b/solax/inverters/x1_boost_g4.py @@ -7,16 +7,20 @@ from solax.utils import div10, div100, pack_u16, to_signed -class X1BoostG4(Inverter): +class X1G4Series(Inverter): """ + Tested with X1-Boost gen 4 with Pocket WiFi 3.009.03 + and + X1-Mini gen 4 WIFI+LAN 1.001.20 + Includes X-Forwarded-For for direct LAN API access """ # pylint: disable=duplicate-code _schema = vol.Schema( { - vol.Required("type", "type"): vol.All(int, 18), + vol.Required("type", "type"): vol.All(int, vol.Any(18, 22)), vol.Required( "sn", ): str, diff --git a/tests/fixtures.py b/tests/fixtures.py index 7449e80..1b4e918 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -15,6 +15,7 @@ X1_MINI_VALUES, X1_MINI_VALUES_V34, X1_MINI_VALUES_V34_VER3, + X1_MINI_G4_VALUES, X1_SMART_VALUES, X1_VALUES, X3_EVC_VALUES, @@ -41,6 +42,7 @@ X1_HYBRID_G4_V_3_018_RESPONSE, X1_MINI_RESPONSE_V34, X1_MINI_RESPONSE_V34_VER3, + X1_MINI_G4, X1_SMART_RESPONSE, X3_EVC_RESPONSE, X3_HYBRID_G3_2X_MPPT_RESPONSE, @@ -123,6 +125,16 @@ def simple_http_fixture(httpserver): headers=None, data=None, ), + InverterUnderTest( + uri="/", + method="POST", + query_string="optType=ReadRealTimeData", + response=X1_MINI_G4, + inverter=inverter.X1BoostG4, + values=X1_MINI_G4_VALUES, + headers=None, + data=None, + ), InverterUnderTest( uri="/", method="POST", diff --git a/tests/samples/expected_values.py b/tests/samples/expected_values.py index 7391665..3097a5f 100644 --- a/tests/samples/expected_values.py +++ b/tests/samples/expected_values.py @@ -428,6 +428,25 @@ "Inverter Temperature": 39.0, } + +X1_MINI_G4_VALUES = { + "AC Voltage": 226.1, + "AC Output Current": 0.4, + "AC Output Power": 0.0, + "PV1 Voltage": 77.9, + "PV2 Voltage": 0.0, + "PV1 Current": 0.0, + "PV2 Current": 0.0, + "PV1 Power": 0.0, + "PV2 Power": 0.0, + "AC Frequency": 50.04, + "Total Generated Energy": 638.3, + "Today's Generated Energy": 1.1, + "Exported Power": 0.0, + "Total Export Energy": 0.0, + "Total Import Energy": 0.0, +} + X1_SMART_VALUES = { "Network Voltage": 239.6, "Output Current": 12.6, diff --git a/tests/samples/responses.py b/tests/samples/responses.py index f131efd..fd477b3 100644 --- a/tests/samples/responses.py +++ b/tests/samples/responses.py @@ -550,6 +550,13 @@ "Information": [1.500, 4, "XXXXXXXXXXXXXX", 8, 2.27, 0.00, 1.43, 0.00, 0.00, 1], } +X1_MINI_G4 = {"sn": "XXXXXXXXXX", "ver": "1.001.20", "type": 22, + "Data": [2261, 4, 5004, 0, 779, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 6383, 0, 11, 2500, 18, 17, 0, 1, + 0, 11669, 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": [2.500, 22, "XMXXXXXXXX", 13, 0.15, 0.00, 0.17, 0.00, 0.00, 1]} + X1_SMART_RESPONSE = { "sn": "XXXXXXX", "ver": "2.033.20", From 140fb7e872a29c56783e7aae413e77b6bc0ffcbb Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Wed, 1 Jan 2025 20:14:15 +0000 Subject: [PATCH 10/13] Finish refactor. --- solax/inverters/__init__.py | 4 ++-- solax/inverters/{x1_boost_g4.py => x1_g4_series.py} | 0 tests/fixtures.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename solax/inverters/{x1_boost_g4.py => x1_g4_series.py} (100%) diff --git a/solax/inverters/__init__.py b/solax/inverters/__init__.py index c9386e7..d8c9c90 100644 --- a/solax/inverters/__init__.py +++ b/solax/inverters/__init__.py @@ -1,7 +1,7 @@ from .qvolt_hyb_g3_3p import QVOLTHYBG33P from .x1 import X1 from .x1_boost import X1Boost -from .x1_boost_g4 import X1BoostG4 +from .x1_g4_series import X1G4Series from .x1_hybrid_gen4 import X1HybridGen4 from .x1_mini import X1Mini from .x1_mini_v34 import X1MiniV34 @@ -25,7 +25,7 @@ "X3HybridG4", "X3", "X1Boost", - "X1BoostG4", + "X1G4Series", "X1HybridGen4", "X3MicProG2", "X3Ultra", diff --git a/solax/inverters/x1_boost_g4.py b/solax/inverters/x1_g4_series.py similarity index 100% rename from solax/inverters/x1_boost_g4.py rename to solax/inverters/x1_g4_series.py diff --git a/tests/fixtures.py b/tests/fixtures.py index 1b4e918..b8daa8f 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -130,7 +130,7 @@ def simple_http_fixture(httpserver): method="POST", query_string="optType=ReadRealTimeData", response=X1_MINI_G4, - inverter=inverter.X1BoostG4, + inverter=inverter.X1G4Series, values=X1_MINI_G4_VALUES, headers=None, data=None, @@ -170,7 +170,7 @@ def simple_http_fixture(httpserver): method="POST", query_string="optType=ReadRealTimeData", response=X1_BOOST_RESPONSE_G4_V3, - inverter=inverter.X1BoostG4, + inverter=inverter.X1G4Series, values=X1_BOOST_VALUES_G4_V3, headers=X_FORWARDED_HEADER, data=None, From 430239c169bdefbfda3666f1a082044baa447ea2 Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Thu, 2 Jan 2025 16:54:03 +0100 Subject: [PATCH 11/13] Fix setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bcb33d8..296ba89 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ "qvolt_hyb_g3_3p = solax.inverters.qvolt_hyb_g3_3p:QVOLTHYBG33P", "x1 = solax.inverters.x1:X1", "x1_boost = solax.inverters.x1_boost:X1Boost", - "x1_boost_g4 = solax.inverters.x1_boost_g4:X1BoostG4", + "x1_g4_series = solax.inverters.x1_g4_series:X1G4Series", "x1_hybrid_gen4 = solax.inverters.x1_hybrid_gen4:X1HybridGen4", "x1_mini = solax.inverters.x1_mini:X1Mini", "x1_mini_v34 = solax.inverters.x1_mini_v34:X1MiniV34", From 13074d0b8fc5978771b36054c83d175fb5dd0ebe Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Sun, 5 Jan 2025 23:58:48 +0100 Subject: [PATCH 12/13] black! --- tests/samples/responses.py | 114 +++++++++++++++++++++++++++++++++++-- 1 file changed, 108 insertions(+), 6 deletions(-) diff --git a/tests/samples/responses.py b/tests/samples/responses.py index fd477b3..d35f7c1 100644 --- a/tests/samples/responses.py +++ b/tests/samples/responses.py @@ -550,12 +550,114 @@ "Information": [1.500, 4, "XXXXXXXXXXXXXX", 8, 2.27, 0.00, 1.43, 0.00, 0.00, 1], } -X1_MINI_G4 = {"sn": "XXXXXXXXXX", "ver": "1.001.20", "type": 22, - "Data": [2261, 4, 5004, 0, 779, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 6383, 0, 11, 2500, 18, 17, 0, 1, - 0, 11669, 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": [2.500, 22, "XMXXXXXXXX", 13, 0.15, 0.00, 0.17, 0.00, 0.00, 1]} +X1_MINI_G4 = { + "sn": "XXXXXXXXXX", + "ver": "1.001.20", + "type": 22, + "Data": [ + 2261, + 4, + 5004, + 0, + 779, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 6383, + 0, + 11, + 2500, + 18, + 17, + 0, + 1, + 0, + 11669, + 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": [2.500, 22, "XMXXXXXXXX", 13, 0.15, 0.00, 0.17, 0.00, 0.00, 1], +} X1_SMART_RESPONSE = { "sn": "XXXXXXX", From a48c543b9a4763e1cdab48b0cd2b7e1906337e93 Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Mon, 6 Jan 2025 00:06:38 +0100 Subject: [PATCH 13/13] further linting --- tests/fixtures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index b8daa8f..b07ca17 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -12,10 +12,10 @@ X1_BOOST_VALUES_V3, X1_HYBRID_G4_V_3_018_VALUES, X1_HYBRID_G4_VALUES, + X1_MINI_G4_VALUES, X1_MINI_VALUES, X1_MINI_VALUES_V34, X1_MINI_VALUES_V34_VER3, - X1_MINI_G4_VALUES, X1_SMART_VALUES, X1_VALUES, X3_EVC_VALUES, @@ -40,9 +40,9 @@ X1_HYBRID_G3_RESPONSE, X1_HYBRID_G4_RESPONSE, X1_HYBRID_G4_V_3_018_RESPONSE, + X1_MINI_G4, X1_MINI_RESPONSE_V34, X1_MINI_RESPONSE_V34_VER3, - X1_MINI_G4, X1_SMART_RESPONSE, X3_EVC_RESPONSE, X3_HYBRID_G3_2X_MPPT_RESPONSE,