Skip to content

Write 32-bit modbus registers high-word-first on S series pumps - #316

Draft
yozik04 with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-reversed-word-order
Draft

Write 32-bit modbus registers high-word-first on S series pumps#316
yozik04 with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-reversed-word-order

Conversation

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown

Pull Request Type

Please select the type of your PR:

  • Add/Update Registries
  • Feature
  • Bug Fix

Description

Heatpump model: S1256 (all S series)

Firmware version: N/A

S series pumps are asymmetric over modbus: 32-bit read responses come back low-word-first, but FC16 writes must be high-word-first. word_swap was applied to both directions, so no setting worked for both — with word_swap: true every 32-bit write was ACKed and silently discarded, with false every read decoded garbage.

Ground truth for 40012 "Degree minutes" (s32, factor 10) at 20.5 °C: the pump reads back [205, 0] and only accepts [0, 205] on write.

Changes

  • CoilDataEncoderModbus: new optional word_swap_write overriding the word order used for encoding only. Unset (None) keeps word_swap for both directions, so nothing changes for existing callers.
  • Modbus: passes word_swap_write=False when the pump model is Series.S, so 32-bit writes always go out high-word-first while reads keep honouring word_swap. F series (Modbus 40, which has the symmetric Modbus40 Word Swap register 48852) and pumps with no model set are unaffected.
  • Tests: added coverage for the asymmetric encoder and for F series writes staying symmetric; updated the existing S1255-fixture 32-bit write expectations, which encoded the broken order.
hp = HeatPump(Model.S1256)
hp.word_swap = True
conn = Modbus(hp, "tcp://192.168.1.2:502", 1)

await conn.read_coil(coil)              # [205, 0] -> 20.5
await conn.write_coil(CoilData(coil, 20.5))  # -> [0, 205]

Checklist

  • I have followed the instructions
  • I ensured that my changes are well tested

Co-authored-by: yozik04 <2420038+yozik04@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix writable 32-bit registers word order on S-series Modbus TCP Write 32-bit modbus registers high-word-first on S series pumps Sep 2, 2026
Copilot AI requested a review from yozik04 September 2, 2026 06:52
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.

All writable 32-bit registers are written with reversed word order on S-series Modbus TCP

2 participants