Skip to content

feat(drivers): align Solis + Deye control with Zap reference - #74

Merged
frahlg merged 1 commit into
srcfl:masterfrom
davmoz:feat/solis-deye-control-from-zap
Apr 16, 2026
Merged

frahlg merged 1 commit into
srcfl:masterfrom
davmoz:feat/solis-deye-control-from-zap

Conversation

@davmoz

@davmoz davmoz commented Apr 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Rewrite Solis control to the register set that works on real S5/S6 hardware: 43110 (mode bit-field), 43129/43136 (power, 10 W units), 43135 (mode select), 43130/43131 (per-direction limits at init). 100 ms inter-write pacing.
  • Rewrite Deye control with strict HV/LV detect on reg 0, 13-register init profile, current-based charge via reg 108 using a live battery-voltage read (reg 587, A = W / V), power-based discharge via reg 154 with HV/LV scaling, curtailment via regs 143 + 145, 5-register self-consumption revert. 50 ms inter-write pacing.
  • Add host.sleep(ms) to the Lua driver host for vendor-required inter-write pacing.
  • New Deye YAML knobs: rated_w, max_grid_charge_a (reg 128, clamped 0..185), soc_min / soc_max (reg 166 targets, clamped 0..100 with swap guard).

Why

Previous register layouts diverged from what hardware actually accepts. Cross-checked Solis Appendix 7 + Deye MODBUS RTU V105.3 docs against the Srcful Zap firmware's control profiles, which are validated in production on SUN-SG LV/HV and Solis S5/S6, and pulled the working layout over. Notable semantic clarification from the Deye V105.3 doc:

  • Reg 108 = total max battery-charge current (any source) → the runtime regulator.
  • Reg 128 = grid-source charge-current sub-cap → static, sized to the install's main fuse / subscription.
  • Reg 172 = per-TOU charge-enable bit-field (bit0 grid, bit1 gen); value 3 = both on.

Test plan

  • go build ./... clean
  • go test ./... green (all packages)
  • drivers/solis.lua + drivers/deye.lua load clean in gopher-lua
  • Exercise against a live Solis S5/S6 inverter
  • Exercise against a live Deye LV (SUN-SG03LP1 or similar)
  • Exercise against a live Deye HV (SUN-SG04LP3 or similar)
  • Verify watchdog-timeout → driver_default_mode lands the device in self-consumption

🤖 Generated with Claude Code

Previous register layouts diverged from what works on real hardware.
Cross-checked Solis Appendix 7 + Deye MODBUS RTU V105.3 against the
Srcful Zap firmware control profiles (validated in production on
SUN-SG LV/HV and Solis S5/S6) and pulled the working layout over.

Solis: rewrite to the Zap-confirmed register set. 43110 carries the
mode bit-field (0x60 = forced, 0x21 = self-consume+TOU), 43129/43136
hold charge + discharge power in 10 W units, 43135 selects direction,
43130/43131 seed the per-direction limits at init. 100 ms inter-write
pacing. Lazy init with config.rated_w override.

Deye: strict HV/LV detect on reg 0 (raw == 6 = HV, matching the Zap
reference), 13-register init profile, current-based charge via reg
108 with a live battery-voltage read from reg 587 (A = W / V),
power-based discharge via reg 154 with HV ÷10 / LV ×1 scaling,
curtailment via regs 143 + 145, 5-register self-consumption revert.
50 ms inter-write pacing. New YAML knobs: rated_w, max_grid_charge_a
(reg 128, clamped 0..185), soc_min / soc_max (reg 166 targets,
clamped 0..100 with min>max swap guard).

host: add host.sleep(ms) to the Lua driver host for vendor-required
inter-write pacing.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@frahlg

frahlg commented Apr 16, 2026 •

Copy link
Copy Markdown
Member

Nice work — looks like a well-considered alignment with the Zap reference. Read through the full diff (601 lines). A few observations that don't block merge but are worth being aware of:

Noted behavior changes

  • is_hv = (val == 6) is stricter than before (drops the floor(val/256) == 6 branch). If any existing Deye deploy reports device-type with the 6 in the high byte, it would now be misclassified as LV. You note that Zap uses strict equality on real hardware — so that's correct, but worth flagging in the commit message for future bug-hunters.
  • The Solis curtail action now returns false + "not implemented" instead of the former charge-limit-based variant. Reasonable if it wasn't correct, but if the MPC/control layer already calls curtail against a Solis driver it will now log an error every replanning cycle. Worth checking against internal/control.

Minor (nothing to fix now)

  • REG_SPECIAL_FUNC = 178, value 11816 — documented as "vendor magic" with no explanation. If there's any reference for what it actually does (peak-shaving enable? protocol version?) that'd be gold for a future maintainer.
  • read_battery_voltage() runs on every charge setpoint → an extra Modbus round-trip per dispatch cycle. Acceptable but noted.

Everything else looks good: host.sleep is in the right place, write pacing is per vendor spec, setup is config-driven, idempotent init via flag. Merging.

@frahlg
frahlg merged commit 281f4df into srcfl:master Apr 16, 2026
github-actions Bot pushed a commit that referenced this pull request Apr 16, 2026
## [0.7.0](v0.6.1...v0.7.0) (2026-04-16)

### Features

* **drivers:** align Solis + Deye control with Zap reference ([#74](#74)) ([281f4df](281f4df))
@frahlg

frahlg commented Apr 16, 2026 •

Copy link
Copy Markdown
Member

And a parallel heads-up since you're active in the repo right now: today we had a small history-revision incident where a Claude session on my side did a force-push that accidentally erased PR #71's merge commit from origin/master. The content is restored via PR #75 (cherry-pick with Erik preserved as author), but the v0.5.3 tag on origin still points at a dangling commit. Nothing directly affects your #74 — your branch started from a clean master — but if you notice the v0.5.3 tag looking odd on GitHub, that's why. A new release (0.6.1) has just been cut from current master and should be canonical.

@frahlg frahlg mentioned this pull request Oct 8, 2026
6 tasks done
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