parent
bdf948d866
commit
2650c73a89
|
@ -7,7 +7,6 @@ import sys
|
|||
from time import time
|
||||
from collections import OrderedDict
|
||||
|
||||
from types import ModuleType
|
||||
from typing import Any, Optional, Dict
|
||||
|
||||
import voluptuous as vol
|
||||
|
@ -15,263 +14,23 @@ import voluptuous as vol
|
|||
import homeassistant.components as core_components
|
||||
from homeassistant.components import persistent_notification
|
||||
import homeassistant.config as conf_util
|
||||
from homeassistant.config import async_notify_setup_error
|
||||
import homeassistant.core as core
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.loader as loader
|
||||
import homeassistant.util.package as pkg_util
|
||||
from homeassistant.util.async import run_coroutine_threadsafe
|
||||
from homeassistant.util.logging import AsyncHandler
|
||||
from homeassistant.util.yaml import clear_secret_cache
|
||||
from homeassistant.const import EVENT_COMPONENT_LOADED, PLATFORM_FORMAT
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import event_decorators, service
|
||||
from homeassistant.helpers.signal import async_register_signal_handling
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_COMPONENT = 'component'
|
||||
|
||||
DATA_SETUP = 'setup_tasks'
|
||||
DATA_PIP_LOCK = 'pip_lock'
|
||||
|
||||
ERROR_LOG_FILENAME = 'home-assistant.log'
|
||||
|
||||
FIRST_INIT_COMPONENT = set((
|
||||
'recorder', 'mqtt', 'mqtt_eventstream', 'logger', 'introduction'))
|
||||
|
||||
|
||||
def setup_component(hass: core.HomeAssistant, domain: str,
|
||||
config: Optional[Dict]=None) -> bool:
|
||||
"""Setup a component and all its dependencies."""
|
||||
return run_coroutine_threadsafe(
|
||||
async_setup_component(hass, domain, config), loop=hass.loop).result()
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_component(hass: core.HomeAssistant, domain: str,
|
||||
config: Optional[Dict]=None) -> bool:
|
||||
"""Setup a component and all its dependencies.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
if domain in hass.config.components:
|
||||
return True
|
||||
|
||||
setup_tasks = hass.data.get(DATA_SETUP)
|
||||
|
||||
if setup_tasks is not None and domain in setup_tasks:
|
||||
return (yield from setup_tasks[domain])
|
||||
|
||||
if config is None:
|
||||
config = {}
|
||||
|
||||
if setup_tasks is None:
|
||||
setup_tasks = hass.data[DATA_SETUP] = {}
|
||||
|
||||
task = setup_tasks[domain] = hass.async_add_job(
|
||||
_async_setup_component(hass, domain, config))
|
||||
|
||||
return (yield from task)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def _async_process_requirements(hass: core.HomeAssistant, name: str,
|
||||
requirements) -> bool:
|
||||
"""Install the requirements for a component.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
if hass.config.skip_pip:
|
||||
return True
|
||||
|
||||
pip_lock = hass.data.get(DATA_PIP_LOCK)
|
||||
if pip_lock is None:
|
||||
pip_lock = hass.data[DATA_PIP_LOCK] = asyncio.Lock(loop=hass.loop)
|
||||
|
||||
def pip_install(mod):
|
||||
"""Install packages."""
|
||||
return pkg_util.install_package(mod, target=hass.config.path('deps'))
|
||||
|
||||
with (yield from pip_lock):
|
||||
for req in requirements:
|
||||
ret = yield from hass.loop.run_in_executor(None, pip_install, req)
|
||||
if not ret:
|
||||
_LOGGER.error('Not initializing %s because could not install '
|
||||
'dependency %s', name, req)
|
||||
async_notify_setup_error(hass, name)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def _async_process_dependencies(hass, config, name, dependencies):
|
||||
"""Ensure all dependencies are set up."""
|
||||
blacklisted = [dep for dep in dependencies
|
||||
if dep in loader.DEPENDENCY_BLACKLIST]
|
||||
|
||||
if blacklisted:
|
||||
_LOGGER.error('Unable to setup dependencies of %s: '
|
||||
'found blacklisted dependencies: %s',
|
||||
name, ', '.join(blacklisted))
|
||||
return False
|
||||
|
||||
tasks = [async_setup_component(hass, dep, config) for dep
|
||||
in dependencies]
|
||||
|
||||
if not tasks:
|
||||
return True
|
||||
|
||||
results = yield from asyncio.gather(*tasks, loop=hass.loop)
|
||||
|
||||
failed = [dependencies[idx] for idx, res
|
||||
in enumerate(results) if not res]
|
||||
|
||||
if failed:
|
||||
_LOGGER.error('Unable to setup dependencies of %s. '
|
||||
'Setup failed for dependencies: %s',
|
||||
name, ', '.join(failed))
|
||||
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def _async_setup_component(hass: core.HomeAssistant,
|
||||
domain: str, config) -> bool:
|
||||
"""Setup a component for Home Assistant.
|
||||
|
||||
This method is a coroutine.
|
||||
|
||||
hass: Home Assistant instance.
|
||||
domain: Domain of component to setup.
|
||||
config: The Home Assistant configuration.
|
||||
"""
|
||||
def log_error(msg, link=True):
|
||||
"""Log helper."""
|
||||
_LOGGER.error('Setup failed for %s: %s', domain, msg)
|
||||
async_notify_setup_error(hass, domain, link)
|
||||
|
||||
component = loader.get_component(domain)
|
||||
|
||||
if not component:
|
||||
log_error('Component not found.', False)
|
||||
return False
|
||||
|
||||
# Validate no circular dependencies
|
||||
components = loader.load_order_component(domain)
|
||||
|
||||
# OrderedSet is empty if component or dependencies could not be resolved
|
||||
if not components:
|
||||
log_error('Unable to resolve component or dependencies.')
|
||||
return False
|
||||
|
||||
processed_config = \
|
||||
conf_util.async_process_component_config(hass, config, domain)
|
||||
|
||||
if processed_config is None:
|
||||
log_error('Invalid config.')
|
||||
return False
|
||||
|
||||
if not hass.config.skip_pip and hasattr(component, 'REQUIREMENTS'):
|
||||
req_success = yield from _async_process_requirements(
|
||||
hass, domain, component.REQUIREMENTS)
|
||||
if not req_success:
|
||||
log_error('Could not install all requirements.')
|
||||
return False
|
||||
|
||||
if hasattr(component, 'DEPENDENCIES'):
|
||||
dep_success = yield from _async_process_dependencies(
|
||||
hass, config, domain, component.DEPENDENCIES)
|
||||
|
||||
if not dep_success:
|
||||
log_error('Could not setup all dependencies.')
|
||||
return False
|
||||
|
||||
async_comp = hasattr(component, 'async_setup')
|
||||
|
||||
try:
|
||||
_LOGGER.info("Setting up %s", domain)
|
||||
if async_comp:
|
||||
result = yield from component.async_setup(hass, processed_config)
|
||||
else:
|
||||
result = yield from hass.loop.run_in_executor(
|
||||
None, component.setup, hass, processed_config)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
_LOGGER.exception('Error during setup of component %s', domain)
|
||||
async_notify_setup_error(hass, domain, True)
|
||||
return False
|
||||
|
||||
if result is False:
|
||||
log_error('Component failed to initialize.')
|
||||
return False
|
||||
elif result is not True:
|
||||
log_error('Component did not return boolean if setup was successful. '
|
||||
'Disabling component.')
|
||||
loader.set_component(domain, None)
|
||||
return False
|
||||
|
||||
hass.config.components.add(component.DOMAIN)
|
||||
|
||||
# cleanup
|
||||
if domain in hass.data[DATA_SETUP]:
|
||||
hass.data[DATA_SETUP].pop(domain)
|
||||
|
||||
hass.bus.async_fire(
|
||||
EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: component.DOMAIN}
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_prepare_setup_platform(hass: core.HomeAssistant, config, domain: str,
|
||||
platform_name: str) \
|
||||
-> Optional[ModuleType]:
|
||||
"""Load a platform and makes sure dependencies are setup.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
platform_path = PLATFORM_FORMAT.format(domain, platform_name)
|
||||
|
||||
def log_error(msg):
|
||||
"""Log helper."""
|
||||
_LOGGER.error('Unable to prepare setup for platform %s: %s',
|
||||
platform_path, msg)
|
||||
async_notify_setup_error(hass, platform_path)
|
||||
|
||||
platform = loader.get_platform(domain, platform_name)
|
||||
|
||||
# Not found
|
||||
if platform is None:
|
||||
log_error('Platform not found.')
|
||||
return None
|
||||
|
||||
# Already loaded
|
||||
elif platform_path in hass.config.components:
|
||||
return platform
|
||||
|
||||
# Load dependencies
|
||||
if hasattr(platform, 'DEPENDENCIES'):
|
||||
dep_success = yield from _async_process_dependencies(
|
||||
hass, config, platform_path, platform.DEPENDENCIES)
|
||||
|
||||
if not dep_success:
|
||||
log_error('Could not setup all dependencies.')
|
||||
return False
|
||||
|
||||
if not hass.config.skip_pip and hasattr(platform, 'REQUIREMENTS'):
|
||||
req_success = yield from _async_process_requirements(
|
||||
hass, platform_path, platform.REQUIREMENTS)
|
||||
|
||||
if not req_success:
|
||||
log_error('Could not install all requirements.')
|
||||
return None
|
||||
|
||||
return platform
|
||||
|
||||
|
||||
def from_config_dict(config: Dict[str, Any],
|
||||
hass: Optional[core.HomeAssistant]=None,
|
||||
config_dir: Optional[str]=None,
|
||||
|
|
|
@ -11,7 +11,7 @@ import os
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.bootstrap import async_prepare_setup_platform
|
||||
from homeassistant.setup import async_prepare_setup_platform
|
||||
from homeassistant import config as conf_util
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID, CONF_PLATFORM, STATE_ON, SERVICE_TURN_ON, SERVICE_TURN_OFF,
|
||||
|
|
|
@ -6,7 +6,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.const import EVENT_COMPONENT_LOADED
|
||||
from homeassistant.bootstrap import (
|
||||
from homeassistant.setup import (
|
||||
async_prepare_setup_platform, ATTR_COMPONENT)
|
||||
from homeassistant.components.frontend import register_built_in_panel
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
|
|
|
@ -14,7 +14,7 @@ import aiohttp
|
|||
import async_timeout
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.bootstrap import async_prepare_setup_platform
|
||||
from homeassistant.setup import async_prepare_setup_platform
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components import group, zone
|
||||
from homeassistant.components.discovery import SERVICE_NETGEAR
|
||||
|
|
|
@ -18,7 +18,7 @@ from voluptuous.error import Error as VoluptuousError
|
|||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
import homeassistant.loader as loader
|
||||
from homeassistant import bootstrap
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.helpers import discovery
|
||||
from homeassistant.helpers.entity import generate_entity_id
|
||||
from homeassistant.helpers.event import track_time_change
|
||||
|
@ -223,7 +223,7 @@ def do_setup(hass, config):
|
|||
setup_services(hass, track_new_found_calendars, calendar_service)
|
||||
|
||||
# Ensure component is loaded
|
||||
bootstrap.setup_component(hass, 'calendar', config)
|
||||
setup_component(hass, 'calendar', config)
|
||||
|
||||
for calendar in hass.data[DATA_INDEX].values():
|
||||
discovery.load_platform(hass, 'calendar', DOMAIN, calendar)
|
||||
|
|
|
@ -13,7 +13,7 @@ import time
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import async_prepare_setup_platform
|
||||
from homeassistant.setup import async_prepare_setup_platform
|
||||
from homeassistant.config import load_yaml_config_file
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import template, config_validation as cv
|
||||
|
|
|
@ -12,7 +12,7 @@ import sys
|
|||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components.mqtt import (valid_publish_topic,
|
||||
valid_subscribe_topic)
|
||||
from homeassistant.const import (ATTR_BATTERY_LEVEL, CONF_NAME,
|
||||
|
|
|
@ -11,7 +11,7 @@ from functools import partial
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.bootstrap import async_prepare_setup_platform
|
||||
from homeassistant.setup import async_prepare_setup_platform
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.config import load_yaml_config_file
|
||||
|
|
|
@ -18,7 +18,7 @@ from aiohttp import web
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.bootstrap import async_prepare_setup_platform
|
||||
from homeassistant.setup import async_prepare_setup_platform
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.config import load_yaml_config_file
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
|
|
|
@ -7,7 +7,7 @@ There are two different types of discoveries that can be fired/listened for.
|
|||
"""
|
||||
import asyncio
|
||||
|
||||
from homeassistant import bootstrap, core
|
||||
from homeassistant import setup, core
|
||||
from homeassistant.const import (
|
||||
ATTR_DISCOVERED, ATTR_SERVICE, EVENT_PLATFORM_DISCOVERED)
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
@ -63,7 +63,7 @@ def async_discover(hass, service, discovered=None, component=None,
|
|||
'Cannot discover the {} component.'.format(component))
|
||||
|
||||
if component is not None and component not in hass.config.components:
|
||||
yield from bootstrap.async_setup_component(
|
||||
yield from setup.async_setup_component(
|
||||
hass, component, hass_config)
|
||||
|
||||
data = {
|
||||
|
@ -151,7 +151,7 @@ def async_load_platform(hass, component, platform, discovered=None,
|
|||
setup_success = True
|
||||
|
||||
if component not in hass.config.components:
|
||||
setup_success = yield from bootstrap.async_setup_component(
|
||||
setup_success = yield from setup.async_setup_component(
|
||||
hass, component, hass_config)
|
||||
|
||||
# No need to fire event if we could not setup component
|
||||
|
|
|
@ -3,7 +3,7 @@ import asyncio
|
|||
from datetime import timedelta
|
||||
|
||||
from homeassistant import config as conf_util
|
||||
from homeassistant.bootstrap import async_prepare_setup_platform
|
||||
from homeassistant.setup import async_prepare_setup_platform
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID, CONF_SCAN_INTERVAL, CONF_ENTITY_NAMESPACE,
|
||||
DEVICE_DEFAULT_NAME)
|
||||
|
|
|
@ -21,8 +21,7 @@ from typing import Optional
|
|||
|
||||
import requests
|
||||
|
||||
import homeassistant.bootstrap as bootstrap
|
||||
import homeassistant.core as ha
|
||||
from homeassistant import setup, core as ha
|
||||
from homeassistant.const import (
|
||||
HTTP_HEADER_HA_AUTH, SERVER_PORT, URL_API, URL_API_EVENT_FORWARD,
|
||||
URL_API_EVENTS, URL_API_EVENTS_EVENT, URL_API_SERVICES, URL_API_CONFIG,
|
||||
|
@ -151,7 +150,7 @@ class HomeAssistant(ha.HomeAssistant):
|
|||
"""Start the instance."""
|
||||
# Ensure a local API exists to connect with remote
|
||||
if 'api' not in self.config.components:
|
||||
if not bootstrap.setup_component(self, 'api'):
|
||||
if not setup.setup_component(self, 'api'):
|
||||
raise HomeAssistantError(
|
||||
'Unable to setup local API to receive events')
|
||||
|
||||
|
|
|
@ -9,9 +9,7 @@ from unittest.mock import patch
|
|||
|
||||
from typing import Dict, List, Sequence
|
||||
|
||||
import homeassistant.bootstrap as bootstrap
|
||||
import homeassistant.config as config_util
|
||||
import homeassistant.loader as loader
|
||||
from homeassistant import bootstrap, loader, setup, config as config_util
|
||||
import homeassistant.util.yaml as yaml
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
|
@ -30,8 +28,8 @@ MOCKS = {
|
|||
config_util.async_log_exception),
|
||||
'package_error': ("homeassistant.config._log_pkg_error",
|
||||
config_util._log_pkg_error),
|
||||
'logger_exception': ("homeassistant.bootstrap._LOGGER.error",
|
||||
bootstrap._LOGGER.error),
|
||||
'logger_exception': ("homeassistant.setup._LOGGER.error",
|
||||
setup._LOGGER.error),
|
||||
}
|
||||
SILENCE = (
|
||||
'homeassistant.bootstrap.clear_secret_cache',
|
||||
|
|
|
@ -0,0 +1,253 @@
|
|||
"""Provides methods to bootstrap a home assistant instance."""
|
||||
import asyncio
|
||||
import logging
|
||||
import logging.handlers
|
||||
|
||||
from types import ModuleType
|
||||
from typing import Optional, Dict
|
||||
|
||||
import homeassistant.config as conf_util
|
||||
from homeassistant.config import async_notify_setup_error
|
||||
import homeassistant.core as core
|
||||
import homeassistant.loader as loader
|
||||
import homeassistant.util.package as pkg_util
|
||||
from homeassistant.util.async import run_coroutine_threadsafe
|
||||
from homeassistant.const import EVENT_COMPONENT_LOADED, PLATFORM_FORMAT
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_COMPONENT = 'component'
|
||||
|
||||
DATA_SETUP = 'setup_tasks'
|
||||
DATA_PIP_LOCK = 'pip_lock'
|
||||
|
||||
|
||||
def setup_component(hass: core.HomeAssistant, domain: str,
|
||||
config: Optional[Dict]=None) -> bool:
|
||||
"""Setup a component and all its dependencies."""
|
||||
return run_coroutine_threadsafe(
|
||||
async_setup_component(hass, domain, config), loop=hass.loop).result()
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_component(hass: core.HomeAssistant, domain: str,
|
||||
config: Optional[Dict]=None) -> bool:
|
||||
"""Setup a component and all its dependencies.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
if domain in hass.config.components:
|
||||
return True
|
||||
|
||||
setup_tasks = hass.data.get(DATA_SETUP)
|
||||
|
||||
if setup_tasks is not None and domain in setup_tasks:
|
||||
return (yield from setup_tasks[domain])
|
||||
|
||||
if config is None:
|
||||
config = {}
|
||||
|
||||
if setup_tasks is None:
|
||||
setup_tasks = hass.data[DATA_SETUP] = {}
|
||||
|
||||
task = setup_tasks[domain] = hass.async_add_job(
|
||||
_async_setup_component(hass, domain, config))
|
||||
|
||||
return (yield from task)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def _async_process_requirements(hass: core.HomeAssistant, name: str,
|
||||
requirements) -> bool:
|
||||
"""Install the requirements for a component.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
if hass.config.skip_pip:
|
||||
return True
|
||||
|
||||
pip_lock = hass.data.get(DATA_PIP_LOCK)
|
||||
if pip_lock is None:
|
||||
pip_lock = hass.data[DATA_PIP_LOCK] = asyncio.Lock(loop=hass.loop)
|
||||
|
||||
def pip_install(mod):
|
||||
"""Install packages."""
|
||||
return pkg_util.install_package(mod, target=hass.config.path('deps'))
|
||||
|
||||
with (yield from pip_lock):
|
||||
for req in requirements:
|
||||
ret = yield from hass.loop.run_in_executor(None, pip_install, req)
|
||||
if not ret:
|
||||
_LOGGER.error('Not initializing %s because could not install '
|
||||
'dependency %s', name, req)
|
||||
async_notify_setup_error(hass, name)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def _async_process_dependencies(hass, config, name, dependencies):
|
||||
"""Ensure all dependencies are set up."""
|
||||
blacklisted = [dep for dep in dependencies
|
||||
if dep in loader.DEPENDENCY_BLACKLIST]
|
||||
|
||||
if blacklisted:
|
||||
_LOGGER.error('Unable to setup dependencies of %s: '
|
||||
'found blacklisted dependencies: %s',
|
||||
name, ', '.join(blacklisted))
|
||||
return False
|
||||
|
||||
tasks = [async_setup_component(hass, dep, config) for dep
|
||||
in dependencies]
|
||||
|
||||
if not tasks:
|
||||
return True
|
||||
|
||||
results = yield from asyncio.gather(*tasks, loop=hass.loop)
|
||||
|
||||
failed = [dependencies[idx] for idx, res
|
||||
in enumerate(results) if not res]
|
||||
|
||||
if failed:
|
||||
_LOGGER.error('Unable to setup dependencies of %s. '
|
||||
'Setup failed for dependencies: %s',
|
||||
name, ', '.join(failed))
|
||||
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def _async_setup_component(hass: core.HomeAssistant,
|
||||
domain: str, config) -> bool:
|
||||
"""Setup a component for Home Assistant.
|
||||
|
||||
This method is a coroutine.
|
||||
|
||||
hass: Home Assistant instance.
|
||||
domain: Domain of component to setup.
|
||||
config: The Home Assistant configuration.
|
||||
"""
|
||||
def log_error(msg, link=True):
|
||||
"""Log helper."""
|
||||
_LOGGER.error('Setup failed for %s: %s', domain, msg)
|
||||
async_notify_setup_error(hass, domain, link)
|
||||
|
||||
component = loader.get_component(domain)
|
||||
|
||||
if not component:
|
||||
log_error('Component not found.', False)
|
||||
return False
|
||||
|
||||
# Validate no circular dependencies
|
||||
components = loader.load_order_component(domain)
|
||||
|
||||
# OrderedSet is empty if component or dependencies could not be resolved
|
||||
if not components:
|
||||
log_error('Unable to resolve component or dependencies.')
|
||||
return False
|
||||
|
||||
processed_config = \
|
||||
conf_util.async_process_component_config(hass, config, domain)
|
||||
|
||||
if processed_config is None:
|
||||
log_error('Invalid config.')
|
||||
return False
|
||||
|
||||
if not hass.config.skip_pip and hasattr(component, 'REQUIREMENTS'):
|
||||
req_success = yield from _async_process_requirements(
|
||||
hass, domain, component.REQUIREMENTS)
|
||||
if not req_success:
|
||||
log_error('Could not install all requirements.')
|
||||
return False
|
||||
|
||||
if hasattr(component, 'DEPENDENCIES'):
|
||||
dep_success = yield from _async_process_dependencies(
|
||||
hass, config, domain, component.DEPENDENCIES)
|
||||
|
||||
if not dep_success:
|
||||
log_error('Could not setup all dependencies.')
|
||||
return False
|
||||
|
||||
async_comp = hasattr(component, 'async_setup')
|
||||
|
||||
try:
|
||||
_LOGGER.info("Setting up %s", domain)
|
||||
if async_comp:
|
||||
result = yield from component.async_setup(hass, processed_config)
|
||||
else:
|
||||
result = yield from hass.loop.run_in_executor(
|
||||
None, component.setup, hass, processed_config)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
_LOGGER.exception('Error during setup of component %s', domain)
|
||||
async_notify_setup_error(hass, domain, True)
|
||||
return False
|
||||
|
||||
if result is False:
|
||||
log_error('Component failed to initialize.')
|
||||
return False
|
||||
elif result is not True:
|
||||
log_error('Component did not return boolean if setup was successful. '
|
||||
'Disabling component.')
|
||||
loader.set_component(domain, None)
|
||||
return False
|
||||
|
||||
hass.config.components.add(component.DOMAIN)
|
||||
|
||||
# cleanup
|
||||
if domain in hass.data[DATA_SETUP]:
|
||||
hass.data[DATA_SETUP].pop(domain)
|
||||
|
||||
hass.bus.async_fire(
|
||||
EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: component.DOMAIN}
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_prepare_setup_platform(hass: core.HomeAssistant, config, domain: str,
|
||||
platform_name: str) \
|
||||
-> Optional[ModuleType]:
|
||||
"""Load a platform and makes sure dependencies are setup.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
platform_path = PLATFORM_FORMAT.format(domain, platform_name)
|
||||
|
||||
def log_error(msg):
|
||||
"""Log helper."""
|
||||
_LOGGER.error('Unable to prepare setup for platform %s: %s',
|
||||
platform_path, msg)
|
||||
async_notify_setup_error(hass, platform_path)
|
||||
|
||||
platform = loader.get_platform(domain, platform_name)
|
||||
|
||||
# Not found
|
||||
if platform is None:
|
||||
log_error('Platform not found.')
|
||||
return None
|
||||
|
||||
# Already loaded
|
||||
elif platform_path in hass.config.components:
|
||||
return platform
|
||||
|
||||
# Load dependencies
|
||||
if hasattr(platform, 'DEPENDENCIES'):
|
||||
dep_success = yield from _async_process_dependencies(
|
||||
hass, config, platform_path, platform.DEPENDENCIES)
|
||||
|
||||
if not dep_success:
|
||||
log_error('Could not setup all dependencies.')
|
||||
return False
|
||||
|
||||
if not hass.config.skip_pip and hasattr(platform, 'REQUIREMENTS'):
|
||||
req_success = yield from _async_process_requirements(
|
||||
hass, platform_path, platform.REQUIREMENTS)
|
||||
|
||||
if not req_success:
|
||||
log_error('Could not install all requirements.')
|
||||
return None
|
||||
|
||||
return platform
|
|
@ -13,7 +13,7 @@ from aiohttp import web
|
|||
from aiohttp.test_utils import unused_port as get_test_instance_port # noqa
|
||||
|
||||
from homeassistant import core as ha, loader
|
||||
from homeassistant.bootstrap import setup_component, DATA_SETUP
|
||||
from homeassistant.setup import setup_component, DATA_SETUP
|
||||
from homeassistant.config import async_process_component_config
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
|
@ -435,7 +435,7 @@ def assert_setup_component(count, domain=None):
|
|||
- domain: The domain to count is optional. It can be automatically
|
||||
determined most of the time
|
||||
|
||||
Use as a context manager aroung bootstrap.setup_component
|
||||
Use as a context manager aroung setup.setup_component
|
||||
with assert_setup_component(0) as result_config:
|
||||
setup_component(hass, domain, start_config)
|
||||
# using result_config is optional
|
||||
|
|
|
@ -3,7 +3,7 @@ from datetime import timedelta
|
|||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY,
|
||||
STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests the MQTT alarm control panel component."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY,
|
||||
STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED, STATE_UNKNOWN)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import unittest
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.automation as automation
|
||||
|
||||
from tests.common import get_test_home_assistant, mock_component
|
||||
|
|
|
@ -5,7 +5,7 @@ import unittest
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.core import State
|
||||
from homeassistant.bootstrap import setup_component, async_setup_component
|
||||
from homeassistant.setup import setup_component, async_setup_component
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_ON, STATE_OFF
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
|
|
@ -4,7 +4,7 @@ import unittest
|
|||
from unittest import mock
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant import bootstrap
|
||||
from homeassistant import setup
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.components import litejet
|
||||
from tests.common import (fire_time_changed, get_test_home_assistant)
|
||||
|
@ -57,7 +57,7 @@ class TestLiteJetTrigger(unittest.TestCase):
|
|||
'port': '/tmp/this_will_be_mocked'
|
||||
}
|
||||
}
|
||||
assert bootstrap.setup_component(self.hass, litejet.DOMAIN, config)
|
||||
assert setup.setup_component(self.hass, litejet.DOMAIN, config)
|
||||
|
||||
self.hass.services.register('test', 'automation', record_call)
|
||||
|
||||
|
@ -106,7 +106,7 @@ class TestLiteJetTrigger(unittest.TestCase):
|
|||
|
||||
def setup_automation(self, trigger):
|
||||
"""Test setting up the automation."""
|
||||
assert bootstrap.setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup.setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: [
|
||||
{
|
||||
'alias': 'My Test',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import unittest
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.automation as automation
|
||||
from tests.common import (
|
||||
mock_mqtt_component, fire_mqtt_message, get_test_home_assistant,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import unittest
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.automation as automation
|
||||
|
||||
from tests.common import get_test_home_assistant, mock_component
|
||||
|
|
|
@ -5,7 +5,7 @@ import unittest
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
import homeassistant.components.automation as automation
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import unittest
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import sun
|
||||
import homeassistant.components.automation as automation
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import unittest
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.automation as automation
|
||||
|
||||
from tests.common import (
|
||||
|
|
|
@ -4,7 +4,7 @@ import unittest
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
import homeassistant.components.automation as automation
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import unittest
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import automation, zone
|
||||
|
||||
from tests.common import get_test_home_assistant, mock_component
|
||||
|
|
|
@ -3,7 +3,7 @@ import unittest
|
|||
|
||||
from homeassistant.const import (STATE_ON, STATE_OFF)
|
||||
from homeassistant.components.binary_sensor import command_line
|
||||
from homeassistant import bootstrap
|
||||
from homeassistant import setup
|
||||
from homeassistant.helpers import template
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
@ -47,7 +47,7 @@ class TestCommandSensorBinarySensor(unittest.TestCase):
|
|||
'platform': 'not_command_line',
|
||||
}
|
||||
|
||||
self.assertFalse(bootstrap.setup_component(self.hass, 'test', {
|
||||
self.assertFalse(setup.setup_component(self.hass, 'test', {
|
||||
'command_line': config,
|
||||
}))
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests for Home Assistant ffmpeg binary sensor."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, assert_setup_component, mock_coro)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests for the MQTT binary sensor platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.binary_sensor as binary_sensor
|
||||
from homeassistant.const import (STATE_OFF, STATE_ON)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from unittest import mock
|
|||
from nx584 import client as nx584_client
|
||||
|
||||
from homeassistant.components.binary_sensor import nx584
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import MagicMock
|
|||
|
||||
import requests_mock
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components.binary_sensor import sleepiq
|
||||
|
||||
from tests.components.test_sleepiq import mock_responses
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import unittest
|
||||
from unittest.mock import patch, Mock
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components.binary_sensor import tcp as bin_tcp
|
||||
from homeassistant.components.sensor import tcp
|
||||
from tests.common import (get_test_home_assistant, assert_setup_component)
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest import mock
|
|||
|
||||
from homeassistant.core import CoreState, State
|
||||
from homeassistant.const import MATCH_ALL
|
||||
import homeassistant.bootstrap as bootstrap
|
||||
from homeassistant import setup
|
||||
from homeassistant.components.binary_sensor import template
|
||||
from homeassistant.exceptions import TemplateError
|
||||
from homeassistant.helpers import template as template_hlpr
|
||||
|
@ -45,13 +45,13 @@ class TestBinarySensorTemplate(unittest.TestCase):
|
|||
},
|
||||
}
|
||||
with assert_setup_component(1):
|
||||
assert bootstrap.setup_component(
|
||||
assert setup.setup_component(
|
||||
self.hass, 'binary_sensor', config)
|
||||
|
||||
def test_setup_no_sensors(self):
|
||||
""""Test setup with no sensors."""
|
||||
with assert_setup_component(0):
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'template'
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
|
|||
def test_setup_invalid_device(self):
|
||||
""""Test the setup with invalid devices."""
|
||||
with assert_setup_component(0):
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'template',
|
||||
'sensors': {
|
||||
|
@ -72,7 +72,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
|
|||
def test_setup_invalid_device_class(self):
|
||||
""""Test setup with invalid sensor class."""
|
||||
with assert_setup_component(0):
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'template',
|
||||
'sensors': {
|
||||
|
@ -87,7 +87,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
|
|||
def test_setup_invalid_missing_template(self):
|
||||
""""Test setup with invalid and missing template."""
|
||||
with assert_setup_component(0):
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'template',
|
||||
'sensors': {
|
||||
|
@ -134,7 +134,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
|
|||
},
|
||||
}
|
||||
with assert_setup_component(1):
|
||||
assert bootstrap.setup_component(
|
||||
assert setup.setup_component(
|
||||
self.hass, 'binary_sensor', config)
|
||||
|
||||
self.hass.start()
|
||||
|
@ -187,7 +187,7 @@ def test_restore_state(hass):
|
|||
},
|
||||
},
|
||||
}
|
||||
yield from bootstrap.async_setup_component(hass, 'binary_sensor', config)
|
||||
yield from setup.async_setup_component(hass, 'binary_sensor', config)
|
||||
|
||||
state = hass.states.get('binary_sensor.test')
|
||||
assert state.state == 'on'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The test for the threshold sensor platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import (ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS)
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""The test for the Trend sensor platform."""
|
||||
import homeassistant.bootstrap as bootstrap
|
||||
from homeassistant import setup
|
||||
|
||||
from tests.common import get_test_home_assistant, assert_setup_component
|
||||
|
||||
|
@ -19,7 +19,7 @@ class TestTrendBinarySensor:
|
|||
|
||||
def test_up(self):
|
||||
"""Test up trend."""
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'trend',
|
||||
'sensors': {
|
||||
|
@ -40,7 +40,7 @@ class TestTrendBinarySensor:
|
|||
|
||||
def test_down(self):
|
||||
"""Test down trend."""
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'trend',
|
||||
'sensors': {
|
||||
|
@ -61,7 +61,7 @@ class TestTrendBinarySensor:
|
|||
|
||||
def test__invert_up(self):
|
||||
"""Test up trend with custom message."""
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'trend',
|
||||
'sensors': {
|
||||
|
@ -83,7 +83,7 @@ class TestTrendBinarySensor:
|
|||
|
||||
def test_invert_down(self):
|
||||
"""Test down trend with custom message."""
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'trend',
|
||||
'sensors': {
|
||||
|
@ -105,7 +105,7 @@ class TestTrendBinarySensor:
|
|||
|
||||
def test_attribute_up(self):
|
||||
"""Test attribute up trend."""
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'trend',
|
||||
'sensors': {
|
||||
|
@ -126,7 +126,7 @@ class TestTrendBinarySensor:
|
|||
|
||||
def test_attribute_down(self):
|
||||
"""Test attribute down trend."""
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'trend',
|
||||
'sensors': {
|
||||
|
@ -149,7 +149,7 @@ class TestTrendBinarySensor:
|
|||
|
||||
def test_non_numeric(self):
|
||||
"""Test up trend."""
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'trend',
|
||||
'sensors': {
|
||||
|
@ -170,7 +170,7 @@ class TestTrendBinarySensor:
|
|||
|
||||
def test_missing_attribute(self):
|
||||
"""Test attribute down trend."""
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'trend',
|
||||
'sensors': {
|
||||
|
@ -195,7 +195,7 @@ class TestTrendBinarySensor:
|
|||
# pylint: disable=invalid-name
|
||||
"""Test invalid name."""
|
||||
with assert_setup_component(0):
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'template',
|
||||
'sensors': {
|
||||
|
@ -212,7 +212,7 @@ class TestTrendBinarySensor:
|
|||
# pylint: disable=invalid-name
|
||||
"""Test invalid sensor."""
|
||||
with assert_setup_component(0):
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'template',
|
||||
'sensors': {
|
||||
|
@ -228,7 +228,7 @@ class TestTrendBinarySensor:
|
|||
def test_no_sensors_does_not_create(self):
|
||||
"""Test no sensors."""
|
||||
with assert_setup_component(0):
|
||||
assert bootstrap.setup_component(self.hass, 'binary_sensor', {
|
||||
assert setup.setup_component(self.hass, 'binary_sensor', {
|
||||
'binary_sensor': {
|
||||
'platform': 'trend'
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import asyncio
|
||||
from unittest import mock
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import ATTR_ENTITY_PICTURE
|
||||
import homeassistant.components.camera as camera
|
||||
import homeassistant.components.http as http
|
||||
|
|
|
@ -6,7 +6,7 @@ from unittest import mock
|
|||
# https://bugs.python.org/issue23004
|
||||
from mock_open import MockOpen
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
from tests.common import mock_http_component
|
||||
import logging
|
||||
|
|
|
@ -7,7 +7,7 @@ import requests
|
|||
from uvcclient import camera
|
||||
from uvcclient import nvr
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components.camera import uvc
|
||||
from tests.common import get_test_home_assistant, mock_http_component
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import unittest
|
|||
from homeassistant.util.unit_system import (
|
||||
METRIC_SYSTEM
|
||||
)
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import climate
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
|
|
@ -7,7 +7,7 @@ from unittest import mock
|
|||
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import setup_component, async_setup_component
|
||||
from homeassistant.setup import setup_component, async_setup_component
|
||||
from homeassistant.const import (
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
SERVICE_TURN_OFF,
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
|
||||
from homeassistant.const import EVENT_COMPONENT_LOADED
|
||||
from homeassistant.bootstrap import async_setup_component, ATTR_COMPONENT
|
||||
from homeassistant.setup import async_setup_component, ATTR_COMPONENT
|
||||
from homeassistant.components import config
|
||||
|
||||
from tests.common import mock_http_component, mock_coro, mock_component
|
||||
|
|
|
@ -5,7 +5,7 @@ import tempfile
|
|||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.cover as cover
|
||||
from homeassistant.components.cover import (
|
||||
command_line as cmd_rs)
|
||||
|
|
|
@ -3,7 +3,7 @@ import unittest
|
|||
from datetime import timedelta
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import cover
|
||||
from tests.common import get_test_home_assistant, fire_time_changed
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests for the MQTT cover platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import STATE_OPEN, STATE_CLOSED, STATE_UNKNOWN
|
||||
import homeassistant.components.cover as cover
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import unittest
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import rfxtrx as rfxtrx_core
|
||||
|
||||
from tests.common import get_test_home_assistant, mock_component
|
||||
|
|
|
@ -6,7 +6,7 @@ from unittest import mock
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import device_tracker
|
||||
from homeassistant.components.device_tracker import (
|
||||
CONF_CONSIDER_HOME, CONF_TRACK_NEW)
|
||||
|
|
|
@ -8,7 +8,7 @@ import requests
|
|||
import requests_mock
|
||||
|
||||
from homeassistant import config
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import device_tracker
|
||||
from homeassistant.const import (
|
||||
CONF_PLATFORM, CONF_HOST, CONF_PASSWORD, CONF_USERNAME)
|
||||
|
|
|
@ -10,7 +10,7 @@ import os
|
|||
|
||||
from homeassistant.components import zone
|
||||
from homeassistant.core import callback, State
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.helpers import discovery
|
||||
from homeassistant.loader import get_component
|
||||
from homeassistant.util.async import run_coroutine_threadsafe
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
import requests
|
||||
|
||||
from homeassistant import bootstrap, const
|
||||
from homeassistant import setup, const
|
||||
import homeassistant.components.device_tracker as device_tracker
|
||||
import homeassistant.components.http as http
|
||||
from homeassistant.const import CONF_PLATFORM
|
||||
|
@ -33,7 +33,7 @@ def setUpModule():
|
|||
|
||||
hass = get_test_home_assistant()
|
||||
# http is not platform based, assert_setup_component not applicable
|
||||
bootstrap.setup_component(hass, http.DOMAIN, {
|
||||
setup.setup_component(hass, http.DOMAIN, {
|
||||
http.DOMAIN: {
|
||||
http.CONF_SERVER_PORT: SERVER_PORT
|
||||
},
|
||||
|
@ -41,7 +41,7 @@ def setUpModule():
|
|||
|
||||
# Set up device tracker
|
||||
with assert_setup_component(1, device_tracker.DOMAIN):
|
||||
bootstrap.setup_component(hass, device_tracker.DOMAIN, {
|
||||
setup.setup_component(hass, device_tracker.DOMAIN, {
|
||||
device_tracker.DOMAIN: {
|
||||
CONF_PLATFORM: 'locative'
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
|||
import logging
|
||||
import os
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import device_tracker
|
||||
from homeassistant.const import CONF_PLATFORM
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from tests.common import (assert_setup_component, fire_mqtt_message,
|
|||
get_test_home_assistant, mock_mqtt_component)
|
||||
|
||||
import homeassistant.components.device_tracker.owntracks as owntracks
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import device_tracker
|
||||
from homeassistant.const import CONF_PLATFORM, STATE_NOT_HOME
|
||||
from homeassistant.util.async import run_coroutine_threadsafe
|
||||
|
|
|
@ -4,7 +4,7 @@ import os
|
|||
from unittest.mock import patch
|
||||
import logging
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import device_tracker
|
||||
from homeassistant.const import (
|
||||
CONF_PLATFORM, CONF_HOST, CONF_PASSWORD)
|
||||
|
|
|
@ -5,7 +5,7 @@ import json
|
|||
from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant import bootstrap, const, core
|
||||
from homeassistant import setup, const, core
|
||||
import homeassistant.components as core_components
|
||||
from homeassistant.components import (
|
||||
emulated_hue, http, light, script, media_player, fan
|
||||
|
@ -33,14 +33,14 @@ def hass_hue(loop, hass):
|
|||
loop.run_until_complete(
|
||||
core_components.async_setup(hass, {core.DOMAIN: {}}))
|
||||
|
||||
loop.run_until_complete(bootstrap.async_setup_component(
|
||||
loop.run_until_complete(setup.async_setup_component(
|
||||
hass, http.DOMAIN,
|
||||
{http.DOMAIN: {http.CONF_SERVER_PORT: HTTP_SERVER_PORT}}))
|
||||
|
||||
with patch('homeassistant.components'
|
||||
'.emulated_hue.UPNPResponderThread'):
|
||||
loop.run_until_complete(
|
||||
bootstrap.async_setup_component(hass, emulated_hue.DOMAIN, {
|
||||
setup.async_setup_component(hass, emulated_hue.DOMAIN, {
|
||||
emulated_hue.DOMAIN: {
|
||||
emulated_hue.CONF_LISTEN_PORT: BRIDGE_SERVER_PORT,
|
||||
emulated_hue.CONF_EXPOSE_BY_DEFAULT: True
|
||||
|
@ -48,7 +48,7 @@ def hass_hue(loop, hass):
|
|||
}))
|
||||
|
||||
loop.run_until_complete(
|
||||
bootstrap.async_setup_component(hass, light.DOMAIN, {
|
||||
setup.async_setup_component(hass, light.DOMAIN, {
|
||||
'light': [
|
||||
{
|
||||
'platform': 'demo',
|
||||
|
@ -57,7 +57,7 @@ def hass_hue(loop, hass):
|
|||
}))
|
||||
|
||||
loop.run_until_complete(
|
||||
bootstrap.async_setup_component(hass, script.DOMAIN, {
|
||||
setup.async_setup_component(hass, script.DOMAIN, {
|
||||
'script': {
|
||||
'set_kitchen_light': {
|
||||
'sequence': [
|
||||
|
@ -75,7 +75,7 @@ def hass_hue(loop, hass):
|
|||
}))
|
||||
|
||||
loop.run_until_complete(
|
||||
bootstrap.async_setup_component(hass, media_player.DOMAIN, {
|
||||
setup.async_setup_component(hass, media_player.DOMAIN, {
|
||||
'media_player': [
|
||||
{
|
||||
'platform': 'demo',
|
||||
|
@ -84,7 +84,7 @@ def hass_hue(loop, hass):
|
|||
}))
|
||||
|
||||
loop.run_until_complete(
|
||||
bootstrap.async_setup_component(hass, fan.DOMAIN, {
|
||||
setup.async_setup_component(hass, fan.DOMAIN, {
|
||||
'fan': [
|
||||
{
|
||||
'platform': 'demo',
|
||||
|
|
|
@ -5,7 +5,7 @@ import unittest
|
|||
from unittest.mock import patch
|
||||
import requests
|
||||
|
||||
from homeassistant import bootstrap, const, core
|
||||
from homeassistant import setup, const, core
|
||||
import homeassistant.components as core_components
|
||||
from homeassistant.components import emulated_hue, http
|
||||
from homeassistant.util.async import run_coroutine_threadsafe
|
||||
|
@ -28,11 +28,11 @@ def setup_hass_instance(emulated_hue_config):
|
|||
core_components.async_setup(hass, {core.DOMAIN: {}}), hass.loop
|
||||
).result()
|
||||
|
||||
bootstrap.setup_component(
|
||||
setup.setup_component(
|
||||
hass, http.DOMAIN,
|
||||
{http.DOMAIN: {http.CONF_SERVER_PORT: HTTP_SERVER_PORT}})
|
||||
|
||||
bootstrap.setup_component(hass, emulated_hue.DOMAIN, emulated_hue_config)
|
||||
setup.setup_component(hass, emulated_hue.DOMAIN, emulated_hue_config)
|
||||
|
||||
return hass
|
||||
|
||||
|
@ -57,13 +57,13 @@ class TestEmulatedHue(unittest.TestCase):
|
|||
core_components.async_setup(hass, {core.DOMAIN: {}}), hass.loop
|
||||
).result()
|
||||
|
||||
bootstrap.setup_component(
|
||||
setup.setup_component(
|
||||
hass, http.DOMAIN,
|
||||
{http.DOMAIN: {http.CONF_SERVER_PORT: HTTP_SERVER_PORT}})
|
||||
|
||||
with patch('homeassistant.components'
|
||||
'.emulated_hue.UPNPResponderThread'):
|
||||
bootstrap.setup_component(hass, emulated_hue.DOMAIN, {
|
||||
setup.setup_component(hass, emulated_hue.DOMAIN, {
|
||||
emulated_hue.DOMAIN: {
|
||||
emulated_hue.CONF_LISTEN_PORT: BRIDGE_SERVER_PORT
|
||||
}})
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import fan
|
||||
from homeassistant.components.fan.demo import FAN_ENTITY_ID
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
|
|
|
@ -6,7 +6,7 @@ from unittest.mock import patch
|
|||
|
||||
import requests
|
||||
|
||||
from homeassistant import bootstrap, const
|
||||
from homeassistant import setup, const
|
||||
import homeassistant.components.http as http
|
||||
from homeassistant.components.http.const import (
|
||||
KEY_TRUSTED_NETWORKS, KEY_USE_X_FORWARDED_FOR, HTTP_HEADER_X_FORWARDED_FOR)
|
||||
|
@ -43,7 +43,7 @@ def setUpModule():
|
|||
|
||||
hass = get_test_home_assistant()
|
||||
|
||||
bootstrap.setup_component(
|
||||
setup.setup_component(
|
||||
hass, http.DOMAIN, {
|
||||
http.DOMAIN: {
|
||||
http.CONF_API_PASSWORD: API_PASSWORD,
|
||||
|
@ -52,7 +52,7 @@ def setUpModule():
|
|||
}
|
||||
)
|
||||
|
||||
bootstrap.setup_component(hass, 'api')
|
||||
setup.setup_component(hass, 'api')
|
||||
|
||||
hass.http.app[KEY_TRUSTED_NETWORKS] = [
|
||||
ip_network(trusted_network)
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch, mock_open
|
|||
|
||||
import requests
|
||||
|
||||
from homeassistant import bootstrap, const
|
||||
from homeassistant import setup, const
|
||||
import homeassistant.components.http as http
|
||||
from homeassistant.components.http.const import (
|
||||
KEY_BANS_ENABLED, KEY_LOGIN_THRESHOLD, KEY_BANNED_IPS)
|
||||
|
@ -38,7 +38,7 @@ def setUpModule():
|
|||
|
||||
hass = get_test_home_assistant()
|
||||
|
||||
bootstrap.setup_component(
|
||||
setup.setup_component(
|
||||
hass, http.DOMAIN, {
|
||||
http.DOMAIN: {
|
||||
http.CONF_API_PASSWORD: API_PASSWORD,
|
||||
|
@ -47,7 +47,7 @@ def setUpModule():
|
|||
}
|
||||
)
|
||||
|
||||
bootstrap.setup_component(hass, 'api')
|
||||
setup.setup_component(hass, 'api')
|
||||
|
||||
hass.http.app[KEY_BANNED_IPS] = [IpBan(banned_ip) for banned_ip
|
||||
in BANNED_IPS]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import asyncio
|
||||
import requests
|
||||
|
||||
from homeassistant import bootstrap, const
|
||||
from homeassistant import setup, const
|
||||
import homeassistant.components.http as http
|
||||
|
||||
from tests.common import get_test_instance_port, get_test_home_assistant
|
||||
|
@ -32,7 +32,7 @@ def setUpModule():
|
|||
|
||||
hass = get_test_home_assistant()
|
||||
|
||||
bootstrap.setup_component(
|
||||
setup.setup_component(
|
||||
hass, http.DOMAIN, {
|
||||
http.DOMAIN: {
|
||||
http.CONF_API_PASSWORD: API_PASSWORD,
|
||||
|
@ -42,7 +42,7 @@ def setUpModule():
|
|||
}
|
||||
)
|
||||
|
||||
bootstrap.setup_component(hass, 'api')
|
||||
setup.setup_component(hass, 'api')
|
||||
|
||||
# Registering static path as it caused CORS to blow up
|
||||
hass.http.register_static_path(
|
||||
|
@ -131,7 +131,7 @@ class TestView(http.HomeAssistantView):
|
|||
@asyncio.coroutine
|
||||
def test_registering_view_while_running(hass, test_client):
|
||||
"""Test that we can register a view while the server is running."""
|
||||
yield from bootstrap.async_setup_component(
|
||||
yield from setup.async_setup_component(
|
||||
hass, http.DOMAIN, {
|
||||
http.DOMAIN: {
|
||||
http.CONF_SERVER_PORT: get_test_instance_port(),
|
||||
|
@ -139,7 +139,7 @@ def test_registering_view_while_running(hass, test_client):
|
|||
}
|
||||
)
|
||||
|
||||
yield from bootstrap.async_setup_component(hass, 'api')
|
||||
yield from setup.async_setup_component(hass, 'api')
|
||||
|
||||
yield from hass.async_start()
|
||||
|
||||
|
@ -159,7 +159,7 @@ def test_registering_view_while_running(hass, test_client):
|
|||
@asyncio.coroutine
|
||||
def test_api_base_url_with_domain(hass):
|
||||
"""Test setting api url."""
|
||||
result = yield from bootstrap.async_setup_component(hass, 'http', {
|
||||
result = yield from setup.async_setup_component(hass, 'http', {
|
||||
'http': {
|
||||
'base_url': 'example.com'
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ def test_api_base_url_with_domain(hass):
|
|||
@asyncio.coroutine
|
||||
def test_api_base_url_with_ip(hass):
|
||||
"""Test setting api url."""
|
||||
result = yield from bootstrap.async_setup_component(hass, 'http', {
|
||||
result = yield from setup.async_setup_component(hass, 'http', {
|
||||
'http': {
|
||||
'server_host': '1.1.1.1'
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ def test_api_base_url_with_ip(hass):
|
|||
@asyncio.coroutine
|
||||
def test_api_base_url_with_ip_port(hass):
|
||||
"""Test setting api url."""
|
||||
result = yield from bootstrap.async_setup_component(hass, 'http', {
|
||||
result = yield from setup.async_setup_component(hass, 'http', {
|
||||
'http': {
|
||||
'base_url': '1.1.1.1:8124'
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ def test_api_base_url_with_ip_port(hass):
|
|||
@asyncio.coroutine
|
||||
def test_api_no_base_url(hass):
|
||||
"""Test setting api url."""
|
||||
result = yield from bootstrap.async_setup_component(hass, 'http', {
|
||||
result = yield from setup.async_setup_component(hass, 'http', {
|
||||
'http': {
|
||||
}
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch, PropertyMock
|
|||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.const import ATTR_ENTITY_PICTURE
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
import homeassistant.components.http as http
|
||||
import homeassistant.components.image_processing as ip
|
||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch, PropertyMock
|
|||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.const import ATTR_ENTITY_PICTURE
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.image_processing as ip
|
||||
import homeassistant.components.microsoft_face as mf
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch, PropertyMock
|
|||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.const import ATTR_ENTITY_PICTURE
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.image_processing as ip
|
||||
import homeassistant.components.microsoft_face as mf
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch, PropertyMock
|
|||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.const import ATTR_ENTITY_PICTURE
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.image_processing as ip
|
||||
from homeassistant.components.image_processing.openalpr_cloud import (
|
||||
OPENALPR_API_URL)
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch, PropertyMock, MagicMock
|
|||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.const import ATTR_ENTITY_PICTURE
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.image_processing as ip
|
||||
|
||||
from tests.common import (
|
||||
|
|
|
@ -4,7 +4,7 @@ import asyncio
|
|||
import unittest
|
||||
|
||||
from homeassistant.core import State, CoreState
|
||||
from homeassistant.bootstrap import setup_component, async_setup_component
|
||||
from homeassistant.setup import setup_component, async_setup_component
|
||||
import homeassistant.components.light as light
|
||||
from homeassistant.helpers.restore_state import DATA_RESTORE_CACHE
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import unittest
|
||||
import os
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.loader as loader
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID, STATE_ON, STATE_OFF, CONF_PLATFORM,
|
||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
|||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from homeassistant import bootstrap
|
||||
from homeassistant import setup
|
||||
from homeassistant.components import litejet
|
||||
from tests.common import get_test_home_assistant
|
||||
import homeassistant.components.light as light
|
||||
|
@ -47,7 +47,7 @@ class TestLiteJetLight(unittest.TestCase):
|
|||
self.mock_lj.on_load_activated.side_effect = on_load_activated
|
||||
self.mock_lj.on_load_deactivated.side_effect = on_load_deactivated
|
||||
|
||||
assert bootstrap.setup_component(
|
||||
assert setup.setup_component(
|
||||
self.hass,
|
||||
litejet.DOMAIN,
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ light:
|
|||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import STATE_ON, STATE_OFF, ATTR_ASSUMED_STATE
|
||||
import homeassistant.components.light as light
|
||||
from tests.common import (
|
||||
|
|
|
@ -30,7 +30,7 @@ light:
|
|||
import json
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import STATE_ON, STATE_OFF, ATTR_ASSUMED_STATE
|
||||
import homeassistant.components.light as light
|
||||
from tests.common import (
|
||||
|
|
|
@ -22,7 +22,7 @@ If your light doesn't support rgb feature, omit `(red|green|blue)_template`.
|
|||
"""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import STATE_ON, STATE_OFF, ATTR_ASSUMED_STATE
|
||||
import homeassistant.components.light as light
|
||||
from tests.common import (
|
||||
|
|
|
@ -3,7 +3,7 @@ import unittest
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import rfxtrx as rfxtrx_core
|
||||
|
||||
from tests.common import get_test_home_assistant, mock_component
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests for the Demo lock platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import lock
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests for the MQTT lock platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import (STATE_LOCKED, STATE_UNLOCKED,
|
||||
ATTR_ASSUMED_STATE)
|
||||
import homeassistant.components.lock as lock
|
||||
|
|
|
@ -3,7 +3,7 @@ import unittest
|
|||
from unittest.mock import patch
|
||||
import asyncio
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import HTTP_HEADER_HA_AUTH
|
||||
import homeassistant.components.media_player as mp
|
||||
import homeassistant.components.http as http
|
||||
|
|
|
@ -5,7 +5,7 @@ import soco.snapshot
|
|||
from unittest import mock
|
||||
import soco
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components.media_player import sonos, DOMAIN
|
||||
from homeassistant.components.media_player.sonos import CONF_INTERFACE_ADDR, \
|
||||
CONF_ADVERTISE_ADDR
|
||||
|
|
|
@ -8,7 +8,7 @@ import socket
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import setup_component, async_setup_component
|
||||
from homeassistant.setup import setup_component, async_setup_component
|
||||
import homeassistant.components.mqtt as mqtt
|
||||
from homeassistant.const import (
|
||||
EVENT_CALL_SERVICE, ATTR_DOMAIN, ATTR_SERVICE, EVENT_HOMEASSISTANT_START,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests for the MQTT component embedded server."""
|
||||
from unittest.mock import Mock, MagicMock, patch
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.mqtt as mqtt
|
||||
|
||||
from tests.common import (
|
||||
|
|
|
@ -7,7 +7,7 @@ from apns2.errors import Unregistered
|
|||
import yaml
|
||||
|
||||
import homeassistant.components.notify as notify
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components.notify import apns
|
||||
from homeassistant.core import State
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import tempfile
|
|||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.notify as notify
|
||||
from tests.common import assert_setup_component, get_test_home_assistant
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import unittest
|
|||
from unittest.mock import patch
|
||||
|
||||
import homeassistant.components.notify as notify
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components.notify import demo
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import discovery, script
|
||||
|
|
|
@ -3,7 +3,7 @@ import os
|
|||
import unittest
|
||||
from unittest.mock import call, mock_open, patch
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.notify as notify
|
||||
from homeassistant.components.notify import (
|
||||
ATTR_TITLE_DEFAULT)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.notify as notify
|
||||
from homeassistant.components.notify import group, demo
|
||||
from homeassistant.util.async import run_coroutine_threadsafe
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# pylint: disable=protected-access
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.remote as remote
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID, STATE_ON, STATE_OFF, CONF_PLATFORM,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID, STATE_ON, STATE_OFF, CONF_PLATFORM,
|
||||
SERVICE_TURN_ON, SERVICE_TURN_OFF)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests for the Scene component."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant import loader
|
||||
from homeassistant.components import light, scene
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
|||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from homeassistant import bootstrap
|
||||
from homeassistant import setup
|
||||
from homeassistant.components import litejet
|
||||
from tests.common import get_test_home_assistant
|
||||
import homeassistant.components.scene as scene
|
||||
|
@ -35,7 +35,7 @@ class TestLiteJetScene(unittest.TestCase):
|
|||
self.mock_lj.scenes.return_value = range(1, 3)
|
||||
self.mock_lj.get_scene_name.side_effect = get_scene_name
|
||||
|
||||
assert bootstrap.setup_component(
|
||||
assert setup.setup_component(
|
||||
self.hass,
|
||||
litejet.DOMAIN,
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ import unittest
|
|||
|
||||
from homeassistant.helpers.template import Template
|
||||
from homeassistant.components.sensor import command_line
|
||||
from homeassistant import bootstrap
|
||||
from homeassistant import setup
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ class TestCommandSensorSensor(unittest.TestCase):
|
|||
'platform': 'not_command_line',
|
||||
}
|
||||
|
||||
self.assertFalse(bootstrap.setup_component(self.hass, 'test', {
|
||||
self.assertFalse(setup.setup_component(self.hass, 'test', {
|
||||
'command_line': config,
|
||||
}))
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import requests_mock
|
|||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.sensor import darksky
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
from tests.common import load_fixture, get_test_home_assistant
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ from datetime import timedelta
|
|||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components.sensor.history_stats import HistoryStatsSensor
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.helpers.template import Template
|
||||
|
|
|
@ -4,7 +4,7 @@ import unittest.mock as mock
|
|||
|
||||
import requests
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.sensor as sensor
|
||||
import homeassistant.components.sensor.mfi as mfi
|
||||
from homeassistant.const import TEMP_CELSIUS
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import unittest
|
||||
from unittest.mock import patch, DEFAULT, Mock
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components.sensor import DOMAIN
|
||||
import homeassistant.components.sensor.mhz19 as mhz19
|
||||
from homeassistant.const import TEMP_FAHRENHEIT
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The test for the min/max sensor platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import (
|
||||
STATE_UNKNOWN, ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||
from tests.common import get_test_home_assistant
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests for the MoldIndicator sensor."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.sensor as sensor
|
||||
from homeassistant.components.sensor.mold_indicator import (ATTR_DEWPOINT,
|
||||
ATTR_CRITICAL_TEMP)
|
||||
|
|
|
@ -4,7 +4,7 @@ from datetime import datetime
|
|||
from unittest.mock import patch
|
||||
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests for the MQTT sensor platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.sensor as sensor
|
||||
from tests.common import mock_mqtt_component, fire_mqtt_message
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import datetime
|
|||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.sensor as sensor
|
||||
from homeassistant.components.mqtt import (CONF_STATE_TOPIC, CONF_QOS,
|
||||
DEFAULT_QOS)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The tests for the Pilight sensor platform."""
|
||||
import logging
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.sensor as sensor
|
||||
from homeassistant.components import pilight
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The test for the random number sensor platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import requests
|
|||
from requests.exceptions import Timeout, MissingSchema, RequestException
|
||||
import requests_mock
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.setup import setup_component
|
||||
import homeassistant.components.sensor as sensor
|
||||
import homeassistant.components.sensor.rest as rest
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue