Skip to content

[solax] Add missing channels for X1 Hybrid G4 inverter#20660

Merged
lsiepel merged 3 commits intoopenhab:mainfrom
theater:feature/x1-hybrid-g4-additional-channels
May 4, 2026
Merged

[solax] Add missing channels for X1 Hybrid G4 inverter#20660
lsiepel merged 3 commits intoopenhab:mainfrom
theater:feature/x1-hybrid-g4-additional-channels

Conversation

@theater
Copy link
Copy Markdown
Contributor

@theater theater commented May 3, 2026

Summary

  • Add 8 missing channel implementations for the X1 Hybrid G4 inverter (type=15) in X1HybridG4Data
  • All channels were already defined in CommonLocalDeviceData and wired up in the binding but returned default/zero values for this inverter type
  • Register mapping verified against live inverter data (firmware 3.008.10)

Added channels

Channel Register Scale Description
power-usage Data[38] House consumption (W)
today-energy Data[13] ÷10 Today's PV yield (kWh)
total-pv-energy packU16(12,11) ÷10 Lifetime PV energy (kWh)
total-feed-in-energy packU16(35,34) ÷100 Lifetime grid export (kWh)
total-consumption packU16(37,36) ÷100 Lifetime grid import (kWh)
today-feed-in-energy Data[39] ÷10 Today's grid export (kWh)
today-battery-discharge-energy Data[87] ÷10 Today's battery discharge (kWh)
today-battery-charge-energy Data[85] ÷10 Today's battery charge (kWh)

@theater theater added enhancement An enhancement or new feature for an existing add-on work in progress A PR that is not yet ready to be merged labels May 3, 2026
@theater theater force-pushed the feature/x1-hybrid-g4-additional-channels branch from a5618d7 to 7453aaf Compare May 3, 2026 09:13
@theater theater removed the work in progress A PR that is not yet ready to be merged label May 3, 2026
theater added 2 commits May 3, 2026 12:22
Implements the following previously unmapped local API registers:

- getPowerUsage()          → Data[38]            (house consumption W)
- getTodayEnergy()         → Data[13] / 10       (today's PV yield kWh)
- getTotalPVEnergy()       → packU16(12,11) / 10 (lifetime PV energy kWh)
- getTotalFeedInEnergy()   → packU16(35,34) / 100 (lifetime feed-in kWh)
- getTotalConsumption()    → packU16(37,36) / 100 (lifetime grid import kWh)
- getTodayFeedInEnergy()   → Data[39] / 10       (today's feed-in kWh)
- getTodayBatteryDischargeEnergy() → Data[23] / 10 (today battery discharge kWh)
- getTodayBatteryChargeEnergy()    → Data[24] / 10 (today battery charge kWh)

Register mapping verified against live inverter data (type=15, fw 3.008.10).
Power usage cross-checked: AC output (1516W) - feed-in (7W) = 1509W = Data[38].

Updates X1HybridG4DataParser supported channels set and adds test assertions.

Signed-off-by: Konstantin Polihronov <polychronov@gmail.com>
…brid G4

Corrected register mapping based on 30-minute live monitoring session
correlating Data[] changes against battery SoC (74% → 97%):

- getTodayBatteryChargeEnergy(): Data[23] → Data[85] / 10
- getTodayBatteryDischargeEnergy(): Data[24] → Data[87] / 10

Data[23]/Data[24] were wrong — Data[24] was completely static throughout
the entire charging session. Data[85] tracked SoC delta 1:1 (confirmed
charge energy), Data[87] was stable while charging and only moved during
earlier discharge periods (confirmed discharge energy).

Updates test assertions accordingly.

Signed-off-by: Konstantin Polihronov <polychronov@gmail.com>
@theater theater force-pushed the feature/x1-hybrid-g4-additional-channels branch from 7453aaf to d655e90 Compare May 3, 2026 09:28
@lsiepel lsiepel requested a review from Copilot May 3, 2026 11:03
Copy link
Copy Markdown
Contributor

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

Adds the missing channel implementations for the SolaX X1 Hybrid G4 (type=15) local parser/data model so existing binding channels return real values instead of defaults.

Changes:

  • Implement 8 previously-missing LocalData getters in X1HybridG4Data (today/total energy, power usage, etc.) using the correct raw register indices and scaling.
  • Extend X1HybridG4DataParser supported-channel set to advertise those channels for this inverter type.
  • Extend the existing parser test to assert the new channel values.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/local/X1HybridG4Data.java Adds the missing channel getters (raw register mapping + scaling) for X1 Hybrid G4.
bundles/org.openhab.binding.solax/src/main/java/org/openhab/binding/solax/internal/model/local/inverters/X1HybridG4DataParser.java Exposes the added channels as supported for the X1 Hybrid G4 parser.
bundles/org.openhab.binding.solax/src/test/java/org/openhab/binding/solax/internal/local/parsers/TestX1HybridG4Parser.java Adds assertions for the new getters/channels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

When the high word (major) is zero, packU16 returned the low word
(minor) directly as a signed short. This caused negative results for
any 32-bit counter whose value falls in the range 0x8000–0xFFFF of
the low word (e.g. total-pv-energy between ~3276–6553 kWh at ÷10
scaling, or total-feed-in-energy between ~327–655 kWh at ÷100).

Fix by using Short.toUnsignedLong(minor) in the major==0 branch,
consistent with the Integer.toUnsignedLong() already used in the
general case.

Restore the original Data[11]=59781 test fixture (which exercises
this unsigned overflow path) and reinstate the 5978.1 kWh assertion.

Signed-off-by: Konstantin Polihronov <polychronov@gmail.com>
Copy link
Copy Markdown
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@lsiepel lsiepel merged commit aa474db into openhab:main May 4, 2026
2 checks passed
@lsiepel lsiepel added this to the 5.2 milestone May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An enhancement or new feature for an existing add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants