ha-2gis-weather/custom_components/two_gis_weather/__init__.py
2025-11-04 11:21:01 +06:00

29 lines
936 B
Python

from __future__ import annotations
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from .const import DOMAIN, PLATFORMS
from .coordinator import TwoGisWeatherUpdateCoordinator
async def async_setup(hass: HomeAssistant, _config: dict) -> bool:
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
coordinator = TwoGisWeatherUpdateCoordinator(hass, entry)
await coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data.get(DOMAIN, {}).pop(entry.entry_id, None)
return unload_ok