Skip to content

fix(deye): read the inverter again after a silent start (2.2.1) - #307

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

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

Conversation

@frahlg

@frahlg frahlg commented Dec 4, 2026

Copy link
Copy Markdown
Member

Problem

deye 2.2.0 read every register through probe_read, which leaves a register alone until restart after three misses. An inverter asleep when FTW started, or held by another Modbus client, used up every try while answering nothing. The driver then sent nothing; Core reloads a driver with nothing left to read only if an earlier read had succeeded, so it stayed silent until FTW restarted it.

The same start did worse on an HV unit. Register 0, which says whether the battery side is HV or LV, was read in driver_init only, and a failed read meant "assume LV" for good. PV power, battery power and battery voltage then came out ten times too low, and the power registers control writes (143, 154) ten times too large.

A register that did not answer was sent as zero (26 counts in the invented-number baseline).

Change

  • A miss counts only in a poll where another read answered, so a silent inverter uses up no tries and is read again on the first poll it answers. A register that misses three times on an inverter that does answer is asked again every five minutes instead of never.
  • Register 0 is read on each poll until it answers. PV and battery wait for it, and so does control (initialize_control refuses while the scale is unknown). A unit that never answers register 0 is taken as LV once it has missed three times on an inverter that answers otherwise, as before but no longer at once.
  • Rated power (20-21) read in a poll after a failed init read now sets the value control uses, unless rated_w is configured.
  • A field whose register did not answer is left out. PV, battery and meter go out only when their power register (672, 590, 619) answered. Metrics skip missing values.
  • Battery mode (111) is asked only in a poll where the inverter has answered, so a silent start does not push it into its five-minute retry.
  • The serial is read last, once the inverter has answered in that poll.
  • deye leaves invented-number-baseline.json.

Test evidence

  • test_deye_wakes.py, eight tests, all fail on 2.2.0 and pass on 2.2.1:
    • test_wakes_after_silence.lua (shared with fix(saj): read the serial and battery again after the inverter wakes (1.3.1) #301): silent from start-up, silent mid-session, each register refused six times. 2.2.0 fails: asleep at start-up: register 20 not read after the device answered.
    • an HV unit silent at start-up reports PV −4000 W, battery 500 W and 400 V after it wakes (2.2.0: −400 W);
    • with register 0 refused, the meter goes out at once, PV and battery wait, control refuses until LV is assumed;
    • rated power read after a silent start reaches register 143 on init;
    • PV, battery and meter are left out when their power register does not answer, and other fields when theirs do not.
  • test_deye_battery_now.py: 13 passed, unchanged.
  • make test-driver ID=deye: passed.
  • make absent-register-report ID=deye: every address settles.
  • make invented-number-report ID=deye: none.
  • make check: 5582 passed, 927 skipped.

Not yet verified

  • No hardware run. The cases need a Deye that is asleep or held by another client when FTW starts, ideally an HV unit.
  • invented-number-baseline.json and CHANGELOG.md are touched by the other driver 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

Every read went through a guard that left a register alone until restart
after three misses. An inverter asleep at start-up, or held by another
Modbus client, used up every try while answering nothing, and the driver
then sent nothing until FTW restarted it. Register 0, which says whether
the battery side is HV or LV, was read at init only, so the same start
left an HV unit scaled as LV: PV power, battery power and battery voltage
ten times too low, and power writes ten times too large. A register that
did not answer was sent as zero.

A miss now counts only in a poll where another read answered, and a
register that misses three times on an inverter that does answer is asked
again every five minutes. Register 0 is read on each poll until it
answers; PV, battery and control wait for it, and a unit that never
answers it is taken as LV after three misses. Rated power read after such
a start reaches control. Fields whose register did not answer are left
out; PV, battery and meter go out only when their power register
answered. Battery mode and the serial are read only in a poll where the
inverter has answered, the serial last.

test_deye_wakes.py has eight tests; all fail on 2.2.0 and pass on 2.2.1.

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 4, 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-04T18:43:08.714482Z 17dd085 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