mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 02:03:27 +01:00
Allow ignored medcom_ble devices to be set up from the user flow (#155622)
This commit is contained in:
@@ -93,7 +93,7 @@ class InspectorBLEConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
self._discovery_info = self._discovered_devices[address]
|
||||
return await self.async_step_check_connection()
|
||||
|
||||
current_addresses = self._async_current_ids()
|
||||
current_addresses = self._async_current_ids(include_ignore=False)
|
||||
for discovery_info in async_discovered_service_info(self.hass):
|
||||
address = discovery_info.address
|
||||
if address in current_addresses or address in self._discovered_devices:
|
||||
|
||||
@@ -7,6 +7,7 @@ from medcom_ble import MedcomBleDevice
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.medcom_ble.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IGNORE
|
||||
from homeassistant.const import CONF_ADDRESS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@@ -226,3 +227,51 @@ async def test_user_setup_unable_to_connect(hass: HomeAssistant) -> None:
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_user_setup_replaces_ignored_device(hass: HomeAssistant) -> None:
|
||||
"""Test the user initiated form can replace an ignored device."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id="a0:d9:5a:57:0b:00",
|
||||
source=SOURCE_IGNORE,
|
||||
data={},
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.medcom_ble.config_flow.async_discovered_service_info",
|
||||
return_value=[MEDCOM_SERVICE_INFO],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# Verify the ignored device is in the dropdown
|
||||
assert "a0:d9:5a:57:0b:00" in result["data_schema"].schema[CONF_ADDRESS].container
|
||||
|
||||
with (
|
||||
patch_async_ble_device_from_address(MEDCOM_SERVICE_INFO),
|
||||
patch_medcom_ble(
|
||||
MedcomBleDevice(
|
||||
manufacturer="International Medcom",
|
||||
model="Inspector BLE",
|
||||
model_raw="Inspector-BLE",
|
||||
name="Inspector BLE",
|
||||
identifier="a0d95a570b00",
|
||||
)
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.medcom_ble.async_setup_entry",
|
||||
return_value=True,
|
||||
),
|
||||
):
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={CONF_ADDRESS: "a0:d9:5a:57:0b:00"}
|
||||
)
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "InspectorBLE-D9A0"
|
||||
assert result2["data"] == {}
|
||||
assert result2["result"].unique_id == "a0:d9:5a:57:0b:00"
|
||||
|
||||
Reference in New Issue
Block a user