1 """The iss component."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
6 from datetime
import timedelta
11 from requests.exceptions
import HTTPError
18 from .const
import DOMAIN
20 _LOGGER = logging.getLogger(__name__)
22 PLATFORMS = [Platform.SENSOR]
27 """Dataclass representation of data returned from pyiss."""
29 number_of_people_in_space: int
30 current_location: dict[str, str]
33 def update(iss: pyiss.ISS) -> IssData:
34 """Retrieve data from the pyiss API."""
36 number_of_people_in_space=iss.number_of_people_in_space(),
37 current_location=iss.current_location(),
42 """Set up this integration using UI."""
43 hass.data.setdefault(DOMAIN, {})
49 return await hass.async_add_executor_job(update, iss)
50 except (HTTPError, requests.exceptions.ConnectionError)
as ex:
58 update_method=async_update,
62 await coordinator.async_config_entry_first_refresh()
64 hass.data[DOMAIN] = coordinator
66 entry.async_on_unload(entry.add_update_listener(update_listener))
68 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
74 """Handle removal of an entry."""
75 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
81 """Handle options update."""
82 await hass.config_entries.async_reload(entry.entry_id)
IssData update(pyiss.ISS iss)
None update_listener(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)