1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Fix platform warnings (#22551)

This commit is contained in:
Paulus Schoutsen 2019-03-29 17:04:59 -07:00 committed by GitHub
parent c05bff7d17
commit cc886821bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,7 @@ DATA_KEY = 'components'
PACKAGE_CUSTOM_COMPONENTS = 'custom_components'
PACKAGE_BUILTIN = 'homeassistant.components'
LOOKUP_PATHS = [PACKAGE_CUSTOM_COMPONENTS, PACKAGE_BUILTIN]
COMPONENTS_WITH_BAD_PLATFORMS = ['automation', 'mqtt', 'telegram_bot']
class LoaderError(Exception):
@ -83,7 +84,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 ['automation', 'mqtt', 'telegram_bot']:
if domain not in COMPONENTS_WITH_BAD_PLATFORMS:
component = _load_file(hass, platform_name, LOOKUP_PATHS)
else:
# avoid load component for legacy platform
@ -104,7 +105,7 @@ def get_platform(hass, # type: HomeAssistant
return platform
# Legacy platform check for automation: components/automation/event.py
if component is None and domain in ['automation', 'mqtt', 'telegram_bot']:
if component is None and domain in COMPONENTS_WITH_BAD_PLATFORMS:
platform = _load_file(
hass,
PLATFORM_FORMAT.format(domain=platform_name, platform=domain),
@ -129,10 +130,11 @@ def get_platform(hass, # type: HomeAssistant
_LOGGER.error("Unable to find platform %s.%s", platform_name, extra)
return None
_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)
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)
return platform