Repository navigation
Solax: add Gen5 support - #4315
Merged
Merged
Solax: add Gen5 support #4315
Conversation
Linked issuesChecked at commit fdaef6f #1919 Integration with Solax no Bat2 and no PV3 · 2 of 2 met
|
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="packages/modules/devices/solax/solax/counter.py" line_range="76" />
<code_context>
+ voltages = [value / 10 for value in self.__tcp_client.read_input_registers(
+ 202, [ModbusDataType.UINT_16] * 3, unit=unit)]
+ # von Solax beobachtete Kodierung negativer Ströme als Offset von 65535
+ currents = [(65535 - value) / 10 for value in self.__tcp_client.read_input_registers(
+ 206, [ModbusDataType.UINT_16] * 3, unit=unit)]
+ power_factors = [value / 100 for value in self.__tcp_client.read_input_registers(
</code_context>
<issue_to_address>
**Positive phase currents become enormous**
When a Gen5 current register contains an ordinary non-negative reading, `SolaxCounter.update` applies `(65535 - value) / 10` to every raw current, so ordinary readings become values near 6,553 A; `CounterState` only adjusts signs and publishes the excessive magnitudes as phase currents.
Apply the offset conversion only to negatively encoded current values.
Also at `packages/modules/devices/solax/solax/counter.py:77`.
</issue_to_address>
### Comment 2
<location path="packages/modules/devices/solax/solax/bat.py" line_range="55" />
<code_context>
- # Basiswerte aus dem Batterie-Registersatz lesen
- power = self.__tcp_client.read_input_registers(0x0016, ModbusDataType.INT_16, unit=unit)
- soc = self.__tcp_client.read_input_registers(0x001C, ModbusDataType.UINT_16, unit=unit)
+ if self.component_config.configuration.battery_index == 2:
+ power = self.__tcp_client.read_input_registers(297, ModbusDataType.INT_16, unit=unit)
+ soc = self.__tcp_client.read_input_registers(302, ModbusDataType.UINT_16, unit=unit)
</code_context>
<issue_to_address>
**Non-G5 batteries read Gen5 registers**
When a non-G5 inverter is configured with battery index 2, `SolaxBat.update` selects registers 297 and 302 solely from `battery_index`, so it reads unrelated or unsupported registers and reports invalid battery values or fails the update.
Use the second-battery registers only when the inverter is Gen5.
</issue_to_address>
### Comment 3
<location path="packages/modules/devices/solax/solax/counter.py" line_range="69-70" />
<code_context>
+ power = self.__tcp_client.read_input_registers(
+ 0x0046, ModbusDataType.INT_32, wordorder=Endian.Little, unit=unit) * -1
+ frequency = self.__tcp_client.read_input_registers(0x0007, ModbusDataType.UINT_16, unit=unit) / 100
+ powers = [-value for value in self.__tcp_client.read_input_registers(
+ 130, [ModbusDataType.INT_32] * 3, wordorder=Endian.Little, unit=unit)]
+ exported, imported = [value * 10 for value in self.__tcp_client.read_input_registers(
+ 0x0048, [ModbusDataType.UINT_32] * 2, wordorder=Endian.Little, unit=unit)]
</code_context>
<issue_to_address>
**Optional meter reads block counter updates**
When a Gen5 phase-measurement register read fails while the core power and energy registers remain readable, `SolaxCounter.update` lets errors reading phase powers, voltages, currents, or power factors escape before it creates and stores `CounterState`, so usable total power and energy readings are lost for that update and the last counter state remains stale.
Treat the added phase measurements as optional: catch their read failures and store the available core counter values with missing phase fields set to `None`.
Also at `packages/modules/devices/solax/solax/counter.py:73-79`.
</issue_to_address>
### Comment 4
<location path="packages/modules/devices/solax/solax/bat_test.py" line_range="54-55" />
<code_context>
+
+ solax_bat.update()
+
+ client.read_input_registers.assert_any_call(0x0016, bat.ModbusDataType.INT_16, unit=1)
+ client.read_input_registers.assert_any_call(0x001C, bat.ModbusDataType.UINT_16, unit=1)
+
+
</code_context>
<issue_to_address>
**Wrong battery still passes**
When `update()` reads the expected registers but uses another battery's values, `test_update_reads_first_battery_registers_by_default` and `test_update_reads_second_battery_registers_when_configured` pass even if `update()` stores values from the wrong battery, because these assertions only require the expected reads to occur; they do not verify that those reads supply the stored state.
Assert the exact read calls and verify the resulting battery state uses the selected battery's values.
Also at `packages/modules/devices/solax/solax/bat_test.py:66-67`.
</issue_to_address>
LKuemmel
requested changes
Nov 16, 2026
seaspotter
force-pushed
the
solax-gen5-support
branch
from
November 16, 2026 13:15
c59b870 to
fdaef6f
Compare
LKuemmel
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UI: openWB/openwb-ui-settings#1169
Ersetzt den eigenständigen Modulentwurf aus #1972 durch eine Integration in das bestehende solax-Modul, wie dort
vorgeschlagen - die meisten Register sind mit Gen3 identisch, nur PV3 (Register 292), 2. Batterie (297/302) und die zusätzlichen Zähler-Register (Spannung/Strom/cos φ) sind neu.
Registerwerte stammen aus #1972s Diff, inkl. der dortigen Klärung, dass Register 82 den Gesamt- nicht den Tagesertrag liefert. Die Stromkodierung (65535 - Wert) für negative Werte ist aus #1972 übernommen.
Battery-Index folgt genau dem bereits bestehenden Muster bei GoodWe (battery_index in config + Auswahlfeld in der UI).
Fixes #1919 (Ursprungsproblem)
Können geschlossen werden:
Summary by Sourcery
Integrate Solax Gen5 support into the existing Solax module.
New Features:
Bug Fixes:
Enhancements:
Tests: