Convert fan component to config entry (#16951)
* Conver fan component to config entry * Lintpull/16978/head
parent
c600d28b6a
commit
35b6064581
|
@ -4,7 +4,6 @@ Provides functionality to interact with fans.
|
||||||
For more details about this component, please refer to the documentation at
|
For more details about this component, please refer to the documentation at
|
||||||
https://home-assistant.io/components/fan/
|
https://home-assistant.io/components/fan/
|
||||||
"""
|
"""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import functools as ft
|
import functools as ft
|
||||||
import logging
|
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]
|
return state.attributes[ATTR_SPEED] not in [SPEED_OFF, STATE_UNKNOWN]
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def async_setup(hass, config: dict):
|
||||||
def async_setup(hass, config: dict):
|
|
||||||
"""Expose fan control via statemachine and services."""
|
"""Expose fan control via statemachine and services."""
|
||||||
component = EntityComponent(
|
component = hass.data[DOMAIN] = EntityComponent(
|
||||||
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, GROUP_NAME_ALL_FANS)
|
_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(
|
component.async_register_entity_service(
|
||||||
SERVICE_TURN_ON, FAN_TURN_ON_SCHEMA,
|
SERVICE_TURN_ON, FAN_TURN_ON_SCHEMA,
|
||||||
|
@ -134,6 +132,16 @@ def async_setup(hass, config: dict):
|
||||||
return True
|
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):
|
class FanEntity(ToggleEntity):
|
||||||
"""Representation of a fan."""
|
"""Representation of a fan."""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue