Repository navigation
Wattsonic MATIC: add meter template with battery control - #36406
WattsonicAdmin wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
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>| 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 |
There was a problem hiding this comment.
🟠 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) |
There was a problem hiding this comment.
🟡 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 |
There was a problem hiding this comment.
🟡 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.| choice: ["rs485", "tcpip"] | ||
| id: 1 | ||
| port: 502 |
There was a problem hiding this comment.
🟡 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.| 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 |
There was a problem hiding this comment.
⚪ 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
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-gen3already cover, so MATIC users currently have no working template.Battery control
batterymodeuses thewatchdogsource (timeout 10s, so values are repeated every 5 s):Notes:
chargeimportsmaxchargepowerfrom the grid.requirements. On communication loss the inverter falls back to self-consumption after the watchdog timeout.holddischargemust leave external control first; otherwise a previouschargesetpoint stays active.Testing
go test ./meter/ -run TestTemplates/wattsonic-maticandgo test ./util/templates/...pass. The rendered battery config was checked withmaxchargepower: 3000(11045 = −300).sequenceon mode change, re-sent every 5 s):I am with Wattsonic and can verify follow-up changes on hardware.
🤖 Generated with Claude Code