Skip to content

Commit

Permalink
Add workaround for old core versions to `HacsBase.async_recreate_enti…
Browse files Browse the repository at this point in the history
…ties` (#3844)

Add workaround for old core versions to async_recreate_entities
  • Loading branch information
emontnemery authored Jul 1, 2024
1 parent 8f1d5ce commit ffea28f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions custom_components/hacs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,22 @@ async def async_recreate_entities(self) -> None:
"""Recreate entities."""
platforms = [Platform.UPDATE]

await self.hass.config_entries.async_unload_platforms(
entry=self.configuration.config_entry,
platforms=platforms,
)
# Workaround for core versions without https://github.com/home-assistant/core/pull/117084
if self.core.ha_version < AwesomeVersion("2024.6.0"):
unload_platforms_lock = asyncio.Lock()
async with unload_platforms_lock:
on_unload = self.configuration.config_entry._on_unload
self.configuration.config_entry._on_unload = []
await self.hass.config_entries.async_unload_platforms(
entry=self.configuration.config_entry,
platforms=platforms,
)
self.configuration.config_entry._on_unload = on_unload
else:
await self.hass.config_entries.async_unload_platforms(
entry=self.configuration.config_entry,
platforms=platforms,
)
await self.hass.config_entries.async_forward_entry_setups(
self.configuration.config_entry, platforms
)
Expand Down

0 comments on commit ffea28f

Please sign in to comment.