diff --git a/homeassistant/components/soma/__init__.py b/homeassistant/components/soma/__init__.py index 7172704c796..09576f07e6b 100644 --- a/homeassistant/components/soma/__init__.py +++ b/homeassistant/components/soma/__init__.py @@ -54,9 +54,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Soma from a config entry.""" hass.data[DOMAIN] = {} - hass.data[DOMAIN][API] = SomaApi(entry.data[HOST], entry.data[PORT]) - devices = await hass.async_add_executor_job(hass.data[DOMAIN][API].list_devices) - hass.data[DOMAIN][DEVICES] = devices["shades"] + api = await hass.async_add_executor_job(SomaApi, entry.data[HOST], entry.data[PORT]) + devices = await hass.async_add_executor_job(api.list_devices) + hass.data[DOMAIN] = {API: api, DEVICES: devices["shades"]} await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/soma/config_flow.py b/homeassistant/components/soma/config_flow.py index b696d583c04..a29b1b9bf9b 100644 --- a/homeassistant/components/soma/config_flow.py +++ b/homeassistant/components/soma/config_flow.py @@ -37,7 +37,13 @@ class SomaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_creation(self, user_input=None): """Finish config flow.""" - api = SomaApi(user_input["host"], user_input["port"]) + try: + api = await self.hass.async_add_executor_job( + SomaApi, user_input["host"], user_input["port"] + ) + except RequestException: + _LOGGER.error("Connection to SOMA Connect failed with RequestException") + return self.async_abort(reason="connection_error") try: result = await self.hass.async_add_executor_job(api.list_devices) _LOGGER.info("Successfully set up Soma Connect") diff --git a/homeassistant/components/soma/manifest.json b/homeassistant/components/soma/manifest.json index 39029199c29..b9fd5ef45f6 100644 --- a/homeassistant/components/soma/manifest.json +++ b/homeassistant/components/soma/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/soma", "codeowners": ["@ratsept", "@sebfortier2288"], - "requirements": ["pysoma==0.0.10"], + "requirements": ["pysoma==0.0.12"], "iot_class": "local_polling", "loggers": ["api"] } diff --git a/requirements_all.txt b/requirements_all.txt index 6aabb8e5ace..e10c82aa213 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1970,7 +1970,7 @@ pysnmplib==5.0.20 pysnooz==0.8.3 # homeassistant.components.soma -pysoma==0.0.10 +pysoma==0.0.12 # homeassistant.components.spc pyspcwebgw==0.4.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 54ee80e5fb3..3771c08f361 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1414,7 +1414,7 @@ pysnmplib==5.0.20 pysnooz==0.8.3 # homeassistant.components.soma -pysoma==0.0.10 +pysoma==0.0.12 # homeassistant.components.spc pyspcwebgw==0.4.0