Skip to content

Wattsonic MATIC: add meter template with battery control - #36406

Open
WattsonicAdmin wants to merge 1 commit into
evcc-io:masterfrom
WattsonicAdmin:wattsonic-matic
Open

WattsonicAdmin wants to merge 1 commit into
evcc-io:masterfrom
WattsonicAdmin:wattsonic-matic

Conversation

@WattsonicAdmin

Copy link
Copy Markdown

Adds a meter template for the Wattsonic MATIC hybrid inverter (10–25 kW, native Modbus TCP/RTU, ARM firmware ≥ 1130), with grid, PV and battery usage and battery-control.

MATIC uses a different register map than the Wattsonic GEN2/GEN3 AIO series that solinteg-gen2 / solinteg-gen3 already cover, so MATIC users currently have no working template.

Battery control

batterymode uses the watchdog source (timeout 10s, so values are repeated every 5 s):

Mode Writes
normal 11045 = 0, 11060 = 0 (leave external control), 11069 = 2500 (no discharge limit)
holddischarge 11045 = 0, 11060 = 0, then 11069 = 0 (block discharge in local self-consumption mode)
charge heartbeat 12026, 11069 = 2500, 11060 = 1, 12002 = 1, 11045 = −maxchargepower (grid import setpoint)

Notes:

  • 11045 is an absolute setpoint at the grid connection point (meter), so charge imports maxchargepower from the grid.
  • The inverter ignores external setpoints unless its EMS watchdog is enabled. The one-time installer settings (11701/11702/11704/11700) are documented in requirements. On communication loss the inverter falls back to self-consumption after the watchdog timeout.
  • holddischarge must leave external control first; otherwise a previous charge setpoint stays active.

Testing

  • go test ./meter/ -run TestTemplates/wattsonic-matic and go test ./util/templates/... pass. The rendered battery config was checked with maxchargepower: 3000 (11045 = −300).
  • The write sequences were replayed on a real 25 kW MATIC (ARM 1132), following the evcc watchdog semantics (sequence on mode change, re-sent every 5 s):
    • charge: grid import tracked 3000 W within ±20 W, battery charging about 2.8 kW. The first activation took 3–9 s; steady state was reached on the next repeat.
    • holddischarge: discharge blocked, and grid charging stopped.
    • normal: discharge restored; external control released within 0.4–1.7 s.
    • communication loss (no writes for 75 s): the watchdog tripped at 60 s and the inverter returned to self-consumption. Resuming writes restored control within 3 s.

I am with Wattsonic and can verify follow-up changes on hardware.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added devices Specific device support enhancement New feature or request labels Nov 19, 2026

@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 5 issues

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

## Individual Comments

### Comment 1
<location path="templates/definition/meter/wattsonic-matic.yaml" line_range="118" />
<code_context>
+                address: 11069 # Battery Max Discharge Power, 0.01 kW
+                type: writesingle
+                encoding: int16
+      - case: 2 # holddischarge: leave external control first, then block discharge in local mode
+        set:
+          source: sequence
</code_context>
<issue_to_address>
**Hold mode loses battery control**

When holddischarge remains active beyond the configured 60-second watchdog timeout, the `holddischarge` sequence does not refresh heartbeat register 12026, so the inverter watchdog returns to self-consumption and allows battery discharge while evcc still requests a hold.

Refresh heartbeat register 12026 from the `holddischarge` sequence.
</issue_to_address>

### Comment 2
<location path="templates/definition/meter/wattsonic-matic.yaml" line_range="149" />
<code_context>
+                address: 11069 # Battery Max Discharge Power, 0.01 kW
+                type: writesingle
+                encoding: int16
+      - case: 3 # charge: import maxchargepower from the grid (setpoint at the grid connection point)
+        set:
+          source: sequence
</code_context>
<issue_to_address>
**Partial writes leave mixed mode**

When a Modbus write fails partway through a battery-mode sequence, `sequencePlugin` stops at the first failed Modbus write, while the watchdog setter has already stopped repeating the previous mode and only starts repeating the new one after the full sequence succeeds. Registers written before the error remain changed and later ones remain stale, so the inverter can briefly operate in a mixed mode until a retry or its own watchdog takes effect.

On sequence failure, explicitly restore a safe mode or ensure the full desired sequence is retried promptly before treating the transition as complete.
</issue_to_address>

### Comment 3
<location path="templates/definition/meter/wattsonic-matic.yaml" line_range="30" />
<code_context>
+    port: 502
+  - preset: battery-params
+  - name: maxchargepower
+    required: true
+  - name: capacity
+    advanced: true
</code_context>
<issue_to_address>
**Grid/PV meters require battery setting**

When a user selects grid or PV usage without configuring `maxchargepower`, `maxchargepower` is required during validation even though those render branches do not use it, so the configuration is rejected and the meter cannot be used.

Require `maxchargepower` only for battery usage.
</issue_to_address>

### Comment 4
<location path="templates/definition/meter/wattsonic-matic.yaml" line_range="25-27" />
<code_context>
+  - name: usage
+    choice: ["grid", "pv", "battery"]
+  - name: modbus
+    choice: ["rs485", "tcpip"]
+    id: 1
+    port: 502
+  - preset: battery-params
+  - name: maxchargepower
</code_context>
<issue_to_address>
**RS485 connections lack baud rate**

When the template is configured to use RS485, selecting `rs485` leaves the rendered Modbus configuration without a baud rate, so opening the serial connection fails instead of reading or controlling the inverter.

Set the MATIC’s required RS485 baud rate on the `modbus` parameter.
</issue_to_address>

### Comment 5
<location path="templates/definition/meter/wattsonic-matic.yaml" line_range="40-48" />
<code_context>
+    source: modbus
+    {{- include "modbus" . | indent 2 }}
+    register:
+      address: 10765 # Meter Active Power Total, 0.01 kW, positive = export
+      type: holding
+      decode: int16
+    scale: -10
+  energy:
+    source: modbus
+    {{- include "modbus" . | indent 2 }}
+    register:
+      address: 10781 # Meter Energy Import, 0.1 kWh
+      type: holding
+      decode: uint32
</code_context>
<issue_to_address>
**Unnecessary register-description comments**

These inline comments label registers and restate their values or units, adding comments that explain what the code does rather than why. The template therefore violates the repository's comment guidance.

Remove comments that only restate register meanings, values, or units, keeping comments that explain non-obvious constraints or behavior.

Also at `templates/definition/meter/wattsonic-matic.yaml:58-76`, `templates/definition/meter/wattsonic-matic.yaml:97-115`, `templates/definition/meter/wattsonic-matic.yaml:128-146`, `templates/definition/meter/wattsonic-matic.yaml:168-195`.
</issue_to_address>

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

address: 11069 # Battery Max Discharge Power, 0.01 kW
type: writesingle
encoding: int16
- case: 2 # holddischarge: leave external control first, then block discharge in local mode

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.

🟠 High · Hold mode loses battery control

When holddischarge remains active beyond the configured 60-second watchdog timeout, the holddischarge sequence does not refresh heartbeat register 12026, so the inverter watchdog returns to self-consumption and allows battery discharge while evcc still requests a hold.

Refresh heartbeat register 12026 from the holddischarge sequence.

Prompt for AI agents
In `templates/definition/meter/wattsonic-matic.yaml` at line 118:

**Hold mode loses battery control**

When holddischarge remains active beyond the configured 60-second watchdog timeout, the `holddischarge` sequence does not refresh heartbeat register 12026, so the inverter watchdog returns to self-consumption and allows battery discharge while evcc still requests a hold.

Refresh heartbeat register 12026 from the `holddischarge` sequence.

address: 11069 # Battery Max Discharge Power, 0.01 kW
type: writesingle
encoding: int16
- case: 3 # charge: import maxchargepower from the grid (setpoint at the grid connection point)

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.

🟡 Medium · Partial writes leave mixed mode

When a Modbus write fails partway through a battery-mode sequence, sequencePlugin stops at the first failed Modbus write, while the watchdog setter has already stopped repeating the previous mode and only starts repeating the new one after the full sequence succeeds. Registers written before the error remain changed and later ones remain stale, so the inverter can briefly operate in a mixed mode until a retry or its own watchdog takes effect.

On sequence failure, explicitly restore a safe mode or ensure the full desired sequence is retried promptly before treating the transition as complete.

Prompt for AI agents
In `templates/definition/meter/wattsonic-matic.yaml` at line 149:

**Partial writes leave mixed mode**

When a Modbus write fails partway through a battery-mode sequence, `sequencePlugin` stops at the first failed Modbus write, while the watchdog setter has already stopped repeating the previous mode and only starts repeating the new one after the full sequence succeeds. Registers written before the error remain changed and later ones remain stale, so the inverter can briefly operate in a mixed mode until a retry or its own watchdog takes effect.

On sequence failure, explicitly restore a safe mode or ensure the full desired sequence is retried promptly before treating the transition as complete.

port: 502
- preset: battery-params
- name: maxchargepower
required: true

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.

🟡 Medium · Grid/PV meters require battery setting

When a user selects grid or PV usage without configuring maxchargepower, maxchargepower is required during validation even though those render branches do not use it, so the configuration is rejected and the meter cannot be used.

Require maxchargepower only for battery usage.

Prompt for AI agents
In `templates/definition/meter/wattsonic-matic.yaml` at line 30:

**Grid/PV meters require battery setting**

When a user selects grid or PV usage without configuring `maxchargepower`, `maxchargepower` is required during validation even though those render branches do not use it, so the configuration is rejected and the meter cannot be used.

Require `maxchargepower` only for battery usage.

Comment on lines +25 to +27
choice: ["rs485", "tcpip"]
id: 1
port: 502

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.

🟡 Medium · RS485 connections lack baud rate

When the template is configured to use RS485, selecting rs485 leaves the rendered Modbus configuration without a baud rate, so opening the serial connection fails instead of reading or controlling the inverter.

Set the MATIC’s required RS485 baud rate on the modbus parameter.

Prompt for AI agents
In `templates/definition/meter/wattsonic-matic.yaml` at lines 25-27:

**RS485 connections lack baud rate**

When the template is configured to use RS485, selecting `rs485` leaves the rendered Modbus configuration without a baud rate, so opening the serial connection fails instead of reading or controlling the inverter.

Set the MATIC’s required RS485 baud rate on the `modbus` parameter.

Comment on lines +40 to +48
address: 10765 # Meter Active Power Total, 0.01 kW, positive = export
type: holding
decode: int16
scale: -10
energy:
source: modbus
{{- include "modbus" . | indent 2 }}
register:
address: 10781 # Meter Energy Import, 0.1 kWh

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.

⚪ Low · Unnecessary register-description comments

These inline comments label registers and restate their values or units, adding comments that explain what the code does rather than why. The template therefore violates the repository's comment guidance.

Remove comments that only restate register meanings, values, or units, keeping comments that explain non-obvious constraints or behavior.

Also at templates/definition/meter/wattsonic-matic.yaml:58-76, templates/definition/meter/wattsonic-matic.yaml:97-115, templates/definition/meter/wattsonic-matic.yaml:128-146, templates/definition/meter/wattsonic-matic.yaml:168-195.

Prompt for AI agents
In `templates/definition/meter/wattsonic-matic.yaml` at lines 40-48:

**Unnecessary register-description comments**

These inline comments label registers and restate their values or units, adding comments that explain what the code does rather than why. The template therefore violates the repository's comment guidance.

Remove comments that only restate register meanings, values, or units, keeping comments that explain non-obvious constraints or behavior.

Also at `templates/definition/meter/wattsonic-matic.yaml:58-76`, `templates/definition/meter/wattsonic-matic.yaml:97-115`, `templates/definition/meter/wattsonic-matic.yaml:128-146`, `templates/definition/meter/wattsonic-matic.yaml:168-195`.

From AGENTS.md L112-115:

- Prefer self-documenting code over comments; comment the _why_, not the _what_
- Default to no comment. Only add one for a non-obvious constraint, invariant, workaround, or surprising behavior. Keep it to one line, two if necessary
- Skip refs to the current task, PR, issue, or caller ("added for X flow", "see #1234"). Git history covers that
- Exception: Go exported identifiers follow godoc convention. Short `// FuncName does X` summary starting with the identifier name

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

Labels

devices Specific device support enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant