2018-10-08 21:54:55 +00:00
|
|
|
"""
|
2018-11-13 09:01:14 +00:00
|
|
|
Component for the Swedish weather institute weather service.
|
2018-10-08 21:54:55 +00:00
|
|
|
|
|
|
|
For more details about this component, please refer to the documentation at
|
|
|
|
https://home-assistant.io/components/smhi/
|
|
|
|
"""
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
|
|
from homeassistant.core import Config, HomeAssistant
|
|
|
|
|
2018-11-13 09:01:14 +00:00
|
|
|
# Have to import for config_flow to work even if they are not used here
|
2018-10-08 21:54:55 +00:00
|
|
|
from .config_flow import smhi_locations # noqa: F401
|
|
|
|
from .const import DOMAIN # noqa: F401
|
|
|
|
|
2019-02-05 12:43:04 +00:00
|
|
|
REQUIREMENTS = ['smhi-pkg==1.0.8']
|
2018-10-08 21:54:55 +00:00
|
|
|
|
|
|
|
DEFAULT_NAME = 'smhi'
|
|
|
|
|
|
|
|
|
|
|
|
async def async_setup(hass: HomeAssistant, config: Config) -> bool:
|
2018-11-13 09:01:14 +00:00
|
|
|
"""Set up configured SMHI."""
|
2018-10-08 21:54:55 +00:00
|
|
|
# We allow setup only through config flow type of config
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2018-11-13 09:01:14 +00:00
|
|
|
async def async_setup_entry(
|
|
|
|
hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
|
|
|
"""Set up SMHI forecast as config entry."""
|
2018-10-08 21:54:55 +00:00
|
|
|
hass.async_create_task(hass.config_entries.async_forward_entry_setup(
|
|
|
|
config_entry, 'weather'))
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2018-11-13 09:01:14 +00:00
|
|
|
async def async_unload_entry(
|
|
|
|
hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
2018-10-08 21:54:55 +00:00
|
|
|
"""Unload a config entry."""
|
|
|
|
await hass.config_entries.async_forward_entry_unload(
|
|
|
|
config_entry, 'weather')
|
|
|
|
return True
|