Skip to content

feat(deye_hybrid): support TOU slot controls (Gen SOC, Grid/Gen Charge, Sell) and fix packed register handling - #1182

Open
KBADPO wants to merge 3 commits into
davidrapan:mainfrom
KBADPO:main
Open

KBADPO wants to merge 3 commits into
davidrapan:mainfrom
KBADPO:main

Conversation

@KBADPO

@KBADPO KBADPO commented Oct 14, 2026

Copy link
Copy Markdown

Summary

This PR adds complete Time-of-Use (TOU) slot controls to deye_hybrid.yaml (Deye single-phase hybrid inverters, e.g. SG0*LP1) and fixes core handling for packed/masked registers when reading and writing.

What Was Fixed & Added

  1. Parser & Scaling Order (parser.py):

    • In modern Deye firmware, registers 0x0110–0x0115 pack Battery SOC in the low byte (mask: 0x00FF) and Generator SOC in the high byte (mask: 0xFF00, divide: 256).
    • Moved mask, bit, bitmask, divide, and offset processing before the range check in _read_registers and _read_registers_signed. Previously, the raw unmasked 16-bit value (e.g. 5160 for 0x1428) failed validation or displayed incorrectly.
  2. Preserve Adjacent Bytes on Write (entity.py):

    • Added self.mask support to SolarmanWritableEntity.write().
    • When updating a packed sub-register (such as Gen SOC or Battery SOC), the neighboring byte in the same holding register is now preserved rather than overwritten with zeroes.
  3. Divide Scaling on Number Writes (number.py):

    • Handled self.divide in SolarmanNumberEntity.async_set_native_value(), ensuring values written to high-byte fields (e.g., multiplied by 256) are encoded accurately.
  4. TOU Program Slot Entities (deye_hybrid.yaml):

    • Added Program 1–6 Gen SOC (number).
    • Added Program 1–6 Grid Charge switch (bit: 0).
    • Added Program 1–6 Gen Charge switch (bit: 1).
    • Added Program 1–6 Sell switch with corrected Deye Modbus specification bit (bit: 6).
    • Kept all existing definitions and BMS groups intact.

Testing

  • Tested on a Deye single-phase hybrid inverter (SUN-6K-SG05LP1-EU).
  • Verified that:
    • Both Battery % and Gen % display real values simultaneously (e.g., 40% and 20%) instead of combined 16-bit values.
    • Toggling and setting values across Slots 1–6 accurately updates the inverter without corrupting neighboring parameters.
    • The "Sell" toggle accurately reflects and controls the inverter setting (bit 6).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant