Repository navigation
feat(foxess_h3_smart, konja-261-svk): report grid state on the inverter stream - #285
Merged
Merged
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. |
…er stream A hybrid inverter with a backup switch keeps the house on its battery when the grid goes, and FTW had no way to know (srcfl/ftw#2125). Both drivers now report grid_state, "on_grid" or "off_grid", on the inverter stream, only from a vendor status read in the same poll. Observe-only: no read, write or control path changes, and FTW Core does not act on it yet. foxess_h3_smart 0.11.0 decodes bit 0 of Status 3, a 32-bit field at 39065..39066 with the high word first, so the bit is in 39066. That is what nathanmarlor/foxess_modbus#1314 measured through two real outages and 27 relay trips. It is not yet confirmed on 1K5 hardware, so both words also go to history. konja-261-svk 0.5.0 maps PCS 8063: 4 is on_grid, 3 is off_grid, any other state leaves the field out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
frahlg
force-pushed
the
feat/inverter-grid-state
branch
from
November 29, 2026 16:45
c842e04 to
f1c2b24
Compare
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.
Step (5) of off-grid support, srcfl/ftw#2125. FoxESS and Konja now report whether the inverter is on grid or islanded. This is observe-only: no register read, write or control path changes, and FTW Core does not act on the field yet. The point is to get readings from a real grid cut on a 1K5 before any off-grid behaviour is built on them.
The field
grid_stateonhost.emit("inverter", …), with the value"on_grid"or"off_grid":inverterstream because that stream is the inverter's AC stage, which is what islands. Likedevice_state, it is FTW's own key. It is documented indocs/WRITING-A-DRIVER.mdunder "Grid state".foxess_h3_smart 0.11.0
Decode: bit 0 of Status 3, with 1 meaning off-grid. FoxESS Modbus definition V1.05.04.00 places Status 3 at 39065, but it is a 32-bit field with the high word first, so its bit 0 is in 39066 bit 0. This is how the foxess_modbus maintainer reads the definition in fix: read the off-grid status bit from 39066 on H3 Smart nathanmarlor/foxess_modbus#1314.
Evidence: #1314 measured this on a P3-5.0-SH, which is in the same register family:
0x00010x00000x00000x00000x00040x0004These held over two real outages (93 s and 20.7 min, where grid V and Hz read 0) and 27 short relay trips of 9–20 s (where V and Hz stayed normal). #1314 applies the read to the H3-Smart family and to the 1K5 profile.
No extra Modbus traffic: the status block (39063, count 79) is already read every poll.
First inverter stream: the driver emits an
inverterstream for the first time, carrying only this field. Grid V and Hz stay on the meter emit.Not yet verified on a 1K5-HI. Both words therefore also go to history as
foxess_status3_hi(39065) andfoxess_status3_lo(39066). The metrics are split because one 32-bit value would not fit Blixt's 32-bit Lua integers.verification_notessays grid state is unverified.Worth knowing for Core: in the same measurement, 39067 read
0x0980while islanded. This driver's fault latch reads 39067..39069 as fault codes, so on that evidence an outage today raises a device fault (codes 2432/0/0). This PR does not change that. It is recorded here for the off-grid behaviour step.konja-261-svk 0.5.0
on_grid, and 3 isoff_grid.What to record in the grid cut on the 1K5
Please record:
foxess_status3_hi,foxess_status3_lo,foxess_inverter_state, and the device-fault message (fault codes), before, during and after the cut;Tests
drivers/tests/test_foxess_h3_smart.pycovers three cases:drivers/tests/lua_harness/test_grid_state_konja.lua, run bydrivers/tests/test_grid_state.py, covers 4 →on_grid, 3 →off_grid, other states leaving the field out, and no replay after a failed PCS read. It fails against the driver onmain.make checkpasses: 5569 passed, 927 skipped.🤖 Generated with Claude Code