Add async_setup_entry/async_unload_entry for remote platform (#31974)

* add async_setup_entry for remote platform

* add async_unload_entry for remote platform

* Update __init__.py

* Update __init__.py

* Update __init__.py

* Update __init__.py

* Update __init__.py

* Update __init__.py

* Update __init__.py

* Type

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
Paulus Schoutsen 2020-03-04 18:09:17 -08:00 committed by GitHub
parent daff87fe5d
commit 9a4aad1777
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,10 +2,11 @@
from datetime import timedelta from datetime import timedelta
import functools as ft import functools as ft
import logging import logging
from typing import Any, Iterable from typing import Any, Iterable, cast
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
SERVICE_TOGGLE, SERVICE_TOGGLE,
SERVICE_TURN_OFF, SERVICE_TURN_OFF,
@ -66,7 +67,9 @@ def is_on(hass: HomeAssistantType, entity_id: str) -> bool:
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
"""Track states and offer events for remotes.""" """Track states and offer events for remotes."""
component = EntityComponent(_LOGGER, DOMAIN, hass, SCAN_INTERVAL) component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config) await component.async_setup(config)
component.async_register_entity_service( component.async_register_entity_service(
@ -109,6 +112,18 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
return True return True
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return cast(
bool, await cast(EntityComponent, hass.data[DOMAIN]).async_setup_entry(entry)
)
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await cast(EntityComponent, hass.data[DOMAIN]).async_unload_entry(entry)
class RemoteDevice(ToggleEntity): class RemoteDevice(ToggleEntity):
"""Representation of a remote.""" """Representation of a remote."""