Skip to content

Commit

Permalink
Add async_setup_entry/async_unload_entry for remote platform (home-as…
Browse files Browse the repository at this point in the history
…sistant#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 <[email protected]>
  • Loading branch information
balloob and balloob authored Mar 5, 2020
1 parent daff87f commit 9a4aad1
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions homeassistant/components/remote/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
from datetime import timedelta
import functools as ft
import logging
from typing import Any, Iterable
from typing import Any, Iterable, cast

import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
SERVICE_TOGGLE,
SERVICE_TURN_OFF,
Expand Down Expand Up @@ -66,7 +67,9 @@ def is_on(hass: HomeAssistantType, entity_id: str) -> bool:

async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
"""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)

component.async_register_entity_service(
Expand Down Expand Up @@ -109,6 +112,18 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
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):
"""Representation of a remote."""

Expand Down

0 comments on commit 9a4aad1

Please sign in to comment.