|
8 | 8 | import logging |
9 | 9 | from typing import Any |
10 | 10 |
|
| 11 | +import aiohttp |
| 12 | + |
11 | 13 | from homeassistant.config_entries import ConfigEntry |
12 | 14 | from homeassistant.core import CALLBACK_TYPE |
13 | 15 | from homeassistant.core import HomeAssistant |
@@ -315,14 +317,31 @@ async def _async_update_data(self): |
315 | 317 | utc_point_in_time = dt_util.utcnow() |
316 | 318 | # Send list client requests in parallel for each deco |
317 | 319 |
|
318 | | - deco_client_responses = await asyncio.gather( |
319 | | - *[ |
320 | | - async_call_and_propagate_config_error( |
321 | | - self.api.async_list_clients, deco_mac |
322 | | - ) |
323 | | - for deco_mac in deco_macs |
| 320 | + try: |
| 321 | + deco_client_responses = await asyncio.gather( |
| 322 | + *[ |
| 323 | + async_call_and_propagate_config_error( |
| 324 | + self.api.async_list_clients, deco_mac |
| 325 | + ) |
| 326 | + for deco_mac in deco_macs |
| 327 | + ] |
| 328 | + ) |
| 329 | + except aiohttp.ClientResponseError as err: |
| 330 | + if err.status < 500: |
| 331 | + raise |
| 332 | + # Some Deco firmware (e.g. XE75 1.3.x) returns a 5xx (502 observed) |
| 333 | + # for the per-node client_list query. Fall back to a single global |
| 334 | + # query and attribute every client to the master Deco, so its |
| 335 | + # client-count sensor reflects the whole mesh (satellites report 0). |
| 336 | + _LOGGER.debug( |
| 337 | + "Per-node client_list failed (%s); falling back to global query", |
| 338 | + err, |
| 339 | + ) |
| 340 | + master_deco = self._deco_update_coordinator.data.master_deco |
| 341 | + deco_macs = [master_deco.mac if master_deco is not None else "default"] |
| 342 | + deco_client_responses = [ |
| 343 | + await async_call_and_propagate_config_error(self.api.async_list_clients) |
324 | 344 | ] |
325 | | - ) |
326 | 345 |
|
327 | 346 | if len(deco_client_responses) > 0: |
328 | 347 | # deco_macs is not subscriptable, must be iterated |
|
0 commit comments