Fix broken platform components (#22943)
* Fix broken platform components * Lint
This commit is contained in:
parent
8582e390f8
commit
e48ef7f441
8 changed files with 30 additions and 51 deletions
|
@ -49,7 +49,6 @@ DATA_INTEGRATIONS = 'integrations'
|
|||
PACKAGE_CUSTOM_COMPONENTS = 'custom_components'
|
||||
PACKAGE_BUILTIN = 'homeassistant.components'
|
||||
LOOKUP_PATHS = [PACKAGE_CUSTOM_COMPONENTS, PACKAGE_BUILTIN]
|
||||
COMPONENTS_WITH_BAD_PLATFORMS = ['automation', 'mqtt', 'telegram_bot']
|
||||
_UNDEF = object()
|
||||
|
||||
|
||||
|
@ -224,11 +223,7 @@ def get_platform(hass, # type: HomeAssistant
|
|||
"""
|
||||
# If the platform has a component, we will limit the platform loading path
|
||||
# to be the same source (custom/built-in).
|
||||
if domain not in COMPONENTS_WITH_BAD_PLATFORMS:
|
||||
component = _load_file(hass, platform_name, LOOKUP_PATHS)
|
||||
else:
|
||||
# avoid load component for legacy platform
|
||||
component = None
|
||||
component = _load_file(hass, platform_name, LOOKUP_PATHS)
|
||||
|
||||
# Until we have moved all platforms under their component/own folder, it
|
||||
# can be that the component is None.
|
||||
|
@ -244,14 +239,6 @@ def get_platform(hass, # type: HomeAssistant
|
|||
if platform is not None:
|
||||
return platform
|
||||
|
||||
# Legacy platform check for automation: components/automation/event.py
|
||||
if component is None and domain in COMPONENTS_WITH_BAD_PLATFORMS:
|
||||
platform = _load_file(
|
||||
hass,
|
||||
PLATFORM_FORMAT.format(domain=platform_name, platform=domain),
|
||||
base_paths
|
||||
)
|
||||
|
||||
# Legacy platform check for custom: custom_components/light/hue.py
|
||||
# Only check if the component was also in custom components.
|
||||
if component is None or base_paths[0] == PACKAGE_CUSTOM_COMPONENTS:
|
||||
|
@ -270,11 +257,10 @@ def get_platform(hass, # type: HomeAssistant
|
|||
_LOGGER.error("Unable to find platform %s.%s", platform_name, extra)
|
||||
return None
|
||||
|
||||
if domain not in COMPONENTS_WITH_BAD_PLATFORMS:
|
||||
_LOGGER.error(
|
||||
"Integrations need to be in their own folder. Change %s/%s.py to "
|
||||
"%s/%s.py. This will stop working soon.",
|
||||
domain, platform_name, platform_name, domain)
|
||||
_LOGGER.error(
|
||||
"Integrations need to be in their own folder. Change %s/%s.py to "
|
||||
"%s/%s.py. This will stop working soon.",
|
||||
domain, platform_name, platform_name, domain)
|
||||
|
||||
return platform
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue