Skip to content

fix(foxess_h3_smart): hold a mode through small swings near full (0.12.4) - #330

Draft
Leitet wants to merge 1 commit into
cursor/foxess-h3-smart-bat-bound-7b81from
cursor/foxess-h3-smart-mode-dwell-7b81
Draft

Leitet wants to merge 1 commit into
cursor/foxess-h3-smart-bat-bound-7b81from
cursor/foxess-h3-smart-mode-dwell-7b81

Conversation

@Leitet

@Leitet Leitet commented Dec 5, 2026

Copy link
Copy Markdown
Member

Stacked on #296 (0.12.3). Draft. Do not merge.

What 0.12.3 did on Dragonsreach (5 Dec)

0.12.3 was live from 11:37:45. Discharge stayed within |target| + 200 W until 12:33. At 12:40:11 the monitor rolled it back: four mode changes in 180 s, shortest dwell 20 s, as SoC reached 96% and the near-full latch engaged. Core's target flipped between 0 and +300–450 W while house load swung 1.2–2.1 kW every 20–40 s, and the driver followed every swing (remote control, hold, release). No Modbus blackouts and no faults. Max SoC was 96%, so the ≥98% curtail cap, charge refusal and solar lock were not exercised.

Right after the restart, 11:38:00–11:38:30, the battery discharged 1.2–2.3 kW at target 0 because the driver ran on a setpoint the previous process had left in the inverter. pv_ref can also stick, including on a curtailed sample.

What 0.12.4 changes

  • Near a full pack (SoC ≥ 96%, or the existing 98/96 latch), a target inside ±500 W is one mode. Once that mode is chosen it is kept for 120 s, and 0 and a small charge are the same mode, so they do not toggle remote control, hold and release. A discharge larger than 500 W that already sits at least 200 W inside house load still releases on that poll.
  • The first act after start or reload is to write remote control off (46001 = 0), before any register read, so a stale 46003 is never applied.
  • pv_ref is replaced only by a measurement that is not sitting on the last written AC cap while the pack is near full. Otherwise it decays 20% per poll and is cleared rather than landing on the curtailed sample. The metric is published every poll, including 0 when the reference has been cleared, so a stale value does not sit there.
  • The 0.12.3 bounds stay: in remote control the AC setpoint is at most measured PV × 0.977 + |target| + 200 W, and a discharge is released only when it is inside house load.

Tests

make check: 5599 passed, 927 skipped.

New cases replay the 12:36–12:40 pattern (SoC 96%, target 0 ↔ +300–450 W, load 1.2–2.1 kW every 30 s) and expect at most one mode change in 180 s. A −2000 W discharge into a 3000 W house load releases on the next poll, not after two minutes. A restart with 46001 = 1 and 46004 = 2500 writes 46001 = 0 before any read. A PV sample sitting on the last cap at SoC 98% does not stick in pv_ref.

Hardware check, after Johan says yes

Steward installs this only on an explicit yes. Do not install from this PR.

  1. Restart must not discharge at target 0. The first Modbus write should be 46001 = 0.
  2. At SoC ≥ 96% with the target wobbling between 0 and a few hundred watts of charge, and house load swinging 1–2 kW, the driver should change mode at most once in three minutes.
  3. A real discharge larger than 500 W that is inside house load should still drop remote control promptly.
  4. foxess_pv_ref_w should fall, not stick, when PV is sitting on the last AC cap at a full pack.
  5. Discharge in remote control should still stay within |target| + 200 W.
Open in Web Open in Cursor 

@Leitet
Leitet added this pull request to stack #294 December 5, 2026 14:13
0.12.3 kept discharge inside the target, then flipped mode four times
in three minutes when SoC hit 96% and the target wobbled between 0 and
a few hundred watts of charge. 0.12.4 stays in the chosen mode for
120 s, clears a stale remote setpoint on start, and lets pv_ref decay
instead of sticking to a curtailed sample.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Johan Leitet <johan@sourceful-labs.com>
Signed-off-by: Cursor Agent <cursoragent@cursor.com>
@cursor
cursor Bot force-pushed the cursor/foxess-h3-smart-mode-dwell-7b81 branch from 4591c51 to 46be264 Compare December 5, 2026 14:18

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.

2 participants