Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f9932d5d14
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| local pv_w = u32(regs[3], regs[4]) + u32(regs[7], regs[8]) |
There was a problem hiding this comment.
Filter unavailable MPPT power before summing
When an MPPT reports the 0xFFFFFFFF unavailable sentinel, this sum includes it as power. On the repository's 32-bit Lua build, each such input becomes -1 W: synthetic PV1/PV2 readings of 2800/2300 W with unavailable PV3/PV4 produce -5098 W instead of -5100 W, and zero production becomes positive consumption. With 64-bit Lua integers, the same sentinel becomes billions of watts. The referenced GoodWe library explicitly recognizes this sentinel and excludes it from its PV total. Check the word pair before adding each MPPT.
Useful? React with 👍 / 👎.
|
|
||
| local lifetime_wh = nil | ||
| local energy = probe_read(35191, 2, "holding") | ||
| if energy and energy[2] ~= nil then |
There was a problem hiding this comment.
Scale lifetime energy using floating-point arithmetic
On the repository's LUA_32BITS build, both u32() and the literal 100 are integers, so this multiplication wraps once lifetime generation reaches 2,147,483.7 kWh. A synthetic register count of 21,474,837 reproduces lifetime_wh = -2147483596 instead of approximately 2,147,483,700 Wh. The previous calculation promoted to floating point through * 0.1; retain floating-point scaling here so a valid cumulative counter cannot become negative.
Useful? React with 👍 / 👎.
87c6d9f to
1a49f2c
Compare
The driver read most values from the wrong registers: battery power from 35180 (the battery voltage), battery V and A from 35178/35179 (BUS and NBUS voltages), SoC from 35182, total PV from PV1 alone scaled by 0.1, grid frequency from 35113 (PV3 power) and the meter from the inverter's own phase registers. Addresses, types and scales now follow GoodWe's "Modbus Protocol Hybrid for Energy Storage Inverters" (2 February 2024); signs follow evcc's goodwe-hybrid template and the goodwe library. No battery stream when 35184 says none, no meter when 36004 says the inverter does not hear one, and no field from a read that failed. The orphaned community-v1 and gw8kn-et-hk3000 Lua fixtures, which no test ran, are removed. Refs #264 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
GoodWe's map puts meter power at 36019-36041 only above ARM firmware version 9 (35019). On older firmware those registers would read 0 and the driver would send a confident 0 W site meter. No source gives the sign of the older 36005-36008, so the driver now reads 35019 once and sends no meter on ARM 9 or older, or while the version is unknown. PV power and energy of 0xFFFFFFFF (evcc's uint32 "no value") are left out, and an MPPT without a value adds nothing to PV power. SoC above 100 % (0xFFFF) is left out. The THIRD_PARTY_NOTICES entry for the removed gw8kn-et-hk3000 profile is dropped, since no file derives from it any more. Refs #264 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
What this does
goodweread most of its PV, battery and meter values from the wrong registers (#264). This PR moves every one of those reads to the address, type and scale in GoodWe's own map. The driver stays read-only; no write or control path changes.Not verified on hardware. All test values are synthetic. A field report from a GoodWe ET or EH site would settle it: raw words for 35019 (ARM firmware version), 35103-35123, 35180-35184, 36004-36026, 36052-36057 and 37000-37023, and what SEMS or the display shows at the same moment. Please post one on #264 if you have a GoodWe.
Sources
upstream_docs). Used for addresses, types and scales.upstream_docs.et.py(ET/EH/BT/BH).GoodWe's table states no signs in words. Both integrations treat battery discharge and meter export as positive: evcc scales meter power by -1 and passes battery power through as "positive = discharging", and the library's house consumption adds battery power and subtracts meter power. The driver turns both round, as our convention needs. Addresses, types and scales only were taken from the integrations; no code was copied.
Reads changed
grid_hz)Kept as they were, because they already match all three sources: PV1 V/A (35103/35104), PV lifetime energy (35191, × 0.1 kWh), heat sink temperature (35176) and #262's BMS block (37000-37023).
New rules
test_goodwe_battery_now.pychanged for this one case.arm_version) once. On ARM 9 or older, or while 35019 has not answered, it sends no meter. No source gives the sign of 36005-36008, so the driver does not read them; a field report from an old unit could change that. 35019 is given up after three failed tries, like every other register.invented-number-baseline.jsonand is now clean, so it is removed from that file.Left alone, and why
Tests
drivers/tests/test_goodwe_map.py(33 cases): PV sum over four MPPTs and both words, PV2 address, PV energy, frequency at 35123, 0xFFFFFFFF left out of the PV sum and the energy, no PV when no MPPT has a value; battery sign while discharging and charging, both words, SoC from 37007, SoC 0xFFFF and 101 left out, no battery on mode 0, nothing on a failed read, no SoC without a talking BMS; meter sign for export and import, per-phase power, frequency, float energy, per-phase V/A, no meter on 36004 = 0 or a failed read, NaN energy left out; no meter on ARM 9 or when 35019 fails, a meter on ARM 10, 35019 read once and given up after three tries; and that none of the old wrong registers is read. The first 23 were written before the map change and 22 of them fail onmain(the one that passes covers PV lifetime energy, whose read did not change); the firmware and sentinel cases were written before their fix and failed on the first version of this branch.goodwe_fixtures.lua,test_goodwe_failures.lua,test_goodwe_ftw_contract.luaandtest_goodwe_profiles.luaunderdrivers/tests/lua_harness/. No test ran them. They tested thecommunity-v1andgw8kn-et-hk3000profiles, which the driver lost in feat: FTW's field-proven drivers become the source #27, andcommunity-v1encoded the wrong map. TheTHIRD_PARTY_NOTICES.mdentry for thegw8kn-et-hk3000profile goes too, since no file derives from it any more.test_all_drivers.lua(not run by CI) now sets 36004 and 37011 for GoodWe and puts its SoC at 37007; goodwe passes there.make test-driver ID=goodwe: 95 passed, 6 skipped.make check: 5304 passed, 928 skipped, on head 1a49f2c (rebased ontomainafter fix(growatt): leave a failed read out instead of sending 0 (2.2.2) #273).make absent-register-report ID=goodwe: every register settles to 0 failed reads after three tries.Version 2.3.0 via
make bump-driver; CHANGELOG, manifest and generated files updated.Refs #264
🤖 Generated with Claude Code