mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Fix platform warnings (#22551)
This commit is contained in:
parent
f9f100b575
commit
3ad4419cb6
@ -37,6 +37,7 @@ DATA_KEY = 'components'
|
|||||||
PACKAGE_CUSTOM_COMPONENTS = 'custom_components'
|
PACKAGE_CUSTOM_COMPONENTS = 'custom_components'
|
||||||
PACKAGE_BUILTIN = 'homeassistant.components'
|
PACKAGE_BUILTIN = 'homeassistant.components'
|
||||||
LOOKUP_PATHS = [PACKAGE_CUSTOM_COMPONENTS, PACKAGE_BUILTIN]
|
LOOKUP_PATHS = [PACKAGE_CUSTOM_COMPONENTS, PACKAGE_BUILTIN]
|
||||||
|
COMPONENTS_WITH_BAD_PLATFORMS = ['automation', 'mqtt', 'telegram_bot']
|
||||||
|
|
||||||
|
|
||||||
class LoaderError(Exception):
|
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
|
# If the platform has a component, we will limit the platform loading path
|
||||||
# to be the same source (custom/built-in).
|
# 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)
|
component = _load_file(hass, platform_name, LOOKUP_PATHS)
|
||||||
else:
|
else:
|
||||||
# avoid load component for legacy platform
|
# avoid load component for legacy platform
|
||||||
@ -104,7 +105,7 @@ def get_platform(hass, # type: HomeAssistant
|
|||||||
return platform
|
return platform
|
||||||
|
|
||||||
# Legacy platform check for automation: components/automation/event.py
|
# 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(
|
platform = _load_file(
|
||||||
hass,
|
hass,
|
||||||
PLATFORM_FORMAT.format(domain=platform_name, platform=domain),
|
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)
|
_LOGGER.error("Unable to find platform %s.%s", platform_name, extra)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
_LOGGER.error(
|
if domain not in COMPONENTS_WITH_BAD_PLATFORMS:
|
||||||
"Integrations need to be in their own folder. Change %s/%s.py to "
|
_LOGGER.error(
|
||||||
"%s/%s.py. This will stop working soon.",
|
"Integrations need to be in their own folder. Change %s/%s.py to "
|
||||||
domain, platform_name, platform_name, domain)
|
"%s/%s.py. This will stop working soon.",
|
||||||
|
domain, platform_name, platform_name, domain)
|
||||||
|
|
||||||
return platform
|
return platform
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user