1 """The launch_library component."""
3 from __future__
import annotations
5 from datetime
import timedelta
7 from typing
import TypedDict
9 from pylaunches
import PyLaunches, PyLaunchesError
10 from pylaunches.types
import Launch, StarshipResponse
18 from .const
import DOMAIN
20 _LOGGER = logging.getLogger(__name__)
22 PLATFORMS = [Platform.SENSOR]
26 """Typed dict representation of data returned from pylaunches."""
28 upcoming_launches: list[Launch]
29 starship_events: StarshipResponse
33 """Set up this integration using UI."""
35 hass.data.setdefault(DOMAIN, {})
38 launches = PyLaunches(session)
43 upcoming_launches=await launches.launch_upcoming(
44 filters={
"limit": 1,
"hide_recent_previous":
"True"},
46 starship_events=await launches.dashboard_starship(),
48 except PyLaunchesError
as ex:
56 update_method=async_update,
60 await coordinator.async_config_entry_first_refresh()
62 hass.data[DOMAIN] = coordinator
64 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
70 """Handle removal of an entry."""
71 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)