Description
Pressing the Restablecer (Soft reset) button on the device throws an unhandled IndexError when consumptions_daily_sum is empty.
This happens in installs where Datadis hasn't returned consumption data yet — for example, when contracts lookup fails (contracts update failed or no contracts found in the provided account) and the user tries to recover by hitting Restablecer.
Setup
- Home Assistant Core: 2026.4.4
- HAOS: 17.2
- edata: 2025.11.3
Stack trace
File "/config/custom_components/edata/entity.py", line 78, in async_press
await self._action()
File "/config/custom_components/edata/coordinator.py", line 754, in async_soft_reset
if not await self.check_statistics_integrity():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/edata/coordinator.py", line 317, in check_statistics_integrity
self._edata.data["consumptions_daily_sum"][0]["datetime"]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
The UI surfaces this as the toast: No se pudo realizar la acción button/press. list index out of range.
Steps to reproduce
- Install edata.
- Configure Datadis credentials such that the account returns no contracts (e.g., NIF authorization not yet propagated).
- Wait for the integration to log
contracts update failed or no contracts found in the provided account.
- Press the Restablecer button on the edata device.
Expected behavior
check_statistics_integrity() should handle the empty-list case gracefully (skip the integrity check, or return early with a meaningful log line) instead of raising IndexError. Bonus: the button itself could show a friendlier "no data to reset" message in the toast.
Suggested fix
Guard the access at coordinator.py:317:
daily_sum = self._edata.data.get("consumptions_daily_sum") or []
if not daily_sum:
_LOGGER.warning("No consumption data yet; skipping integrity check")
return True # or False, depending on intended semantics
first_dt = daily_sum[0]["datetime"]
Notes
Description
Pressing the Restablecer (Soft reset) button on the device throws an unhandled
IndexErrorwhenconsumptions_daily_sumis empty.This happens in installs where Datadis hasn't returned consumption data yet — for example, when contracts lookup fails (
contracts update failed or no contracts found in the provided account) and the user tries to recover by hitting Restablecer.Setup
Stack trace
The UI surfaces this as the toast:
No se pudo realizar la acción button/press. list index out of range.Steps to reproduce
contracts update failed or no contracts found in the provided account.Expected behavior
check_statistics_integrity()should handle the empty-list case gracefully (skip the integrity check, or return early with a meaningful log line) instead of raisingIndexError. Bonus: the button itself could show a friendlier "no data to reset" message in the toast.Suggested fix
Guard the access at
coordinator.py:317:Notes