ITADN

Volvo integration doesnt work

#179708Closedjakobwaade87-lgtm 创建于 6 天前
integration: volvo
### The problem ## The problem The Volvo integration fails to set up entirely — every entity for the vehicle goes unavailable — because of an unhandled `AttributeError` while parsing the **diagnostics** endpoint response. Specifically, when the `serviceTrigger` field in the API response is `null`, the integration crashes trying to call `.items()` on it as though it were always a dictionary. Because this happens during the coordinator's *first refresh* (used for setup), the single crash causes `ConfigEntryNotReady`, which takes down the entire config entry — not just the diagnostics-related entities. All 72 entities for the vehicle (battery level, doors, locks, everything) went unavailable as a result, and stayed that way for 12+ hours until diagnosed. ## What version of Home Assistant Core has the issue? 2026.8.2 ## What was the last working version of Home Assistant Core? 2026.8.2 ## What type of installation are you running? Home Assistant OS 18.2 ## Integration causing the issue Volvo (official core integration) ## Link to integration documentation on our website https://www.home-assistant.io/integrations/volvo/ ## Diagnostics information <!-- Attach the diagnostics file you downloaded from the integration page, if you're comfortable sharing it (redact VIN/tokens first if it doesn't already) --> ## Example YAML snippet N/A — this is a core integration crash, not a YAML configuration issue. ## Anything in the logs that might be useful for us? The diagnostics API call itself succeeded (HTTP 200), and returned `'serviceTrigger': None` as part of the response: ``` 2026-08-21 07:10:18.011 DEBUG (MainThread) [volvocarsapi.api] Request [diagnostics] status: 200 2026-08-21 07:10:18.011 DEBUG (MainThread) [volvocarsapi.api] Request [diagnostics] response: {'data': {'distanceToService': {'timestamp': '2026-08-20T14:23:40.391239Z', 'unit': 'km', 'value': 26774}, 'engineHoursToService': {'timestamp': '2026-08-20T14:23:40.391239Z', 'unit': 'h', 'value': 500}, 'serviceTrigger': None, 'serviceWarning': {'timestamp': '2026-08-20T14:23:40.391239Z', 'unit': None, 'value': 'NO_WARNING'}, 'timeToService': {'timestamp': '2026-08-20T14:23:40.391239Z', 'unit': 'months', 'value': 21}, 'washerFluidLevelWarning': {'timestamp': '2026-08-20T14:23:40.391239Z', 'unit': None, 'value': 'NO_WARNING'}}} ``` Immediately after, parsing that response crashes: ``` 2026-08-21 07:10:18.013 DEBUG (MainThread) [homeassistant.components.volvo.coordinator] Finished fetching Volvo very slow interval coordinator data in 0.180 seconds (success: False) 2026-08-21 07:10:18.013 INFO (MainThread) [homeassistant.components.volvo] Config entry 'Volvo YV12ZEK99RS040760' for volvo integration not ready yet: update_failed; Retrying in 40 seconds 2026-08-21 07:10:18.013 DEBUG (MainThread) [homeassistant.components.volvo] Full exception Traceback (most recent call last): File "/usr/local/lib/python3.14/site-packages/volvocarsapi/api.py", line 125, in async_get_diagnostics return await self._async_get_field(_API_CONNECTED_ENDPOINT, "diagnostics", vin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.14/site-packages/volvocarsapi/api.py", line 327, in _async_get_field key: VolvoCarsValueField.from_dict(value) for key, value in data.items() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ File "/usr/local/lib/python3.14/site-packages/volvocarsapi/models.py", line 33, in from_dict for key, value in data.items(): ^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'items' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 435, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/volvo/coordinator.py", line 244, in _async_update_data data = await super()._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/volvo/coordinator.py", line 175, in _async_update_data raise UpdateFailed( ...<2 lines>... ) from result homeassistant.helpers.update_coordinator.UpdateFailed: update_failed The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 798, in __async_setup_with_context result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/volvo/__init__.py", line 60, in async_setup_entry await asyncio.gather( ...<9 lines>... ) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in async_config_entry_first_refresh await self._async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 360, in _async_config_entry_first_refresh raise ex homeassistant.exceptions.ConfigEntryNotReady: update_failed ``` ## Additional information - The bug is in `volvocarsapi/models.py`, `VolvoCarsValueField.from_dict()` (called from `api.py` line 327 inside `_async_get_field`) — it assumes every value in the API response dict is itself a dict and unconditionally calls `.items()` on it, with no `None` check. - This is data-driven, not a HA version regression: the integration had been working correctly for a long time before this started, which suggests Volvo's API began returning `serviceTrigger: null` for this vehicle (rather than omitting the field or returning a populated object), and the integration was never written to handle that case. - Because this single field's parsing failure raises out of the *first* coordinator refresh (used for setup via `async_config_entry_first_refresh`), it fails the entire config entry rather than just marking one entity unavailable — every entity for the vehicle (72 entities, including battery level, locks, doors, etc.) goes unavailable, not just diagnostics-related ones. - A safe fix would be for `VolvoCarsValueField.from_dict()` (or its caller in `_async_get_field`) to skip/return `None` for fields whose value is `None`, rather than assuming a populated dict. - This effectively means anyone whose vehicle's `serviceTrigger` (or potentially other diagnostics fields) comes back `null` from Volvo's API will have their entire integration silently break, with no way to recover other than a code fix — reloading the integration, re-authenticating, and restarting Home Assistant all fail identically since the underlying API response is unchanged. ### What version of Home Assistant Core has the issue? 2026.8.2 ### What was the last working version of Home Assistant Core? 2026.8.2 ### What type of installation are you running? Home Assistant OS ### Integration causing the issue Volvo ### Link to integration documentation on our website _No response_ ### Diagnostics information _No response_ ### Example YAML snippet ```yaml ``` ### Anything in the logs that might be useful for us? ```txt ``` ### Additional information _No response_
关闭于 6 天前 4 条评论