integration/homeassistant/src/openaliro_ha/serial_transport.py
openaliro/openaliro
Module

serial_transport.py

pyserial adapter and privacy-safe serial-port identity helpers.

integration/homeassistant/src/openaliro_ha/serial_transport.py12 documented symbols

Overview

pyserial adapter and privacy-safe serial-port identity helpers.

depends on serial.ts  ·  used by __init__.py agent.py cli.py

API

Cclass SerialTransportError(RuntimeError)

integration/homeassistant/src/openaliro_ha/serial_transport.py:13

A serial transport error that never includes a device path or USB serial.

called by PySerialConnection.close, _import_serial, open_serial_connection, resolve_serial_port

Cclass SerialPort

integration/homeassistant/src/openaliro_ha/serial_transport.py:18

One discoverable serial port with a non-reversible stable identity.

called by discover_serial_ports

F_import_serial() -> Any

integration/homeassistant/src/openaliro_ha/serial_transport.py:29

Import pyserial (serial, list_ports); raise SerialTransportError if not installed.

called by discover_serial_ports, open_serial_connection  ·  calls SerialTransportError

Fserial_identity(*, vid: Optional[int], pid: Optional[int], serial_number: Optional[str], interface: Optional[str], device: Optional[str]=None) -> Optional[str]

integration/homeassistant/src/openaliro_ha/serial_transport.py:39

Hash one USB console endpoint without retaining serial or path text.

Some macOS J-Link drivers omit the CDC interface name. In that case, include the currently assigned endpoint name so two console endpoints cannot collapse into one identity and silently select the wrong one. A later rename fails closed and requires reconfiguration rather than guessing.

called by discover_serial_ports

Fdiscover_serial_ports(ports: Optional[Iterable[Any]]=None) -> tuple[SerialPort, ...]

integration/homeassistant/src/openaliro_ha/serial_transport.py:64

List ports without exposing their paths or USB serials in diagnostics.

called by resolve_serial_port  ·  calls SerialPort, _import_serial, serial_identity

Fresolve_serial_port(serial_port: str, serial_identity_value: Optional[str], *, ports: Optional[Iterable[SerialPort]]=None) -> str

integration/homeassistant/src/openaliro_ha/serial_transport.py:97

Resolve an explicit path or one unambiguous privacy-safe USB identity.

calls SerialTransportError, discover_serial_ports

Cclass PySerialConnection

integration/homeassistant/src/openaliro_ha/serial_transport.py:116

Async wrapper around one opened pyserial connection.

called by open_serial_connection

FPySerialConnection.__init__(self, connection: Any) -> None

integration/homeassistant/src/openaliro_ha/serial_transport.py:119

Initialize a serial connection wrapper around an open pyserial port object.

FPySerialConnection.readline(self) -> bytes

integration/homeassistant/src/openaliro_ha/serial_transport.py:124

Wait for a line without blocking the caller's asyncio event loop.

FPySerialConnection.write(self, data: bytes) -> None

integration/homeassistant/src/openaliro_ha/serial_transport.py:136

Write a bounded command without blocking the asyncio event loop.

FPySerialConnection.close(self) -> None

integration/homeassistant/src/openaliro_ha/serial_transport.py:146

Release the serial port and unblock any pending read.

calls SerialTransportError

Fopen_serial_connection(serial_port: str, baud: int, *, serial_factory: Optional[Callable[..., Any]]=None) -> PySerialConnection

integration/homeassistant/src/openaliro_ha/serial_transport.py:158

Open one serial port with finite read and write timeouts.

calls PySerialConnection, SerialTransportError, _import_serial