Skip to content

Commit 3ad4419

Browse files
committed
Fix platform warnings (#22551)
1 parent f9f100b commit 3ad4419

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

homeassistant/loader.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
PACKAGE_CUSTOM_COMPONENTS = 'custom_components'
3838
PACKAGE_BUILTIN = 'homeassistant.components'
3939
LOOKUP_PATHS = [PACKAGE_CUSTOM_COMPONENTS, PACKAGE_BUILTIN]
40+
COMPONENTS_WITH_BAD_PLATFORMS = ['automation', 'mqtt', 'telegram_bot']
4041

4142

4243
class LoaderError(Exception):
@@ -83,7 +84,7 @@ def get_platform(hass, # type: HomeAssistant
8384
"""
8485
# If the platform has a component, we will limit the platform loading path
8586
# to be the same source (custom/built-in).
86-
if domain not in ['automation', 'mqtt', 'telegram_bot']:
87+
if domain not in COMPONENTS_WITH_BAD_PLATFORMS:
8788
component = _load_file(hass, platform_name, LOOKUP_PATHS)
8889
else:
8990
# avoid load component for legacy platform
@@ -104,7 +105,7 @@ def get_platform(hass, # type: HomeAssistant
104105
return platform
105106

106107
# Legacy platform check for automation: components/automation/event.py
107-
if component is None and domain in ['automation', 'mqtt', 'telegram_bot']:
108+
if component is None and domain in COMPONENTS_WITH_BAD_PLATFORMS:
108109
platform = _load_file(
109110
hass,
110111
PLATFORM_FORMAT.format(domain=platform_name, platform=domain),
@@ -129,10 +130,11 @@ def get_platform(hass, # type: HomeAssistant
129130
_LOGGER.error("Unable to find platform %s.%s", platform_name, extra)
130131
return None
131132

132-
_LOGGER.error(
133-
"Integrations need to be in their own folder. Change %s/%s.py to "
134-
"%s/%s.py. This will stop working soon.",
135-
domain, platform_name, platform_name, domain)
133+
if domain not in COMPONENTS_WITH_BAD_PLATFORMS:
134+
_LOGGER.error(
135+
"Integrations need to be in their own folder. Change %s/%s.py to "
136+
"%s/%s.py. This will stop working soon.",
137+
domain, platform_name, platform_name, domain)
136138

137139
return platform
138140

0 commit comments

Comments
 (0)