Skip to content

Solax: re-write battery mode before manual mode times out - #35869

Closed
JohannesRudolph wants to merge 2 commits into
evcc-io:masterfrom
JohannesRudolph:solax-hold-watchdog
Closed

JohannesRudolph wants to merge 2 commits into
evcc-io:masterfrom
JohannesRudolph:solax-hold-watchdog

Conversation

@JohannesRudolph

@JohannesRudolph JohannesRudolph commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

A Solax X3 Hybrid G4 switches from manual mode back to self use 6 hours after evcc writes hold. evcc keeps reporting hold, so the battery discharges during a planned overnight hold. Seen twice: the inverter's SolarChargeUseMode flipped to self use at 6h00m after each write (20:45:17 → 02:45:20, 21:13:19 → 03:13:21 UTC), with no other writer.

This wraps batterymode in a watchdog, like other battery templates. A fixed 4h timeout re-writes every 2h: below the inverter's timeout, with few register writes. Normal mode resets the watchdog.

Best reviewed with whitespace hidden: the switch only moved one level down.

go test ./util/templates/... ./meter/ passes. Running on a nightly since 2026-11-06.

🤖 Generated with Claude Code

The inverter switches from manual mode back to self use 6 hours after
evcc sets hold or charge. evcc does not notice and keeps reporting the
mode, so the battery discharges during a planned hold.

Wrap batterymode in a watchdog. The default of 4h re-writes the mode
every 2h, which stays below the timeout with few register writes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the devices Specific device support label Nov 6, 2026
The 6h timeout is fixed inverter behaviour, so users have nothing to tune.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
source: const
value: {{ .defaultmode }}
source: watchdog
timeout: 4h # inverter leaves manual mode after 6h, re-write at timeout/2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

for review: I could not find any official solax documentation on timeouts, or if timeouts are configurable at all via modbus (in my SMA inverters it is for example). I have hence decided to just write a fixed value here since I assume the 6h is a hardcoded firmware default on the solax inverters

@JohannesRudolph
JohannesRudolph marked this pull request as ready for review November 6, 2026 07:45

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="templates/definition/meter/solax.yaml" line_range="154" />
<code_context>
-      set:
-        source: const
-        value: {{ .defaultmode }}
+    source: watchdog
+    timeout: 4h # inverter leaves manual mode after 6h, re-write at timeout/2
+    reset: 1 # reset watchdog on normal
</code_context>
<issue_to_address>
**Hold watchdog stops after failed mode change**

When a mode change from hold fails during its Modbus write, then hold is requested again before the failed mode is successfully applied, `watchdogPlugin.setter` cancels the active hold watchdog before writing the new mode. If that write fails, `applyBatteryMode` keeps its cached hold state; when hold is requested again, it skips the setter, leaving no watchdog to refresh the inverter and it eventually returns to self-use.

Preserve or restart the previous mode's watchdog when a new mode write fails, or invalidate the cached applied mode so the next request reapplies it.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread templates/definition/meter/solax.yaml Resolved
@JohannesRudolph

JohannesRudolph commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

I retract this PR for the time being. Solax is a mess. The register unfortunately is written to EEPROM so not great for use in combination with a watchdog. The bigger problem is that hold mode as currently implemented sends PV into the battery but covers the house from the grid (!) instead of PV surplus.

This has been discussed before but no solution for this yet evcc-io/evcc#27120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devices Specific device support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant