Skip to content

IndexError: list index out of range in control_const.py split() crashes number/time platform setup #535

@mrvdb

Description

@mrvdb

split() in control_const.py contains an off-by-one error that causes IndexError when the SolisCloud API returns a value with fewer segments than expected. This crashes setup of the number and time platforms, leaving those entities unavailable and stopping the integration's polling loop entirely.

Affected version: v4.0.1 (current latest)

Error:

File "custom_components/solis/number.py", line 105, in do_update
    value = self.split(value)
  File "custom_components/solis/control_const.py", line 82, in split
    return values[self._index]
IndexError: list index out of range

Root cause: Line 81 uses <= instead of <:

# buggy
if self._index <= len(values):
    return values[self._index]  # IndexError when index == len(values)

Fix:

if self._index < len(values):
    return values[self._index]

Impact: When SolisCloud returns fewer split segments than expected for a register (e.g. during inverter startup or API hiccup), the entire integration stops updating. Sensors remain stale until a manual reload.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions