This commit is contained in:
Samuel Spagl 2024-03-12 15:06:44 +01:00 committed by GitHub
commit 525da9b555
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,12 @@
# 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
### Added

View File

@ -1,7 +1,9 @@
import logging
from aiohttp import ClientResponseError
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import DOMAIN, HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession
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_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(
entry.data, soundbar_device
)

View File

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