37
37
PACKAGE_CUSTOM_COMPONENTS = 'custom_components'
38
38
PACKAGE_BUILTIN = 'homeassistant.components'
39
39
LOOKUP_PATHS = [PACKAGE_CUSTOM_COMPONENTS , PACKAGE_BUILTIN ]
40
+ COMPONENTS_WITH_BAD_PLATFORMS = ['automation' , 'mqtt' , 'telegram_bot' ]
40
41
41
42
42
43
class LoaderError (Exception ):
@@ -83,7 +84,7 @@ def get_platform(hass, # type: HomeAssistant
83
84
"""
84
85
# If the platform has a component, we will limit the platform loading path
85
86
# 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 :
87
88
component = _load_file (hass , platform_name , LOOKUP_PATHS )
88
89
else :
89
90
# avoid load component for legacy platform
@@ -104,7 +105,7 @@ def get_platform(hass, # type: HomeAssistant
104
105
return platform
105
106
106
107
# 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 :
108
109
platform = _load_file (
109
110
hass ,
110
111
PLATFORM_FORMAT .format (domain = platform_name , platform = domain ),
@@ -129,10 +130,11 @@ def get_platform(hass, # type: HomeAssistant
129
130
_LOGGER .error ("Unable to find platform %s.%s" , platform_name , extra )
130
131
return None
131
132
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 )
136
138
137
139
return platform
138
140
0 commit comments