Skip to content

Solis Hybrid S: fix power decoding#29547

Merged
andig merged 1 commit intomasterfrom
device/solis-hybrid-s-abs
May 2, 2026
Merged

Solis Hybrid S: fix power decoding#29547
andig merged 1 commit intomasterfrom
device/solis-hybrid-s-abs

Conversation

@premultiply
Copy link
Copy Markdown
Member

The battery power calculation was updated to correctly handle both firmware variants of the Solis Hybrid (S Series) inverter:

Before: Register 33149 was read as uint32. When the firmware reports a negative value as a signed 32-bit integer (e.g. 0xFFFFFC7C = −900 W during discharge), this was misinterpreted as ~4,295 MW — a classic 32-bit unsigned overflow.

After: Register 33149 is now read as int32, and its absolute value is taken via calc + abs. The sign is then applied separately by multiplying with +1 or −1 derived from the direction register 33135.

power = abs(int32(reg 33149)) × ((reg 33135 × 2) − 1)

This handles both known firmware variants:

Fixes #28732

@premultiply premultiply self-assigned this May 1, 2026
Copilot AI review requested due to automatic review settings May 1, 2026 19:50
@premultiply premultiply added the devices Specific device support label May 1, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

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:

  • Consider how the abs operation behaves for int32 on the minimum value (-2^31); if the calc engine doesn't guard against abs(INT32_MIN) overflow, explicitly clamping or converting to a larger numeric type before abs may be safer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider how the `abs` operation behaves for `int32` on the minimum value (`-2^31`); if the calc engine doesn't guard against `abs(INT32_MIN)` overflow, explicitly clamping or converting to a larger numeric type before `abs` may be safer.

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.

@premultiply premultiply changed the title Solis Hybrid S: use int32 decoding and abs() Solis Hybrid S: fix power decoding May 1, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Solis Hybrid (S Series) meter template’s battery power calculation to correctly interpret register 33149 across firmware variants by decoding it as int32 and applying abs() before applying the charge/discharge direction from register 33135.

Changes:

  • Change battery power register 33149 decoding from uint32 to int32.
  • Wrap battery power in a calc + abs stage before multiplying by the direction-derived sign.

@andig andig merged commit 06819fd into master May 2, 2026
23 checks passed
@andig andig deleted the device/solis-hybrid-s-abs branch May 2, 2026 04:09
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.

Ginlog Solis Hybrid inverter : Incorrect power values (32-bit overflow) when battery is discharging + Modbus timeouts

3 participants