Migrate serial backend from pyserial to serialx#13
Open
balloob wants to merge 2 commits into
Open
Conversation
* Initial plan * feat: migrate serial backend to serialx Co-authored-by: balloob <1444314+balloob@users.noreply.github.com> * docs: clarify serialx port initialization Co-authored-by: balloob <1444314+balloob@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: balloob <1444314+balloob@users.noreply.github.com>
balloob
commented
Feb 27, 2026
Author
|
Home Assistant 2026.5 will have full support for ESPHome proxies and a new Serial Port selector that the Monoprice integration could leverage when migrating to serialx. |
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.
Hey,
With the Open Home Foundation we're working on adding serial proxies to ESPHome. It will allow users to connect an ESPHome device to the serial port, and then connect to it via Home Assistant. Seamlessly :-)
Because python serial land has been quite stale (with fixes not getting published), we've been working on our own serial library
serialxwhich is a drop-in replacement for python-serial. It is already used inside Home Assistant for things like Zigbee.We will soon add support for the ESPHome serial proxies to serialx (PR) and HA (TBD), and so are looking into getting interesting integrations in HA ready to be able to leverage this.
I've asked AI to migrate this lib to serialx, so that when ESPHome support lands, it can just be a dep bump.
Would you be open for switching the serial library and test this PR?
~Paulus
(below written by AI)
CoPilot summary
This updates the library to use
serialxas the serial transport backend instead ofpyserial/pyserial-asyncio-fast, covering both sync and asyncio paths. The migration keeps the existingpymonopriceAPI behavior intact while switching underlying serial implementation.Runtime migration (sync + async)
serialandserial_asyncio_fastusage withserialxin core runtime code.serial_for_url(...)toserialx.Serial(...)with equivalent serial settings.serialx.create_serial_connection(...).serialx.SerialTransport.Timeout/error compatibility
SerialTimeoutExceptionand raised it on sync read timeout, preserving the package-level timeout contract used by callers/tests.Dependency updates
pyserialandpyserial-asyncio-fastrequirements withserialx>=0.7.0in packaging and requirements files.Tests aligned with new backend contract
pymonoprice.SerialTimeoutExceptioninstead ofserial.SerialTimeoutException.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.