Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peloton errors when starting workout #89

Open
RogerSelwyn opened this issue Nov 11, 2023 · 4 comments
Open

Peloton errors when starting workout #89

RogerSelwyn opened this issue Nov 11, 2023 · 4 comments

Comments

@RogerSelwyn
Copy link

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
Copy link
Author

RogerSelwyn commented Nov 11, 2023

This looks to be a duplicate of these:

and possibly this:

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.

@neildsb
Copy link

neildsb commented Jan 15, 2024

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

@Gibbo592
Copy link

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

@edwork
Copy link
Owner

edwork commented Apr 7, 2024

Hello,

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants