1 """The openhome component."""
6 from async_upnp_client.client
import UpnpError
7 from openhomedevice.device
import Device
15 from .const
import DOMAIN
17 _LOGGER = logging.getLogger(__name__)
19 PLATFORMS = [Platform.MEDIA_PLAYER, Platform.UPDATE]
21 CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
25 """Cleanup before removing config entry."""
26 unload_ok = await hass.config_entries.async_unload_platforms(
27 config_entry, PLATFORMS
29 hass.data[DOMAIN].pop(config_entry.entry_id)
36 config_entry: ConfigEntry,
38 """Set up the configuration config entry."""
39 _LOGGER.debug(
"Setting up config entry: %s", config_entry.unique_id)
41 device = await hass.async_add_executor_job(Device, config_entry.data[CONF_HOST])
45 except (TimeoutError, aiohttp.ClientError, UpnpError)
as exc:
46 raise ConfigEntryNotReady
from exc
48 _LOGGER.debug(
"Initialised device: %s", device.uuid())
50 hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = device
52 await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
bool async_unload_entry(HomeAssistant hass, ConfigEntry config_entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry config_entry)