mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Remove the old ZWave controller from the list of migration targets (#145281)
* Remove the old ZWave controller from the list of migration targets * ensure addon device path is serial/by_id * Use executor --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
73811eac0a
commit
ba44986524
@ -1163,6 +1163,15 @@ class ZWaveJSConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
_LOGGER.error("Failed to get USB ports: %s", err)
|
_LOGGER.error("Failed to get USB ports: %s", err)
|
||||||
return self.async_abort(reason="usb_ports_failed")
|
return self.async_abort(reason="usb_ports_failed")
|
||||||
|
|
||||||
|
addon_info = await self._async_get_addon_info()
|
||||||
|
addon_config = addon_info.options
|
||||||
|
old_usb_path = addon_config.get(CONF_ADDON_DEVICE, "")
|
||||||
|
# Remove the old controller from the ports list.
|
||||||
|
ports.pop(
|
||||||
|
await self.hass.async_add_executor_job(usb.get_serial_by_id, old_usb_path),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
|
||||||
data_schema = vol.Schema(
|
data_schema = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_USB_PATH): vol.In(ports),
|
vol.Required(CONF_USB_PATH): vol.In(ports),
|
||||||
|
@ -13,6 +13,7 @@ from aiohasupervisor.models import AddonsOptions, Discovery
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import pytest
|
import pytest
|
||||||
from serial.tools.list_ports_common import ListPortInfo
|
from serial.tools.list_ports_common import ListPortInfo
|
||||||
|
from voluptuous import InInvalid
|
||||||
from zwave_js_server.exceptions import FailedCommand
|
from zwave_js_server.exceptions import FailedCommand
|
||||||
from zwave_js_server.version import VersionInfo
|
from zwave_js_server.version import VersionInfo
|
||||||
|
|
||||||
@ -3694,6 +3695,7 @@ async def test_reconfigure_migrate_with_addon(
|
|||||||
integration,
|
integration,
|
||||||
addon_running,
|
addon_running,
|
||||||
restart_addon,
|
restart_addon,
|
||||||
|
addon_options,
|
||||||
set_addon_options,
|
set_addon_options,
|
||||||
get_addon_discovery_info,
|
get_addon_discovery_info,
|
||||||
get_server_version: AsyncMock,
|
get_server_version: AsyncMock,
|
||||||
@ -3717,6 +3719,7 @@ async def test_reconfigure_migrate_with_addon(
|
|||||||
"usb_path": "/dev/ttyUSB0",
|
"usb_path": "/dev/ttyUSB0",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
addon_options["device"] = "/dev/ttyUSB0"
|
||||||
|
|
||||||
async def mock_backup_nvm_raw():
|
async def mock_backup_nvm_raw():
|
||||||
await asyncio.sleep(0)
|
await asyncio.sleep(0)
|
||||||
@ -3793,6 +3796,9 @@ async def test_reconfigure_migrate_with_addon(
|
|||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "choose_serial_port"
|
assert result["step_id"] == "choose_serial_port"
|
||||||
assert result["data_schema"].schema[CONF_USB_PATH]
|
assert result["data_schema"].schema[CONF_USB_PATH]
|
||||||
|
# Ensure the old usb path is not in the list of options
|
||||||
|
with pytest.raises(InInvalid):
|
||||||
|
result["data_schema"].schema[CONF_USB_PATH](addon_options["device"])
|
||||||
|
|
||||||
# Reset side effect before starting the add-on.
|
# Reset side effect before starting the add-on.
|
||||||
get_server_version.side_effect = None
|
get_server_version.side_effect = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user