mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Do not rely on pyserial for port scanning with the CM5 + ZHA (#137585)
Do not rely on pyserial for port scanning with the CM5
This commit is contained in:
parent
aa6fa3cdad
commit
b3205ea1cd
@ -113,9 +113,14 @@ async def list_serial_ports(hass: HomeAssistant) -> list[ListPortInfo]:
|
||||
except HomeAssistantError:
|
||||
pass
|
||||
else:
|
||||
yellow_radio = next(p for p in ports if p.device == "/dev/ttyAMA1")
|
||||
yellow_radio.description = "Yellow Zigbee module"
|
||||
yellow_radio.manufacturer = "Nabu Casa"
|
||||
# PySerial does not properly handle the Yellow's serial port with the CM5
|
||||
# so we manually include it
|
||||
port = ListPortInfo(device="/dev/ttyAMA1", skip_link_detection=True)
|
||||
port.description = "Yellow Zigbee module"
|
||||
port.manufacturer = "Nabu Casa"
|
||||
|
||||
ports = [p for p in ports if not p.device.startswith("/dev/ttyAMA")]
|
||||
ports.insert(0, port)
|
||||
|
||||
if is_hassio(hass):
|
||||
# Present the multi-PAN addon as a setup option, if it's available
|
||||
|
@ -1914,9 +1914,18 @@ async def test_options_flow_migration_reset_old_adapter(
|
||||
assert result4["step_id"] == "choose_serial_port"
|
||||
|
||||
|
||||
async def test_config_flow_port_yellow_port_name(hass: HomeAssistant) -> None:
|
||||
@pytest.mark.parametrize(
|
||||
"device",
|
||||
[
|
||||
"/dev/ttyAMA1", # CM4
|
||||
"/dev/ttyAMA10", # CM5, erroneously detected by pyserial
|
||||
],
|
||||
)
|
||||
async def test_config_flow_port_yellow_port_name(
|
||||
hass: HomeAssistant, device: str
|
||||
) -> None:
|
||||
"""Test config flow serial port name for Yellow Zigbee radio."""
|
||||
port = com_port(device="/dev/ttyAMA1")
|
||||
port = com_port(device=device)
|
||||
port.serial_number = None
|
||||
port.manufacturer = None
|
||||
port.description = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user