mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Add more Z-Wave USB discovery (#142460)
This commit is contained in:
parent
cb07e64b47
commit
dacc4c230d
@ -420,7 +420,10 @@ class ZWaveJSConfigFlow(BaseZwaveJSFlow, ConfigFlow, domain=DOMAIN):
|
|||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
dev_path = discovery_info.device
|
dev_path = discovery_info.device
|
||||||
self.usb_path = dev_path
|
self.usb_path = dev_path
|
||||||
self._title = usb.human_readable_device_name(
|
if manufacturer == "Nabu Casa" and description == "ZWA-2 - Nabu Casa ZWA-2":
|
||||||
|
title = "Home Assistant Connect ZWA-2"
|
||||||
|
else:
|
||||||
|
human_name = usb.human_readable_device_name(
|
||||||
dev_path,
|
dev_path,
|
||||||
serial_number,
|
serial_number,
|
||||||
manufacturer,
|
manufacturer,
|
||||||
@ -428,9 +431,9 @@ class ZWaveJSConfigFlow(BaseZwaveJSFlow, ConfigFlow, domain=DOMAIN):
|
|||||||
vid,
|
vid,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
self.context["title_placeholders"] = {
|
title = human_name.split(" - ")[0].strip()
|
||||||
CONF_NAME: self._title.split(" - ")[0].strip()
|
self.context["title_placeholders"] = {CONF_NAME: title}
|
||||||
}
|
self._title = title
|
||||||
return await self.async_step_usb_confirm()
|
return await self.async_step_usb_confirm()
|
||||||
|
|
||||||
async def async_step_usb_confirm(
|
async def async_step_usb_confirm(
|
||||||
|
@ -21,6 +21,13 @@
|
|||||||
"pid": "8A2A",
|
"pid": "8A2A",
|
||||||
"description": "*z-wave*",
|
"description": "*z-wave*",
|
||||||
"known_devices": ["Nortek HUSBZB-1"]
|
"known_devices": ["Nortek HUSBZB-1"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"vid": "303A",
|
||||||
|
"pid": "4001",
|
||||||
|
"description": "*nabu casa zwa-2*",
|
||||||
|
"manufacturer": "nabu casa",
|
||||||
|
"known_devices": ["Nabu Casa Connect ZWA-2"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"zeroconf": ["_zwave-js-server._tcp.local."]
|
"zeroconf": ["_zwave-js-server._tcp.local."]
|
||||||
|
7
homeassistant/generated/usb.py
generated
7
homeassistant/generated/usb.py
generated
@ -148,4 +148,11 @@ USB = [
|
|||||||
"pid": "8A2A",
|
"pid": "8A2A",
|
||||||
"vid": "10C4",
|
"vid": "10C4",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "*nabu casa zwa-2*",
|
||||||
|
"domain": "zwave_js",
|
||||||
|
"manufacturer": "nabu casa",
|
||||||
|
"pid": "4001",
|
||||||
|
"vid": "303A",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
@ -556,6 +556,28 @@ async def test_abort_hassio_discovery_for_other_addon(
|
|||||||
assert result2["reason"] == "not_zwave_js_addon"
|
assert result2["reason"] == "not_zwave_js_addon"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("usb_discovery_info", "device", "discovery_name"),
|
||||||
|
[
|
||||||
|
(
|
||||||
|
USB_DISCOVERY_INFO,
|
||||||
|
USB_DISCOVERY_INFO.device,
|
||||||
|
"zwave radio",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
UsbServiceInfo(
|
||||||
|
device="/dev/zwa2",
|
||||||
|
pid="303A",
|
||||||
|
vid="4001",
|
||||||
|
serial_number="1234",
|
||||||
|
description="ZWA-2 - Nabu Casa ZWA-2",
|
||||||
|
manufacturer="Nabu Casa",
|
||||||
|
),
|
||||||
|
"/dev/zwa2",
|
||||||
|
"Home Assistant Connect ZWA-2",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"discovery_info",
|
"discovery_info",
|
||||||
[
|
[
|
||||||
@ -578,15 +600,19 @@ async def test_usb_discovery(
|
|||||||
get_addon_discovery_info,
|
get_addon_discovery_info,
|
||||||
set_addon_options,
|
set_addon_options,
|
||||||
start_addon,
|
start_addon,
|
||||||
|
usb_discovery_info: UsbServiceInfo,
|
||||||
|
device: str,
|
||||||
|
discovery_name: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test usb discovery success path."""
|
"""Test usb discovery success path."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USB},
|
context={"source": config_entries.SOURCE_USB},
|
||||||
data=USB_DISCOVERY_INFO,
|
data=usb_discovery_info,
|
||||||
)
|
)
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "usb_confirm"
|
assert result["step_id"] == "usb_confirm"
|
||||||
|
assert result["description_placeholders"] == {"name": discovery_name}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
|
|
||||||
@ -619,7 +645,7 @@ async def test_usb_discovery(
|
|||||||
"core_zwave_js",
|
"core_zwave_js",
|
||||||
AddonsOptions(
|
AddonsOptions(
|
||||||
config={
|
config={
|
||||||
"device": USB_DISCOVERY_INFO.device,
|
"device": device,
|
||||||
"s0_legacy_key": "new123",
|
"s0_legacy_key": "new123",
|
||||||
"s2_access_control_key": "new456",
|
"s2_access_control_key": "new456",
|
||||||
"s2_authenticated_key": "new789",
|
"s2_authenticated_key": "new789",
|
||||||
@ -652,7 +678,7 @@ async def test_usb_discovery(
|
|||||||
assert result["title"] == TITLE
|
assert result["title"] == TITLE
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://host1:3001",
|
"url": "ws://host1:3001",
|
||||||
"usb_path": USB_DISCOVERY_INFO.device,
|
"usb_path": device,
|
||||||
"s0_legacy_key": "new123",
|
"s0_legacy_key": "new123",
|
||||||
"s2_access_control_key": "new456",
|
"s2_access_control_key": "new456",
|
||||||
"s2_authenticated_key": "new789",
|
"s2_authenticated_key": "new789",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user