Skip to content

drivers/solaredge_legacy: cache "MPPT unsupported" to stop flapping the poll-fail counter on K-series firmware - #702

Closed
murwall wants to merge 1 commit into
srcfl:masterfrom
murwall:fix/drivers-solaredge-legacy-mppt
Closed

murwall wants to merge 1 commit into
srcfl:masterfrom
murwall:fix/drivers-solaredge-legacy-mppt

Conversation

@murwall

@murwall murwall commented Jul 28, 2026

Copy link
Copy Markdown

What

Cache a mppt_supported flag in the module. On the first poll where the
MPPT block at 40123 read returns nothing, mark it unsupported and skip
the host.modbus_read call on every subsequent poll (until driver
restart, which re-probes). Rest of the poll — Model 103 block, AC power,
frequency, temp, lifetime energy — is unchanged.

Why

On SolarEdge K-series firmware (SE7K/10K/17K/25K, "display" era) the
proprietary MPPT registers at 40123 aren't populated. A direct Modbus
TCP probe against an SE17K running firmware 0003.2251 confirms:

40000  SunSpec ID          → OK
40069  Inverter block M103 → OK
40123  MPPT SF block       → EXCEPTION 2 (illegal data address)

The driver already pcalls the MPPT read and treats failure as
"MPPT metrics unavailable, keep going with Model 103". Correct at the
Lua level.

But the Go host counts every failed host.modbus_read toward the
driver-poll error tally regardless of Lua-side pcall handling.
So
on K-series hardware the driver flaps driver_poll: 1 of 2 modbus reads failed every 5 s indefinitely, gets marked offline via the stale-
telemetry watchdog, and PV data never reaches the planner. This is a
regression vs v0.120.9, where the same K-series firmware polled
cleanly on the same driver source.

Rather than change the Go host's accounting (which would need to
distinguish "this driver called modbus_read but doesn't care if it
fails" from a real error), fix at the driver: don't ISSUE the failing
read once we know it isn't going to succeed.

Testing

Verified on SE17K firmware 0003.2251 (K-series with display):

Before (v1.13.4 shipped driver, no patch):

driver_poll: 1 of 2 modbus reads failed  ← every 5 s indefinitely
Status=2 (offline), ConsecutiveErrors=47+

After (this patch):

  • First poll after startup: normal probe attempts, MPPT fails as expected, one INFO log line: "MPPT block at 40123 not readable on this firmware — emitting Model 103 metrics only. Reprobe on next restart."
  • All subsequent polls: Status=0, ConsecutiveErrors=0, AC power / frequency / temperature / lifetime energy all emit correctly.
  • Restart re-probes the register once (in case firmware was updated).

Ran for ~30 min in a live install; battery dispatch runs cleanly.

Related

  • Same class of bug in pixii.lua (meter_energy_sf at 40288) — separate PR: [#PR-pixii-meter-energy-sf]
  • Both surface the same root cause: Go host counts failed modbus_read calls regardless of Lua's pcall. Localized "cache unsupported, skip subsequent reads" pattern fixes both.

Alternative

If a broader architectural approach is preferred, exposing a
host.modbus_read_optional(addr, n, fc) that doesn't count toward the
failure tally on nil returns would let drivers opt out declaratively.
Bigger surface change; the localized fix here is portable to v0.120.9-
style behaviour without touching the Go host.

@murwall
murwall requested a review from frahlg as a code owner July 28, 2026 15:07

@miravoss26 miravoss26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the diff. Clean, well-reasoned fix: it caches mppt_supported, so once a K-series inverter returns exception-2 on the 40123 MPPT block the driver stops re-probing and the Go host's failed-read counter stops flapping. Model 103 metrics are untouched, and a confirmed-unsupported unit emits the same MPPT zeros it did before, so no change on the data side.

  • Correctness: the nil-probe / true-keep-reading / false-skip state machine is right, and the default 0,0,0,0 means skipping emits the same values the old pcall-fail path did.
  • One edge worth a thought: the lock to false fires on the first failed read. A transient first-poll error on a firmware that actually exposes MPPT would disable those metrics until restart, since the Lua side can't tell exception-2 from a one-off timeout. Fine given restart re-probes and the target is genuinely-unsupported K-series, but if first-poll flakiness shows up, 2 or 3 consecutive misses before locking would harden it.
  • Security: nothing flagged. No secrets, no new deps, existing host.modbus_read / host.log only.

No CI checks attached that I can see, so worth confirming the driver test run is green first. Safe to merge from my read. Not in my auto-merge allowlist, so I'm leaving the merge to a human.

@frahlg

frahlg commented Jul 28, 2026

Copy link
Copy Markdown
Member

Thanks @murwall — carried over verbatim in srcfl/device-drivers#33, with you credited. The 30-minute run on SE17K firmware 0003.2251 is the strongest evidence on either PR.

Moving it for the same reason as #703: drivers/ here is a bundled snapshot, not the source. AGENTS.md in device-drivers is explicit that it is the only editable source for shared drivers and the main driver source for FTW, so a fix landed here is overwritten by the next publication from the signed channel.

Your reasoning for fixing it in the driver rather than in the Go host's accounting is worth keeping on the record, so I quoted it in the new PR: distinguishing "this driver called modbus_read but doesn't care if it fails" from a real error is a harder change than not issuing a read you already know will fail.

srcfl/device-drivers#33 adds a regression test against the catalog driver and verifies it against the unpatched baseline: three reads of 40123 over three polls before, one after.

One thing that came out of it — editing the driver cost it byte-identity with baselines/ftw, which is what had exempted it from the Modbus test suite. That immediately surfaced a bug in the suite's decode-call extractor, which counted a nested call's comma as an argument separator. Fixed in the same PR.

Closing in favour of srcfl/device-drivers#33.

tommylindgren pushed a commit to tommylindgren/device-drivers that referenced this pull request Aug 10, 2026
)

Brings the two driver fixes from srcfl/ftw#703 and srcfl/ftw#702 to the repository that owns the drivers. pixii 2.1.0 → 2.1.1, solaredge_legacy 0.3.0 → 0.3.1.

Closes srcfl/ftw#703, closes srcfl/ftw#702
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants