mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
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:
parent
daff87fe5d
commit
9a4aad1777
@ -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,
|
||||
@ -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(
|
||||
@ -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."""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user