Repository navigation
Talk to the heat pump through modbus-connection (v1.18.0) - #10
Merged
Merged
Conversation
Replace pymodbus with modbus-connection on its tmodbus backend, the Modbus layer Home Assistant core shares between integrations. QubeClient keeps its constructor and opens its own connection, or takes a caller's ModbusUnit (QubeClient(host, unit=unit)) and leaves that connection alone. modbus-connection never replays a request, so a block read whose response went missing or arrived garbled is tried once more; writes are never retried. connect() gives up after 3 s without cancelling the shared connect task, so a caller's own timeout no longer makes asyncio log an error. Tests run on the modbus-connection in-memory mock.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces pymodbus with modbus-connection on its tmodbus backend. This is the Modbus layer Home Assistant core shares between integrations (
homeassistant.components.modbus.async_get_unit). Core pinsmodbus-connection[tmodbus]==4.12.7andtmodbus==1.1.0; this requires>=4.12.7.API
QubeClient(host, port, unit_id)works as before and opens its own connection.QubeClient(host, unit=unit)takes a caller'sModbusUnit.connect()returns True andclose()leaves the connection alone;hostonly labels messages.close()now drops the link withdisconnect(). The client stays usable and the next request reconnects.==1.17.0until a bump PR.Behaviour changes
None,get_all_data()returnsNoneand the link is dropped. An error reply or a short response still falls back to single reads. Writes are never retried.connect()without asyncio error logs. The attempt runs in its own task and waits withasyncio.wait. A caller'sasyncio.timeoutaroundconnect()(both config flows have one) used to cancel modbus-connection's shielded connect. On an unreachable host, Python 3.14 then logged "exception in shielded future" about 10 s later.get_all_data()reconnects stays for owned connections.Tests
modbus-connectionpytest plugin (mock_modbus_unit), with helpers intests/helpers.py.mypy --strictand ruff 0.14.14 are clean.Not done yet