diff --git a/homeassistant/components/fan/__init__.py b/homeassistant/components/fan/__init__.py index ec18637f065..36b075747e0 100644 --- a/homeassistant/components/fan/__init__.py +++ b/homeassistant/components/fan/__init__.py @@ -4,7 +4,6 @@ Provides functionality to interact with fans. For more details about this component, please refer to the documentation at https://home-assistant.io/components/fan/ """ -import asyncio from datetime import timedelta import functools as ft import logging @@ -98,13 +97,12 @@ def is_on(hass, entity_id: str = None) -> bool: return state.attributes[ATTR_SPEED] not in [SPEED_OFF, STATE_UNKNOWN] -@asyncio.coroutine -def async_setup(hass, config: dict): +async def async_setup(hass, config: dict): """Expose fan control via statemachine and services.""" - component = EntityComponent( + component = hass.data[DOMAIN] = EntityComponent( _LOGGER, DOMAIN, hass, SCAN_INTERVAL, GROUP_NAME_ALL_FANS) - yield from component.async_setup(config) + await component.async_setup(config) component.async_register_entity_service( SERVICE_TURN_ON, FAN_TURN_ON_SCHEMA, @@ -134,6 +132,16 @@ def async_setup(hass, config: dict): return True +async def async_setup_entry(hass, entry): + """Set up a config entry.""" + return await hass.data[DOMAIN].async_setup_entry(entry) + + +async def async_unload_entry(hass, entry): + """Unload a config entry.""" + return await hass.data[DOMAIN].async_unload_entry(entry) + + class FanEntity(ToggleEntity): """Representation of a fan."""