mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Fix exception during rediscovery of ignored zha config entries (#55859)
Fixes #55709
This commit is contained in:
parent
0533a9c714
commit
eba9b61011
@ -108,7 +108,7 @@ class ZhaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self._abort_if_unique_id_configured(
|
self._abort_if_unique_id_configured(
|
||||||
updates={
|
updates={
|
||||||
CONF_DEVICE: {
|
CONF_DEVICE: {
|
||||||
**current_entry.data[CONF_DEVICE],
|
**current_entry.data.get(CONF_DEVICE, {}),
|
||||||
CONF_DEVICE_PATH: dev_path,
|
CONF_DEVICE_PATH: dev_path,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ class ZhaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self._abort_if_unique_id_configured(
|
self._abort_if_unique_id_configured(
|
||||||
updates={
|
updates={
|
||||||
CONF_DEVICE: {
|
CONF_DEVICE: {
|
||||||
**current_entry.data[CONF_DEVICE],
|
**current_entry.data.get(CONF_DEVICE, {}),
|
||||||
CONF_DEVICE_PATH: device_path,
|
CONF_DEVICE_PATH: device_path,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,34 @@ async def test_discovery_via_zeroconf_ip_change(detect_mock, hass):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@patch("homeassistant.components.zha.async_setup_entry", AsyncMock(return_value=True))
|
||||||
|
@patch("zigpy_znp.zigbee.application.ControllerApplication.probe", return_value=True)
|
||||||
|
async def test_discovery_via_zeroconf_ip_change_ignored(detect_mock, hass):
|
||||||
|
"""Test zeroconf flow that was ignored gets updated."""
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
unique_id="tube_zb_gw_cc2652p2_poe",
|
||||||
|
source=config_entries.SOURCE_IGNORE,
|
||||||
|
)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
service_info = {
|
||||||
|
"host": "192.168.1.22",
|
||||||
|
"port": 6053,
|
||||||
|
"hostname": "tube_zb_gw_cc2652p2_poe.local.",
|
||||||
|
"properties": {"address": "tube_zb_gw_cc2652p2_poe.local"},
|
||||||
|
}
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
"zha", context={"source": SOURCE_ZEROCONF}, data=service_info
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result["type"] == RESULT_TYPE_ABORT
|
||||||
|
assert result["reason"] == "already_configured"
|
||||||
|
assert entry.data[CONF_DEVICE] == {
|
||||||
|
CONF_DEVICE_PATH: "socket://192.168.1.22:6638",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@patch("zigpy_znp.zigbee.application.ControllerApplication.probe", return_value=True)
|
@patch("zigpy_znp.zigbee.application.ControllerApplication.probe", return_value=True)
|
||||||
async def test_discovery_via_usb(detect_mock, hass):
|
async def test_discovery_via_usb(detect_mock, hass):
|
||||||
"""Test usb flow -- radio detected."""
|
"""Test usb flow -- radio detected."""
|
||||||
@ -317,6 +345,37 @@ async def test_discovery_via_usb_deconz_ignored(detect_mock, hass):
|
|||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
|
||||||
|
|
||||||
|
@patch("zigpy_znp.zigbee.application.ControllerApplication.probe", return_value=True)
|
||||||
|
async def test_discovery_via_usb_zha_ignored_updates(detect_mock, hass):
|
||||||
|
"""Test usb flow that was ignored gets updated."""
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
source=config_entries.SOURCE_IGNORE,
|
||||||
|
data={},
|
||||||
|
unique_id="AAAA:AAAA_1234_test_zigbee radio",
|
||||||
|
)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
discovery_info = {
|
||||||
|
"device": "/dev/ttyZIGBEE",
|
||||||
|
"pid": "AAAA",
|
||||||
|
"vid": "AAAA",
|
||||||
|
"serial_number": "1234",
|
||||||
|
"description": "zigbee radio",
|
||||||
|
"manufacturer": "test",
|
||||||
|
}
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
"zha", context={"source": SOURCE_USB}, data=discovery_info
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert result["type"] == RESULT_TYPE_ABORT
|
||||||
|
assert result["reason"] == "already_configured"
|
||||||
|
assert entry.data[CONF_DEVICE] == {
|
||||||
|
CONF_DEVICE_PATH: "/dev/ttyZIGBEE",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@patch("homeassistant.components.zha.async_setup_entry", AsyncMock(return_value=True))
|
@patch("homeassistant.components.zha.async_setup_entry", AsyncMock(return_value=True))
|
||||||
@patch("zigpy_znp.zigbee.application.ControllerApplication.probe", return_value=True)
|
@patch("zigpy_znp.zigbee.application.ControllerApplication.probe", return_value=True)
|
||||||
async def test_discovery_already_setup(detect_mock, hass):
|
async def test_discovery_already_setup(detect_mock, hass):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user