homeassistant-peloton-sensor icon indicating copy to clipboard operation
homeassistant-peloton-sensor copied to clipboard

Peloton errors when starting workout

Open RogerSelwyn opened this issue 2 years ago • 4 comments

Whenever I start a workout I get a number of the errors below in my logs. Not doing anything special. It is a Peloton Plus with which I'm using an Apple Watch for heart rate monitoring.

I'm using HA 2011.11.2 and Peloton 0.10.0.

2023-11-11 10:54:57.760 ERROR (MainThread) [custom_components.peloton] Unexpected error fetching peloton data: list index out of range
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 246, in _async_update_data
return await self.update_method()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/peloton/__init__.py", line 79, in async_update_data
"quant_data": compile_quant_data(
^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/peloton/__init__.py", line 278, in compile_quant_data
if isinstance((value := metric.get("values")[len(metric.get("values"))-1]), int)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range

At some point I'll try to set up in my dev environment to debug. Looking at that line of code, I'd anticipate that the "values" list is empty, and it is trying to get item '-1' from it.

RogerSelwyn avatar Nov 11 '23 13:11 RogerSelwyn

This looks to be a duplicate of these:

  • https://github.com/edwork/homeassistant-peloton-sensor/issues/88
  • https://github.com/edwork/homeassistant-peloton-sensor/issues/85

and possibly this:

  • https://github.com/edwork/homeassistant-peloton-sensor/issues/61
  • https://github.com/edwork/homeassistant-peloton-sensor/issues/60

I'm currently testing changes which include a if len(metric.get("values")) > 0 and at the start of each metric retrieval. When I added it to the output metric I then got the same error at line 260 for cadence. So I've added to speed, resistance and heart_rate as well. I'll wait to my next ride to see if it fixes it.

RogerSelwyn avatar Nov 11 '23 17:11 RogerSelwyn

note sure if this is linked?

Core 2024.1.3 Supervisor 2023.12.0 Operating System 11.4 Frontend 20240104.0

This error originated from a custom integration.

Logger: custom_components.peloton Source: helpers/update_coordinator.py:300 Integration: Peloton (documentation, issues) First occurred: 14 January 2024 at 6:13:09 pm (5 occurrences) Last logged: 14 January 2024 at 6:14:00 pm

Unexpected error fetching peloton data: list index out of range Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 256, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/peloton/init.py", line 79, in async_update_data "quant_data": compile_quant_data( ^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/peloton/init.py", line 278, in compile_quant_data if isinstance((value := metric.get("values")[len(metric.get("values"))-1]), int) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ IndexError: list index out of range

neildsb avatar Jan 15 '24 10:01 neildsb

Was this issue fixed ? I have the same issue

This error originated from a custom integration.

Logger: custom_components.peloton Source: helpers/update_coordinator.py:300 Integration: Peloton (documentation, issues) First occurred: 8:15:34 AM (7 occurrences) Last logged: 8:23:53 AM

Unexpected error fetching peloton data: list index out of range Traceback (most recent call last): File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/update_coordinator.py", line 256, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/peloton/init.py", line 75, in async_update_data "quant_data": compile_quant_data( ^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/peloton/init.py", line 254, in compile_quant_data if isinstance((value := metric.get("values")[len(metric.get("values"))-1]), int) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ IndexError: list index out of range

Gibbo592 avatar Jan 26 '24 22:01 Gibbo592

Hello,

I'm working on some additional error handling that should help to prevent this.

Thanks!

edwork avatar Apr 07 '24 17:04 edwork