Skip to content

Commit 0276725

Browse files
authored
fixed battery temp sensor fail (#132)
* fixed battery temp sensor fail
1 parent 3ad1b55 commit 0276725

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

e3dc/_e3dc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,11 @@ def get_battery_data(
15681568
):
15691569
temperatures_data = rscpFindTagIndex(temperatures_raw, RscpTag.BAT_DATA)
15701570
sensorCount = rscpFindTagIndex(info, RscpTag.BAT_DCB_NR_SENSOR)
1571-
for sensor in range(0, sensorCount):
1571+
1572+
# As sensorCount can return bigger values than we have actual temperatures_data,
1573+
# we use the smaller count for robustness.
1574+
sensors = min(sensorCount, len(temperatures_data))
1575+
for sensor in range(0, sensors):
15721576
temperatures.append(temperatures_data[sensor][2])
15731577

15741578
# Set voltages, if available for the device

0 commit comments

Comments
 (0)