Skip to content

IndexError on retrieving temperature data #130

@Morg42

Description

@Morg42

Hi,

I'm running an E3/DC S10E, pye3dc 0.9.2 and e3dc_to_mqtt 0.0.19. Periodically, I get exceptions:

2025-10-05 20:59:16:ERROR: exception in main loop
Traceback (most recent call last):
  File "/usr/local/e3dc/e3dc_to_mqtt/e3dc_to_mqtt_base.py", line 164, in run
    battery_data = await self.e3dc.get_battery_data()
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/e3dc/e3dc_to_mqtt/e3dc_to_mqtt_base.py", line 299, in get_battery_data
    battery_data = self.__e3dc.get_battery_data(batIndex=i)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sh/.venvs/3.11/lib/python3.11/site-packages/e3dc/_e3dc.py", line 1563, in get_battery_data
    temperatures.append(temperatures_data[sensor][2])
                                    ~~~~~~~~~~~~~~~~~^^^^^^^^
IndexError: list index out of range

The program crashes when sensor becomes 5. I tried printing the temperature_raw and info data:

info:

returning BAT_DCB_NR_SENSOR as 35,

temperatures_raw:
('BAT_DCB_ALL_CELL_TEMPERATURES', 'Container', [('BAT_DCB_INDEX', 'Int32', 2), ('BAT_DATA', 'Container', [('BAT_DCB_CELL_TEMPERATURE', 'Float32', 27.600000381469727), ('BAT_DCB_CELL_TEMPERATURE', 'Float32', 30.200000762939453), ('BAT_DCB_CELL_TEMPERATURE', 'Float32', 30.600000381469727), ('BAT_DCB_CELL_TEMPERATURE', 'Float32', 28.600000381469727), ('BAT_DCB_CELL_TEMPERATURE', 'Float32', 29.0)])])

returning only 4 measure values.

I changed the code to hard return -1 if sensor > len(temperatures_data), but this doesn't seem right.

Any ideas what creates this error? (Do I really have 35 (36?) temperature sensors with 3 battery packs?)

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