mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Fix notify discovery setup (#68451)
* Fix notify discovery setup * add test * unsubscribe at reset * Add guard * move dispatcher to reload module * only unsubscribe if platform was setup * initialize dispatcher once and tests * test get_service too * add tests * fix test * use get_service for test invalid platform * Test built-in reload method * set to None after clearing dispatcher - tests * Pathing services file * Update tests/components/notify/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * dispatcher is not set twice if integration loaded * empty discovery payload * Removed not needed services.yaml mock * Update tests/components/notify/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * flake8 Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
@@ -21,6 +21,8 @@ from .typing import ConfigType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM_RESET_LOCK = "lock_async_reset_platform_{}"
|
||||
|
||||
|
||||
async def async_reload_integration_platforms(
|
||||
hass: HomeAssistant, integration_name: str, integration_platforms: Iterable[str]
|
||||
@@ -79,8 +81,11 @@ async def _resetup_platform(
|
||||
if hasattr(component, "async_reset_platform"):
|
||||
# If the integration has its own way to reset
|
||||
# use this method.
|
||||
await component.async_reset_platform(hass, integration_name)
|
||||
await component.async_setup(hass, root_config)
|
||||
async with hass.data.setdefault(
|
||||
PLATFORM_RESET_LOCK.format(integration_platform), asyncio.Lock()
|
||||
):
|
||||
await component.async_reset_platform(hass, integration_name)
|
||||
await component.async_setup(hass, root_config)
|
||||
return
|
||||
|
||||
# If it's an entity platform, we use the entity_platform
|
||||
|
||||
Reference in New Issue
Block a user