Add unique ID to WLED config entries (#30480)
* Add unique ID to WLED config entries * Improve robustness of the tests
This commit is contained in:
1 parent
bf9418e51a
commit
51db9bdfce
4 files changed
+56
-40
No files matched your search
@@ -61,6 +61,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN][entry.entry_id] = {DATA_WLED_CLIENT: wled}
|
||||
|
||||
# For backwards compat, set unique ID
|
||||
if entry.unique_id is None:
|
||||
hass.config_entries.async_update_entry(
|
||||
entry, unique_id=wled.device.info.mac_address
|
||||
)
|
||||
|
||||
# Set up all platforms for this device/entry.
|
||||
for component in WLED_COMPONENTS:
|
||||
hass.async_create_task(
|
||||
|
||||
@@ -87,10 +87,8 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
# Check if already configured
|
||||
mac_address = device.info.mac_address
|
||||
for entry in self._async_current_entries():
|
||||
if entry.data[CONF_MAC] == mac_address:
|
||||
# This mac address is already configured
|
||||
return self.async_abort(reason="already_configured")
|
||||
await self.async_set_unique_id(device.info.mac_address)
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
title = user_input[CONF_HOST]
|
||||
if source == SOURCE_ZEROCONF:
|
||||
|
||||
Reference in new issue
Block a user