1 """Support for Roku."""
3 from __future__
import annotations
9 from .const
import CONF_PLAY_MEDIA_APP_ID, DEFAULT_PLAY_MEDIA_APP_ID, DOMAIN
10 from .coordinator
import RokuDataUpdateCoordinator
13 Platform.BINARY_SENSOR,
14 Platform.MEDIA_PLAYER,
22 """Set up Roku from a config entry."""
23 if (device_id := entry.unique_id)
is None:
24 device_id = entry.entry_id
28 host=entry.data[CONF_HOST],
30 play_media_app_id=entry.options.get(
31 CONF_PLAY_MEDIA_APP_ID, DEFAULT_PLAY_MEDIA_APP_ID
34 await coordinator.async_config_entry_first_refresh()
36 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
38 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
40 entry.async_on_unload(entry.add_update_listener(async_reload_entry))
46 """Unload a config entry."""
47 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
48 hass.data[DOMAIN].pop(entry.entry_id)
53 """Reload the config entry when it changed."""
54 await hass.config_entries.async_reload(entry.entry_id)
None async_reload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)