1 """Component for the Portuguese weather service - IPMA."""
6 from pyipma
import IPMAException
7 from pyipma.api
import IPMA_API
8 from pyipma.location
import Location
16 from .config_flow
import IpmaFlowHandler
17 from .const
import DATA_API, DATA_LOCATION, DOMAIN
21 PLATFORMS = [Platform.SENSOR, Platform.WEATHER]
23 _LOGGER = logging.getLogger(__name__)
27 """Set up IPMA station as config entry."""
29 latitude = config_entry.data[CONF_LATITUDE]
30 longitude = config_entry.data[CONF_LONGITUDE]
35 async
with asyncio.timeout(30):
36 location = await Location.get(api,
float(latitude),
float(longitude))
37 except (IPMAException, TimeoutError)
as err:
39 f
"Could not get location for ({latitude},{longitude})"
43 "Initializing for coordinates %s, %s -> station %s (%d, %d)",
48 location.global_id_local,
51 hass.data.setdefault(DOMAIN, {})
52 hass.data[DOMAIN][config_entry.entry_id] = {DATA_API: api, DATA_LOCATION: location}
54 await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
59 """Unload a config entry."""
61 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
62 hass.data[DOMAIN].pop(entry.entry_id)
64 if not hass.data[DOMAIN]:
bool async_setup_entry(HomeAssistant hass, ConfigEntry config_entry)
bool async_unload_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)