mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Explicitely allow Platform enum in config_entries (#63581)
* Explicitely allow Platform enum in config_entries * Undo argument name change and conversion to string Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
665eeb4b27
commit
34a967c48a
@ -14,7 +14,7 @@ import weakref
|
|||||||
|
|
||||||
from . import data_entry_flow, loader
|
from . import data_entry_flow, loader
|
||||||
from .backports.enum import StrEnum
|
from .backports.enum import StrEnum
|
||||||
from .const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP
|
from .const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP, Platform
|
||||||
from .core import CALLBACK_TYPE, CoreState, Event, HomeAssistant, callback
|
from .core import CALLBACK_TYPE, CoreState, Event, HomeAssistant, callback
|
||||||
from .exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady, HomeAssistantError
|
from .exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady, HomeAssistantError
|
||||||
from .helpers import device_registry, entity_registry
|
from .helpers import device_registry, entity_registry
|
||||||
@ -1100,13 +1100,15 @@ class ConfigEntries:
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_setup_platforms(
|
def async_setup_platforms(
|
||||||
self, entry: ConfigEntry, platforms: Iterable[str]
|
self, entry: ConfigEntry, platforms: Iterable[Platform | str]
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Forward the setup of an entry to platforms."""
|
"""Forward the setup of an entry to platforms."""
|
||||||
for platform in platforms:
|
for platform in platforms:
|
||||||
self.hass.async_create_task(self.async_forward_entry_setup(entry, platform))
|
self.hass.async_create_task(self.async_forward_entry_setup(entry, platform))
|
||||||
|
|
||||||
async def async_forward_entry_setup(self, entry: ConfigEntry, domain: str) -> bool:
|
async def async_forward_entry_setup(
|
||||||
|
self, entry: ConfigEntry, domain: Platform | str
|
||||||
|
) -> bool:
|
||||||
"""Forward the setup of an entry to a different component.
|
"""Forward the setup of an entry to a different component.
|
||||||
|
|
||||||
By default an entry is setup with the component it belongs to. If that
|
By default an entry is setup with the component it belongs to. If that
|
||||||
@ -1129,7 +1131,7 @@ class ConfigEntries:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
async def async_unload_platforms(
|
async def async_unload_platforms(
|
||||||
self, entry: ConfigEntry, platforms: Iterable[str]
|
self, entry: ConfigEntry, platforms: Iterable[Platform | str]
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Forward the unloading of an entry to platforms."""
|
"""Forward the unloading of an entry to platforms."""
|
||||||
return all(
|
return all(
|
||||||
@ -1141,7 +1143,9 @@ class ConfigEntries:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_forward_entry_unload(self, entry: ConfigEntry, domain: str) -> bool:
|
async def async_forward_entry_unload(
|
||||||
|
self, entry: ConfigEntry, domain: Platform | str
|
||||||
|
) -> bool:
|
||||||
"""Forward the unloading of an entry to a different component."""
|
"""Forward the unloading of an entry to a different component."""
|
||||||
# It was never loaded.
|
# It was never loaded.
|
||||||
if domain not in self.hass.config.components:
|
if domain not in self.hass.config.components:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user