Skip to content

Commit 636b7d2

Browse files
committed
fix still flaky test
1 parent b39d3d7 commit 636b7d2

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

custom_components/bms_ble/config_flow.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ async def async_step_bluetooth_confirm(
115115
LOGGER.debug("confirm step for %s", self._disc_dev.name)
116116

117117
if user_input is not None:
118+
# Re-set unique_id to avoid race with newly added entries
119+
await self.async_set_unique_id(self._disc_dev.discovery_info.address)
118120
self._abort_if_unique_id_configured()
121+
119122
return self.async_create_entry(
120123
title=self._disc_dev.name,
121124
data={"type": self._disc_dev.type},

tests/test_config_flow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ async def test_bluetooth_confirm_entry_added_during_flow(
278278
# Simulate another flow/user creating the entry before confirmation
279279
cfg: MockConfigEntry = mock_config()
280280
cfg.add_to_hass(hass)
281+
await hass.config_entries.async_setup(cfg.entry_id)
281282
await hass.async_block_till_done()
282283

283284
# Now try to confirm - should abort instead of creating entry

0 commit comments

Comments
 (0)