Coordinator fetches device statuses sequentially (performance bug for multi-device setups) #1

Closed
opened 2026-05-09 05:09:47 +00:00 by Mark · 1 comment
Owner

Severity: Medium (performance)

File: custom_components/yeedi/coordinator.py, lines 35-39

Issue: In _async_update_data, the coordinator iterates over devices and awaits each async_get_device_status call sequentially:

for device in devices:
    if device.status is not None:
        statuses[device.device_id] = device.status
        continue
    statuses[device.device_id] = await self._client.async_get_device_status(device.device_id)

If a user has multiple Yeedi devices, each status fetch blocks the next. For N devices with ~500ms API latency each, the total poll time grows linearly, potentially causing coordinator timeouts.

Fix: Use asyncio.gather or asyncio.as_completed to fetch statuses concurrently:

futures = {
    device.device_id: self._client.async_get_device_status(device.device_id)
    for device in devices
}
results = await asyncio.gather(*futures.values(), return_exceptions=True)
**Severity:** Medium (performance) **File:** `custom_components/yeedi/coordinator.py`, lines 35-39 **Issue:** In `_async_update_data`, the coordinator iterates over devices and awaits each `async_get_device_status` call sequentially: ```python for device in devices: if device.status is not None: statuses[device.device_id] = device.status continue statuses[device.device_id] = await self._client.async_get_device_status(device.device_id) ``` If a user has multiple Yeedi devices, each status fetch blocks the next. For N devices with ~500ms API latency each, the total poll time grows linearly, potentially causing coordinator timeouts. **Fix:** Use `asyncio.gather` or `asyncio.as_completed` to fetch statuses concurrently: ```python futures = { device.device_id: self._client.async_get_device_status(device.device_id) for device in devices } results = await asyncio.gather(*futures.values(), return_exceptions=True) ```
Author
Owner

Fixed in commit. Closing.

Fixed in commit. Closing.
Mark closed this issue 2026-05-12 01:33:40 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/yeedi_awmbuild#1
No description provided.