1 """Support for Soma Smartshades."""
3 from __future__
import annotations
5 from api.soma_api
import SomaApi
6 import voluptuous
as vol
8 from homeassistant
import config_entries
15 from .const
import API, DEVICES, DOMAIN, HOST, PORT
17 CONFIG_SCHEMA = vol.Schema(
19 cv.deprecated(DOMAIN),
22 {vol.Required(CONF_HOST): cv.string, vol.Required(CONF_PORT): cv.string}
26 extra=vol.ALLOW_EXTRA,
29 PLATFORMS = [Platform.COVER, Platform.SENSOR]
32 async
def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
33 """Set up the Soma component."""
34 if DOMAIN
not in config:
37 hass.async_create_task(
38 hass.config_entries.flow.async_init(
41 context={
"source": config_entries.SOURCE_IMPORT},
49 """Set up Soma from a config entry."""
50 hass.data[DOMAIN] = {}
51 api = await hass.async_add_executor_job(SomaApi, entry.data[HOST], entry.data[PORT])
52 devices = await hass.async_add_executor_job(api.list_devices)
53 hass.data[DOMAIN] = {API: api, DEVICES: devices[
"shades"]}
55 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
61 """Unload a config entry."""
62 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup(HomeAssistant hass, ConfigType config)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)