Fix dev branch (#22493)

pull/22496/head
Jason Hu 2019-03-28 03:09:12 -07:00 committed by Pascal Vizeli
parent 4db224ceb5
commit 8d86722c0e
4 changed files with 16 additions and 5 deletions

View File

@ -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

View File

@ -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:

View File

@ -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)

View File

@ -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)