Skip to content

Commit 52f7105

Browse files
bdracoballoob
andcommitted
Handle race condition in harmony setup (#33611)
* Handle race condition in harmony setup If the remote was discovered via ssdp before the yaml config import happened, the unique id would already be set and the import would abort. * Update homeassistant/components/harmony/config_flow.py Co-Authored-By: Paulus Schoutsen <[email protected]> * reduce * black Co-authored-by: Paulus Schoutsen <[email protected]>
1 parent 38b729b commit 52f7105

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

homeassistant/components/harmony/config_flow.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,11 @@ async def async_step_link(self, user_input=None):
128128

129129
async def async_step_import(self, validated_input):
130130
"""Handle import."""
131-
await self.async_set_unique_id(validated_input[UNIQUE_ID])
131+
await self.async_set_unique_id(
132+
validated_input[UNIQUE_ID], raise_on_progress=False
133+
)
132134
self._abort_if_unique_id_configured()
135+
133136
# Everything was validated in remote async_setup_platform
134137
# all we do now is create.
135138
return await self._async_create_entry_from_valid_input(
@@ -149,14 +152,8 @@ async def _async_create_entry_from_valid_input(self, validated, user_input):
149152
# Options from yaml are preserved, we will pull them out when
150153
# we setup the config entry
151154
data.update(_options_from_user_input(user_input))
152-
return self.async_create_entry(title=validated[CONF_NAME], data=data)
153155

154-
def _host_already_configured(self, user_input):
155-
"""See if we already have a harmony matching user input configured."""
156-
existing_hosts = {
157-
entry.data[CONF_HOST] for entry in self._async_current_entries()
158-
}
159-
return user_input[CONF_HOST] in existing_hosts
156+
return self.async_create_entry(title=validated[CONF_NAME], data=data)
160157

161158

162159
def _options_from_user_input(user_input):

0 commit comments

Comments
 (0)