2019-02-13 20:21:14 +00:00
|
|
|
"""Support for the Swedish weather institute weather service."""
|
2018-10-08 21:54:55 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
2022-01-15 19:01:48 +00:00
|
|
|
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, Platform
|
2021-04-16 16:22:56 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2018-10-08 21:54:55 +00:00
|
|
|
|
2021-12-04 12:43:48 +00:00
|
|
|
PLATFORMS = [Platform.WEATHER]
|
2018-10-08 21:54:55 +00:00
|
|
|
|
2021-04-27 20:10:04 +00:00
|
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
2018-11-13 09:01:14 +00:00
|
|
|
"""Set up SMHI forecast as config entry."""
|
2022-01-15 19:01:48 +00:00
|
|
|
|
|
|
|
# Setting unique id where missing
|
|
|
|
if entry.unique_id is None:
|
|
|
|
unique_id = f"{entry.data[CONF_LATITUDE]}-{entry.data[CONF_LONGITUDE]}"
|
|
|
|
hass.config_entries.async_update_entry(entry, unique_id=unique_id)
|
|
|
|
|
2021-04-27 20:10:04 +00:00
|
|
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
2018-10-08 21:54:55 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
|
2021-04-27 20:10:04 +00:00
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
2018-10-08 21:54:55 +00:00
|
|
|
"""Unload a config entry."""
|
2021-04-27 20:10:04 +00:00
|
|
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|