alandtse / alexa_media_player

This is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API.
Apache License 2.0
1.5k stars 287 forks source link

Unexpected error fetching alexa_media data: argument of type 'NoneType' is not iterable #1753

Closed jocamane closed 1 year ago

jocamane commented 2 years ago

Describe the bug error message appears in the HA core log

To Reproduce

  1. Go to LOGS
  2. See error

Expected behavior I hoped there was no error

Screenshots image

System details

Logs This error originated from a custom integration.

Logger: custom_components.alexa_media Source: custom_components/alexa_media/init.py:546 Integration: Alexa Media Player (documentation, issues) First occurred: 13:00:46 (1 occurrences) Last logged: 13:00:46

Unexpected error fetching alexa_media data: argument of type 'NoneType' is not iterable Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh self.data = await self._async_update_data() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 164, in _async_update_data return await self.update_method() File "/config/custom_components/alexa_media/init.py", line 546, in async_update_data if "doNotDisturbDeviceStatusList" in dnd: TypeError: argument of type 'NoneType' is not iterable

Additional context Random. I don't know when it happens

JB09 commented 2 years ago

Same issue. Started early/mid September. After the issue occurs, I no longer get state updates (ie. paused, playing) for my Alexa media_player's, but notifications (announce, tts) still work. Reloading the integration fixes the issue until the error appears again. One other comment about my setup is that I do have one echo device that is only plugged occasionally (I use it outdoors), and maybe causing the API to return a 'None' object in the device list?

jocamane commented 2 years ago

Same issue. Started early/mid September. After the issue occurs, I no longer get state updates (ie. paused, playing) for my Alexa media_player's, but notifications (announce, tts) still work. Reloading the integration fixes the issue until the error appears again. One other comment about my setup is that I do have one echo device that is only plugged occasionally (I use it outdoors), and maybe causing the API to return a 'None' object in the device list?

Hi, How can I test if in my case I don't have the state updates either?

JB09 commented 2 years ago

Hi, How can I test if in my case I don't have the state updates either?

If you see the error in your logs (and you haven’t re-loaded the Alexa Media integration) try playing music on an echo device and see if the state updates in the Developer Tools tab on HA. If it doesn’t say playing, re-load only the Alexa Media integration and see if the state is now populated properly.

JB09 commented 2 years ago

``Logger: homeassistant Source: custom_components/alexa_media/init.py:784 Integration: Alexa Media Player (documentation, issues) First occurred: October 12, 2022 at 7:01:05 PM (1 occurrences) Last logged: October 12, 2022 at 7:01:05 PM

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/alexapy/alexawebsocket.py", line 263, in process_messages await self.on_message(cast(bytes, msg.data)) File "/usr/local/lib/python3.10/site-packages/alexapy/alexawebsocket.py", line 274, in on_message await self.msg_callback(message_obj) File "/config/custom_components/alexa_media/init.py", line 1042, in ws_handler await update_dnd_state(login_obj) File "/config/custom_components/alexa_media/helpers.py", line 156, in _catch_login_errors result = await func(*args, **kwargs) File "/config/custom_components/alexa_media/init.py", line 784, in update_dnd_state if "doNotDisturbDeviceStatusList" in dnd: TypeError: argument of type 'NoneType' is not iterable``

This also started showing up in the logs when I updated HA a few days ago.

jocamane commented 2 years ago

Hi, How can I test if in my case I don't have the state updates either?

If you see the error in your logs (and you haven’t re-loaded the Alexa Media integration) try playing music on an echo device and see if the state updates in the Developer Tools tab on HA. If it doesn’t say playing, re-load only the Alexa Media integration and see if the state is now populated properly.

Hi, in my case all work fine. when i put music state change to playing and when i stop change to paused