mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Move creation of DeviceInfo outside try statement in SMA (#59821)
This commit is contained in:
parent
5133269e2b
commit
ac96c7bb1f
@ -145,6 +145,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
try:
|
try:
|
||||||
# Get updated device info
|
# Get updated device info
|
||||||
sma_device_info = await sma.device_info()
|
sma_device_info = await sma.device_info()
|
||||||
|
# Get all device sensors
|
||||||
|
sensor_def = await sma.get_sensors()
|
||||||
|
except (
|
||||||
|
pysma.exceptions.SmaReadException,
|
||||||
|
pysma.exceptions.SmaConnectionException,
|
||||||
|
) as exc:
|
||||||
|
raise ConfigEntryNotReady from exc
|
||||||
|
|
||||||
|
# Create DeviceInfo object from sma_device_info
|
||||||
device_info = DeviceInfo(
|
device_info = DeviceInfo(
|
||||||
configuration_url=url,
|
configuration_url=url,
|
||||||
identifiers={(DOMAIN, entry.unique_id)},
|
identifiers={(DOMAIN, entry.unique_id)},
|
||||||
@ -153,13 +162,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
name=sma_device_info["name"],
|
name=sma_device_info["name"],
|
||||||
sw_version=sma_device_info["sw_version"],
|
sw_version=sma_device_info["sw_version"],
|
||||||
)
|
)
|
||||||
# Get all device sensors
|
|
||||||
sensor_def = await sma.get_sensors()
|
|
||||||
except (
|
|
||||||
pysma.exceptions.SmaReadException,
|
|
||||||
pysma.exceptions.SmaConnectionException,
|
|
||||||
) as exc:
|
|
||||||
raise ConfigEntryNotReady from exc
|
|
||||||
|
|
||||||
# Parse legacy options if initial setup was done from yaml
|
# Parse legacy options if initial setup was done from yaml
|
||||||
if entry.source == SOURCE_IMPORT:
|
if entry.source == SOURCE_IMPORT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user