1 """The met component."""
3 from __future__
import annotations
14 DEFAULT_HOME_LATITUDE,
15 DEFAULT_HOME_LONGITUDE,
18 from .coordinator
import MetDataUpdateCoordinator
20 PLATFORMS = [Platform.WEATHER]
22 _LOGGER = logging.getLogger(__name__)
24 type MetWeatherConfigEntry = ConfigEntry[MetDataUpdateCoordinator]
28 hass: HomeAssistant, config_entry: MetWeatherConfigEntry
30 """Set up Met as config entry."""
33 if config_entry.data.get(CONF_TRACK_HOME,
False)
and (
34 (
not hass.config.latitude
and not hass.config.longitude)
36 hass.config.latitude == DEFAULT_HOME_LATITUDE
37 and hass.config.longitude == DEFAULT_HOME_LONGITUDE
41 "Skip setting up met.no integration; No Home location has been set"
46 await coordinator.async_config_entry_first_refresh()
48 if config_entry.data.get(CONF_TRACK_HOME,
False):
49 coordinator.track_home()
51 config_entry.runtime_data = coordinator
53 config_entry.async_on_unload(config_entry.add_update_listener(async_update_entry))
54 config_entry.async_on_unload(coordinator.untrack_home)
56 await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
64 hass: HomeAssistant, config_entry: MetWeatherConfigEntry
66 """Unload a config entry."""
67 return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
71 """Reload Met component when options changed."""
72 await hass.config_entries.async_reload(config_entry.entry_id)
76 """Cleanup device without proper device identifier."""
77 device_reg = dr.async_get(hass)
78 device = device_reg.async_get_device(identifiers={(DOMAIN,)})
80 _LOGGER.debug(
"Removing improper device %s", device.name)
81 device_reg.async_remove_device(device.id)
bool async_setup_entry(HomeAssistant hass, MetWeatherConfigEntry config_entry)
bool async_unload_entry(HomeAssistant hass, MetWeatherConfigEntry config_entry)
None cleanup_old_device(HomeAssistant hass)
def async_update_entry(HomeAssistant hass, MetWeatherConfigEntry config_entry)