Skip to content

fix(ferroamp_modbus): read the EnergyHub again after a silent start (2.2.3) - #327

Open
frahlg wants to merge 1 commit into
mainfrom
fix/ferroamp_modbus-wake
Open

frahlg wants to merge 1 commit into
mainfrom
fix/ferroamp_modbus-wake

Conversation

@frahlg

@frahlg frahlg commented Dec 5, 2026

Copy link
Copy Markdown
Member

Problem

ferroamp_modbus 2.2.2 read every register through probe_read, which leaves a register alone until restart after three misses: meter 2016, 2032, 3100, 3112, 3064; PV 5100, 5064; battery 6100, 6016, 6064.

An EnergyHub that was off, restarting or held by another Modbus client when FTW started used up every try while answering nothing. The driver then sent nothing until FTW restarted it. It already sent no zeros, so this is only the wake-up.

Change

  • A miss counts only in a poll where another read answered, so a silent EnergyHub uses up no tries and is read again on the first poll it answers. A register that misses three times on an EnergyHub that does answer is asked again every five minutes instead of never.
  • A reply counts only when every word asked for came back. Before, the guard took a reply whose first word answered, and the meter and PV checked the last word themselves.
  • driver_cleanup resets the new poll state.
  • Unchanged: the meter goes out only when 3100 answered, PV only when 5100 answered, fields that did not answer or hold NaN are left out, and the driver stays read-only.

Test evidence

  • test_ferroamp_modbus_wakes.py, fifteen tests. Twelve fail on 2.2.2 and all pass on 2.2.3:
    • test_wakes_after_silence.lua (shared with the other PRs in this series): silent from start-up, silent mid-session, each register refused six times;
    • ten silent polls, then every meter, PV and battery field on the first poll that answers;
    • each of the ten registers asked again within five minutes after three refusals.
    • The other three, the meter or PV left out when its power does not answer and fields left out when their registers do not answer, pass on 2.2.2 too.
  • test_ferroamp_modbus_battery.py, test_ferroamp_modbus_meter_pv.py and test_ferroamp_modbus_nan.py pass unchanged.
  • make test-driver ID=ferroamp_modbus: 87 passed, 4 skipped.
  • make absent-register-report ID=ferroamp_modbus: every address settles.
  • make invented-number-report ID=ferroamp_modbus: none. The driver was not in the baseline.
  • make check: 5589 passed, 927 skipped.

Not yet verified

  • No hardware run. The case needs an EnergyHub that is off or held by another Modbus client when FTW starts.
  • Left as it was: the battery stream still goes out with SoC or energy alone when battery power (6100) does not answer. test_ferroamp_modbus_battery.lua asks for this on purpose ("a failed power read must not also drop a good SoC"). Whether a battery without its power should go out is the owner's call.
  • drivers/lua/ferroamp.lua (the MQTT driver) is not touched.
  • CHANGELOG.md and drivers/tests/lua_harness/test_wakes_after_silence.lua are shared with the other PRs in this series; whichever merges later needs a rebase there.
  • After merge, FTW's pin in drivers/BUNDLED_SOURCE.json has to move.

🤖 Generated with Claude Code

…2.2.3)

Every read went through a guard that left a register alone until restart
after three misses. An EnergyHub that was off, restarting or held by
another Modbus client at start-up used up every try while answering
nothing, and the driver then sent nothing until FTW restarted it.

A miss now counts only in a poll where another read answered, and a
register that misses three times on an EnergyHub that does answer is asked
again every five minutes. A reply counts only when every word asked for
came back. The meter and PV still go out only when 3100 and 5100 answered,
and fields that did not answer are still left out.

test_ferroamp_modbus_wakes.py fails on 2.2.2 (12 of 15 cases; the other
three check streams and fields left out, which 2.2.2 already did) and
passes on 2.2.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T06:12:12.351508Z bfee74d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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.

1 participant