diff --git a/homeassistant/components/shelly/__init__.py b/homeassistant/components/shelly/__init__.py index 184b7c8bb6b..75f66d0bced 100644 --- a/homeassistant/components/shelly/__init__.py +++ b/homeassistant/components/shelly/__init__.py @@ -174,10 +174,13 @@ async def _async_setup_block_entry( await device.initialize() if not device.firmware_supported: async_create_issue_unsupported_firmware(hass, entry) + await device.shutdown() raise ConfigEntryNotReady except (DeviceConnectionError, MacAddressMismatchError) as err: + await device.shutdown() raise ConfigEntryNotReady(repr(err)) from err except InvalidAuthError as err: + await device.shutdown() raise ConfigEntryAuthFailed(repr(err)) from err runtime_data.block = ShellyBlockCoordinator(hass, entry, device) @@ -247,10 +250,13 @@ async def _async_setup_rpc_entry(hass: HomeAssistant, entry: ShellyConfigEntry) await device.initialize() if not device.firmware_supported: async_create_issue_unsupported_firmware(hass, entry) + await device.shutdown() raise ConfigEntryNotReady except (DeviceConnectionError, MacAddressMismatchError) as err: + await device.shutdown() raise ConfigEntryNotReady(repr(err)) from err except InvalidAuthError as err: + await device.shutdown() raise ConfigEntryAuthFailed(repr(err)) from err runtime_data.rpc = ShellyRpcCoordinator(hass, entry, device) diff --git a/homeassistant/components/shelly/config_flow.py b/homeassistant/components/shelly/config_flow.py index c044d032170..cb3bca6aa47 100644 --- a/homeassistant/components/shelly/config_flow.py +++ b/homeassistant/components/shelly/config_flow.py @@ -102,10 +102,11 @@ async def validate_input( ws_context, options, ) - await rpc_device.initialize() - await rpc_device.shutdown() - - sleep_period = get_rpc_device_wakeup_period(rpc_device.status) + try: + await rpc_device.initialize() + sleep_period = get_rpc_device_wakeup_period(rpc_device.status) + finally: + await rpc_device.shutdown() return { "title": rpc_device.name, @@ -121,11 +122,15 @@ async def validate_input( coap_context, options, ) - await block_device.initialize() - await block_device.shutdown() + try: + await block_device.initialize() + sleep_period = get_block_device_sleep_period(block_device.settings) + finally: + await block_device.shutdown() + return { "title": block_device.name, - CONF_SLEEP_PERIOD: get_block_device_sleep_period(block_device.settings), + CONF_SLEEP_PERIOD: sleep_period, "model": block_device.model, CONF_GEN: gen, } diff --git a/homeassistant/components/shelly/manifest.json b/homeassistant/components/shelly/manifest.json index b1b00e40c66..4076f53c28c 100644 --- a/homeassistant/components/shelly/manifest.json +++ b/homeassistant/components/shelly/manifest.json @@ -9,7 +9,7 @@ "iot_class": "local_push", "loggers": ["aioshelly"], "quality_scale": "platinum", - "requirements": ["aioshelly==10.0.1"], + "requirements": ["aioshelly==11.0.0"], "zeroconf": [ { "type": "_http._tcp.local.", diff --git a/requirements_all.txt b/requirements_all.txt index e2fe45139de..8781c83f901 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -362,7 +362,7 @@ aioruuvigateway==0.1.0 aiosenz==1.0.0 # homeassistant.components.shelly -aioshelly==10.0.1 +aioshelly==11.0.0 # homeassistant.components.skybell aioskybell==22.7.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index f1c5d8553db..eee7bd70159 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -335,7 +335,7 @@ aioruuvigateway==0.1.0 aiosenz==1.0.0 # homeassistant.components.shelly -aioshelly==10.0.1 +aioshelly==11.0.0 # homeassistant.components.skybell aioskybell==22.7.0