Compare commits

...

1 Commits

Author SHA1 Message Date
samuelspagl 2c278da442 Add `ConfigEntryNotReady` exception when the update during setup fails 2024-03-12 15:04:30 +01:00
3 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## [0.3.1] Let HomeAssistant schedule failing setup of integration
### Added
- Add a `try / catch` mechanism to the first update of the client while setup and throw a
`ConfigEntryNotReady` exception when the update fails
## [0.3.0] Icons and Chore ## [0.3.0] Icons and Chore
### Added ### Added

View File

@ -1,7 +1,9 @@
import logging import logging
from aiohttp import ClientResponseError
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import DOMAIN, HomeAssistant from homeassistant.core import DOMAIN, HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from pysmartthings import SmartThings from pysmartthings import SmartThings
@ -49,7 +51,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entry.data.get(CONF_ENTRY_MAX_VOLUME), entry.data.get(CONF_ENTRY_MAX_VOLUME),
entry.data.get(CONF_ENTRY_DEVICE_NAME), entry.data.get(CONF_ENTRY_DEVICE_NAME),
) )
await soundbar_device.update() try:
await soundbar_device.update()
except ClientResponseError as excp:
raise ConfigEntryNotReady("An error occurred while setting up the soundbar device. "
"Please recheck whether the device has power or is connected to the internet.")\
from excp
domain_config.devices[entry.data.get(CONF_ENTRY_DEVICE_ID)] = DeviceConfig( domain_config.devices[entry.data.get(CONF_ENTRY_DEVICE_ID)] = DeviceConfig(
entry.data, soundbar_device entry.data, soundbar_device
) )

View File

@ -8,5 +8,5 @@
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"issue_tracker": "https://github.com/samuelspagl/ha_samsung_soundbar/issues", "issue_tracker": "https://github.com/samuelspagl/ha_samsung_soundbar/issues",
"requirements": ["pysmartthings"], "requirements": ["pysmartthings"],
"version": "0.3.0" "version": "0.3.1"
} }