diff --git a/homeassistant/components/homekit_controller/__init__.py b/homeassistant/components/homekit_controller/__init__.py index f9fd0409c9c..44af8bffe26 100644 --- a/homeassistant/components/homekit_controller/__init__.py +++ b/homeassistant/components/homekit_controller/__init__.py @@ -1,6 +1,5 @@ """Support for Homekit device discovery.""" import logging -import os from homeassistant.components.discovery import SERVICE_HOMEKIT from homeassistant.helpers import discovery @@ -9,7 +8,7 @@ from homeassistant.helpers.entity import Entity from .config_flow import load_old_pairings from .connection import get_accessory_information, HKDevice from .const import ( - CONTROLLER, HOMEKIT_DIR, KNOWN_DEVICES, PAIRING_FILE + CONTROLLER, KNOWN_DEVICES ) from .const import DOMAIN # noqa: pylint: disable=unused-import diff --git a/homeassistant/loader.py b/homeassistant/loader.py index 7f0d50f93d4..8ccbcaa33c4 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -83,7 +83,11 @@ 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). - component = _load_file(hass, platform_name, LOOKUP_PATHS) + if domain not in ['automation', 'mqtt', 'telegram_bot']: + component = _load_file(hass, platform_name, LOOKUP_PATHS) + else: + # avoid load component for legacy platform + component = None # Until we have moved all platforms under their component/own folder, it # can be that the component is None. @@ -99,6 +103,14 @@ 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 ['automation', 'mqtt', 'telegram_bot']: + 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: diff --git a/tests/helpers/test_entity_component.py b/tests/helpers/test_entity_component.py index 163261a4b81..6da3293d597 100644 --- a/tests/helpers/test_entity_component.py +++ b/tests/helpers/test_entity_component.py @@ -324,7 +324,7 @@ def test_setup_dependencies_platform(hass): loader.set_component(hass, 'test_component2', MockModule('test_component2')) loader.set_component( - hass, 'test_domain.test_component', + hass, 'test_component.test_domain', MockPlatform(dependencies=['test_component', 'test_component2'])) component = EntityComponent(_LOGGER, DOMAIN, hass) diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index 324db971583..32532761ccf 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -192,7 +192,7 @@ async def test_remove_entry(hass, manager): async_remove_entry=mock_remove_entry )) loader.set_component( - hass, 'light.test', + hass, 'test.light', MockPlatform(async_setup_entry=mock_setup_entry_platform)) MockConfigEntry(domain='test', entry_id='test1').add_to_manager(manager)