Skip to content

Commit afd2763

Browse files
authored
Allow configuring ignored Kuler Sky devices (home-assistant#155634)
1 parent cad1f1d commit afd2763

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

homeassistant/components/kulersky/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def async_step_user(
106106
if discovery := self._discovery_info:
107107
self._discovered_devices[discovery.address] = discovery
108108
else:
109-
current_addresses = self._async_current_ids()
109+
current_addresses = self._async_current_ids(include_ignore=False)
110110
for discovery in async_discovered_service_info(self.hass):
111111
if (
112112
discovery.address in current_addresses

tests/components/kulersky/test_config_flow.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
from homeassistant.components.kulersky.config_flow import DOMAIN
99
from homeassistant.config_entries import (
1010
SOURCE_BLUETOOTH,
11+
SOURCE_IGNORE,
1112
SOURCE_INTEGRATION_DISCOVERY,
1213
SOURCE_USER,
1314
)
1415
from homeassistant.const import CONF_ADDRESS
1516
from homeassistant.core import HomeAssistant
1617
from homeassistant.data_entry_flow import FlowResultType
1718

19+
from tests.common import MockConfigEntry
1820
from tests.components.bluetooth import generate_advertisement_data, generate_ble_device
1921

2022
KULERSKY_SERVICE_INFO = BluetoothServiceInfoBleak(
@@ -180,3 +182,44 @@ async def test_unexpected_error(hass: HomeAssistant) -> None:
180182

181183
assert result["type"] is FlowResultType.FORM
182184
assert result["errors"]["base"] == "unknown"
185+
186+
187+
async def test_user_setup_replaces_ignored_device(hass: HomeAssistant) -> None:
188+
"""Test the user flow can replace an ignored device."""
189+
entry = MockConfigEntry(
190+
domain=DOMAIN,
191+
unique_id="AA:BB:CC:DD:EE:FF",
192+
source=SOURCE_IGNORE,
193+
data={},
194+
)
195+
entry.add_to_hass(hass)
196+
197+
with patch(
198+
"homeassistant.components.kulersky.config_flow.async_discovered_service_info",
199+
return_value=[KULERSKY_SERVICE_INFO],
200+
):
201+
result = await hass.config_entries.flow.async_init(
202+
DOMAIN,
203+
context={"source": SOURCE_USER},
204+
)
205+
await hass.async_block_till_done()
206+
207+
assert result["type"] is FlowResultType.FORM
208+
assert result["step_id"] == "user"
209+
210+
# Verify the ignored device is in the dropdown
211+
assert "AA:BB:CC:DD:EE:FF" in result["data_schema"].schema[CONF_ADDRESS].container
212+
213+
with patch("pykulersky.Light", Mock(return_value=AsyncMock())):
214+
result2 = await hass.config_entries.flow.async_configure(
215+
result["flow_id"],
216+
{CONF_ADDRESS: "AA:BB:CC:DD:EE:FF"},
217+
)
218+
await hass.async_block_till_done()
219+
220+
assert result2["type"] is FlowResultType.CREATE_ENTRY
221+
assert result2["title"] == "KulerLight (EEFF)"
222+
assert result2["data"] == {
223+
CONF_ADDRESS: "AA:BB:CC:DD:EE:FF",
224+
}
225+
assert result2["result"].unique_id == "AA:BB:CC:DD:EE:FF"

0 commit comments

Comments
 (0)