mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Handle missing Somfy devices during update (#44425)
* Handle missing devices during update * Raise error only if there was devices previously * Not final dot Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
fa69daf5b3
commit
dc79d71f39
@ -21,6 +21,7 @@ from homeassistant.helpers.typing import HomeAssistantType
|
|||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
|
UpdateFailed,
|
||||||
)
|
)
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
@ -92,6 +93,10 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
|||||||
async def _update_all_devices():
|
async def _update_all_devices():
|
||||||
"""Update all the devices."""
|
"""Update all the devices."""
|
||||||
devices = await hass.async_add_executor_job(data[API].get_devices)
|
devices = await hass.async_add_executor_job(data[API].get_devices)
|
||||||
|
previous_devices = data[COORDINATOR].data
|
||||||
|
# Sometimes Somfy returns an empty list.
|
||||||
|
if not devices and previous_devices:
|
||||||
|
raise UpdateFailed("No devices returned")
|
||||||
return {dev.id: dev for dev in devices}
|
return {dev.id: dev for dev in devices}
|
||||||
|
|
||||||
coordinator = DataUpdateCoordinator(
|
coordinator = DataUpdateCoordinator(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user