Migrate serial backend from pyserial to serialx#13
Conversation
|
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. |
|
@etsinko could you take a look? |
|
@balloob I can't test it as I don't have monoprice hardware anymore. If you are confident that the migration is correct I can do the merge without problem. |
|
Hi @etsinko, I maintain the Monoprice integration in HA. Since you no longer have the hardware, maybe it will make sense to transfer this project over to the Open Home Foundation or to me? |
|
@OnFreund yes that would work, otherwise everything I'd do in this repo would be released untested. I can transfer the project to you. |
|
Thanks @etsinko. Can you transfer in PyPI as well? |
|
Excellent. I've been in touch with OnFreund and support this! |
|
@OnFreund I think I can only add you as a collaborator in PyPi with full access but I can't transfer it to you or at least I didn't find how to do that. What is your username on pypi? |
* 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>
Co-authored-by: puddly <32534428+puddly@users.noreply.github.com>
Use asyncio.BaseTransport to satisfy the LSP constraint from the base protocol. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Tested on my unit |
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.