Skip to content

Commit dc79d71

Browse files
tetiennefrenck
andauthored
Handle missing Somfy devices during update (home-assistant#44425)
* Handle missing devices during update * Raise error only if there was devices previously * Not final dot Co-authored-by: Franck Nijhof <[email protected]> Co-authored-by: Franck Nijhof <[email protected]>
1 parent fa69daf commit dc79d71

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

homeassistant/components/somfy/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from homeassistant.helpers.update_coordinator import (
2222
CoordinatorEntity,
2323
DataUpdateCoordinator,
24+
UpdateFailed,
2425
)
2526

2627
from . import api
@@ -92,6 +93,10 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
9293
async def _update_all_devices():
9394
"""Update all the devices."""
9495
devices = await hass.async_add_executor_job(data[API].get_devices)
96+
previous_devices = data[COORDINATOR].data
97+
# Sometimes Somfy returns an empty list.
98+
if not devices and previous_devices:
99+
raise UpdateFailed("No devices returned")
95100
return {dev.id: dev for dev in devices}
96101

97102
coordinator = DataUpdateCoordinator(

0 commit comments

Comments
 (0)