Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The Sky Remote Control integration."""
2 
3 import logging
4 
5 from skyboxremote import RemoteControl, SkyBoxConnectionError
6 
7 from homeassistant.config_entries import ConfigEntry
8 from homeassistant.const import CONF_HOST, CONF_PORT, Platform
9 from homeassistant.core import HomeAssistant
10 from homeassistant.exceptions import ConfigEntryNotReady
11 
12 PLATFORMS = [Platform.REMOTE]
13 
14 _LOGGER = logging.getLogger(__name__)
15 
16 
17 type SkyRemoteConfigEntry = ConfigEntry[RemoteControl]
18 
19 
20 async def async_setup_entry(hass: HomeAssistant, entry: SkyRemoteConfigEntry) -> bool:
21  """Set up Sky remote."""
22  host = entry.data[CONF_HOST]
23  port = entry.data[CONF_PORT]
24 
25  _LOGGER.debug("Setting up Host: %s, Port: %s", host, port)
26  remote = RemoteControl(host, port)
27  try:
28  await remote.check_connectable()
29  except SkyBoxConnectionError as e:
30  raise ConfigEntryNotReady from e
31 
32  entry.runtime_data = remote
33  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
34  return True
35 
36 
37 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
38  """Unload a config entry."""
39  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:37
bool async_setup_entry(HomeAssistant hass, SkyRemoteConfigEntry entry)
Definition: __init__.py:20