Skip to content

Use FC16 for single-register control writes (fixes writes on SUN-12K-SG05LP3) - #3

Open
iz3man wants to merge 1 commit into
Developer089:mainfrom
iz3man:fc16-writes
Open

iz3man wants to merge 1 commit into
Developer089:mainfrom
iz3man:fc16-writes

Conversation

@iz3man

@iz3man iz3man commented Sep 27, 2026

Copy link
Copy Markdown

Problem

On my SUN-12K-SG05LP3 (via the Deye WiFi/LAN logger, port 8899), all control
entities (number/select/switch) fail to write. The integration sends FC06
(Write Single Register), which the inverter silently ignores. pymodbus logs
"No response received after 3 retries", the entity briefly goes unavailable and
the value never changes. Writing the same register via the
deye_modbus.write_registers service (FC16) works immediately.
Deye's Modbus protocol document specifies FC16 (0x10) for writes.

Changes

  • New option Write mode (fc16 default / fc06 legacy). write_single_register()
    sends FC16 with one value when fc16 is selected, so all existing control
    entities work without map changes.
  • Writes now acquire the coordinator lock used by polling. Previously a write
    could interleave with a running poll on the shared connection (transaction_id
    mismatches, lost writes).
  • Write failures are logged (register + reason) instead of being swallowed, and
    entities raise HomeAssistantError so failures are visible in the UI/traces.
  • Consolidated the FC05/FC06/FC16 write helpers into one _write_call().
  • write_register service stays explicitly FC06 (as documented); description updated.
  • README, en/cs translations, version bump to 0.1.2.

Testing

  • SUN-12K-SG05LP3: TOU SOC 1 set 15 → 16 → 15 % via number.set_value,
    confirmed via the RB readback sensor; no timeouts.
  • Coordinator tested against a pymodbus TCP server that drops FC06:
    fc16 → write succeeds; fc06 → logged failure, returns False.

… writes with polling, surface write failures
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