1 """The AccuWeather component."""
3 from __future__
import annotations
7 from accuweather
import AccuWeather
15 from .const
import DOMAIN, UPDATE_INTERVAL_DAILY_FORECAST, UPDATE_INTERVAL_OBSERVATION
16 from .coordinator
import (
17 AccuWeatherConfigEntry,
18 AccuWeatherDailyForecastDataUpdateCoordinator,
20 AccuWeatherObservationDataUpdateCoordinator,
23 _LOGGER = logging.getLogger(__name__)
25 PLATFORMS = [Platform.SENSOR, Platform.WEATHER]
29 """Set up AccuWeather as config entry."""
30 api_key: str = entry.data[CONF_API_KEY]
31 name: str = entry.data[CONF_NAME]
33 location_key = entry.unique_id
35 _LOGGER.debug(
"Using location_key: %s", location_key)
38 accuweather = AccuWeather(api_key, websession, location_key=location_key)
46 UPDATE_INTERVAL_OBSERVATION,
55 UPDATE_INTERVAL_DAILY_FORECAST,
58 await coordinator_observation.async_config_entry_first_refresh()
59 await coordinator_daily_forecast.async_config_entry_first_refresh()
62 coordinator_observation=coordinator_observation,
63 coordinator_daily_forecast=coordinator_daily_forecast,
66 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
69 ent_reg = er.async_get(hass)
71 unique_id = f
"{location_key}-ozone-{day}"
72 if entity_id := ent_reg.async_get_entity_id(SENSOR_PLATFORM, DOMAIN, unique_id):
73 _LOGGER.debug(
"Removing ozone sensor entity %s", entity_id)
74 ent_reg.async_remove(entity_id)
80 hass: HomeAssistant, entry: AccuWeatherConfigEntry
82 """Unload a config entry."""
83 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, AccuWeatherConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, AccuWeatherConfigEntry 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)