Skip to content

Modbus: fix delay and timeout handling - #32694

Merged
andig merged 4 commits into
masterfrom
fix/modbus-template-timeout-default
Aug 10, 2026
Merged

Modbus: fix delay and timeout handling#32694
andig merged 4 commits into
masterfrom
fix/modbus-template-timeout-default

Conversation

@andig

@andig andig commented Aug 10, 2026

Copy link
Copy Markdown
Member

Regression from #31996, found while investigating #32687.

Templates that deprecated their own delay/timeout param in favour of the modbus definition rendered no value at all, so the affected devices silently fell back to the modbus library default of 3s instead of their device-specific value. On top of that, delay and timeout are properties of the physical connection, which is shared between all logical connections of the same uri or device, so the last configured device used to overrule all others.

  • deprecated params are pre-populated with an empty default value, which the modbus value merge treated as user-supplied and therefore skipped
  • restores e.g. timeout: 15s for huawei-sun2000-inverter and delay: 100ms for wattsonic, in rendered configs, docs and config UI defaults alike
  • affects all templates that deprecated delay or timeout, among them the huawei-sun2000, solaredge, sungrow and saj templates
  • delay, connect delay and timeout now keep the largest value requested by any of the sharing connections, the modbus proxy included

🤖 Generated with Claude Code

Templates that deprecated their own delay or timeout param in favour of the
modbus definition rendered no value at all. Deprecated params are pre-populated
with an empty default which was treated as a user-supplied value.
@andig andig added bug Something isn't working devices Specific device support labels Aug 10, 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 left some high level feedback:

  • In ModbusValues, the v != nil && v != "" guard now treats any non-nil, non-empty-string value as a user override, which means zero-values of non-string types (e.g. 0, false) will also block default propagation; if the params are expected to be strings only, consider making that explicit with a type assertion or a type switch so that future non-string params don't accidentally rely on this behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `ModbusValues`, the `v != nil && v != ""` guard now treats any non-nil, non-empty-string value as a user override, which means zero-values of non-string types (e.g. `0`, `false`) will also block default propagation; if the params are expected to be strings only, consider making that explicit with a type assertion or a type switch so that future non-string params don't accidentally rely on this behavior.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@andig
andig enabled auto-merge (squash) August 10, 2026 14:37
Delay, connect delay and timeout apply to the physical connection which is
shared between all logical connections of the same uri or device, including the
modbus proxy. Keep the largest requested value instead of letting the last
writer win.
@andig andig changed the title Modbus: fix missing template delay and timeout defaults Modbus: fix delay and timeout handling Aug 10, 2026
@andig
andig merged commit 285b01f into master Aug 10, 2026
8 of 9 checks passed
@andig
andig deleted the fix/modbus-template-timeout-default branch August 10, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working devices Specific device support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant