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

Error on startup when account has devices without alarm support #108

Merged

Conversation

LazyTarget
Copy link
Contributor

Hey!
I have been trying to setup this integration for quite some time, now I finally got the time to look at it and I managed to find out what was the issue.


After applying my credentials and when the integration tries to startup but then I got this error (then it loops until Garmin blocks all requests)

Logger: custom_components.garmin_connect
Source: custom_components/garmin_connect/__init__.py:99
Integration: Garmin Connect ([documentation](https://github.com/cyberjunky/home-assistant-garmin_connect), [issues](https://github.com/cyberjunky/home-assistant-garmin_connect/issues))
First occurred: 08:24:11 (17 occurrences)
Last logged: 10:19:32

Unexpected error fetching garmin_connect data: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/garmin_connect/__init__.py", line 99, in _async_update_data
    alarms = await self.hass.async_add_executor_job(self._api.get_device_alarms)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/garminconnect/__init__.py", line 425, in get_device_alarms
    alarms += device_settings["alarms"]
TypeError: 'NoneType' object is not iterable

So I debugged the source code locally and it seems that, I have a device (Garmin Vector 3 pedals) that returns alarms: null inside the device_settings, making the current code crash and the whole startup process fails. Simply adding this null check fixes this by simply ignoring that device.

Please have a look when you have time, and let me now if I need to update something

@LazyTarget LazyTarget changed the title Feature/fail when getting alarms Error on startup when account has devices without alarm support Jan 5, 2023
@cyberjunky cyberjunky merged commit ac14aaf into cyberjunky:master Jan 6, 2023
@cyberjunky
Copy link
Owner

Very nice find! Thanks for the PR!

@LazyTarget
Copy link
Contributor Author

Thanks for quick merge and release! 😍

hirebusbrandon pushed a commit to hirebusbrandon/python-garminconnect that referenced this pull request Jul 10, 2024
…etting_alarms

Error on startup when account has devices without alarm support
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

Successfully merging this pull request may close these issues.

None yet

2 participants