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

TypeError: argument of type 'NoneType' is not iterable #25

Closed
kwdavidson opened this issue Aug 16, 2018 · 11 comments · Fixed by #29
Closed

TypeError: argument of type 'NoneType' is not iterable #25

kwdavidson opened this issue Aug 16, 2018 · 11 comments · Fixed by #29

Comments

@kwdavidson
Copy link

kwdavidson commented Aug 16, 2018

Running 0.9.0. Error is added to the log once per minute.

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/media_player/alexa.py", line 167, in <lambda>
    track_utc_time_change(hass, lambda now: update_devices(), second=30)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/media_player/alexa.py", line 189, in update_devices
    update_devices, url)
  File "/config/custom_components/media_player/alexa.py", line 253, in __init__
    self.refresh(device)
  File "/config/custom_components/media_player/alexa.py", line 293, in refresh
    self._session['progress'] else None)
TypeError: argument of type 'NoneType' is not iterable

Hass.io 0.75.3 running on ResinOS 2.3.0+rev1. Supervisor 125.

@keatontaylor
Copy link
Collaborator

This should've been fixed in the latest version where conditionals were added for the JSON. Closing for now, feel free to reopen if the issue still occurs.

@kwdavidson
Copy link
Author

I agree that the conditionals should have fixed it, but they don't. The error occurs in the two assignments that reference 'progress'. I even tried modifying them to check for the existence of 'progress' and it didn't help. The only way I can get the messages to stop (and get my Echoes to show up again as media players) is to comment out the two assignments that use 'progress' (media_pos and media_duration).

@keatontaylor
Copy link
Collaborator

Huh, look at that. The progress conditional is for media_length parameter inside the progress parameter and if the progress parameter is non-existent then it will absolutely give you the above error. Reopening and will implement a fix soon

@keatontaylor keatontaylor reopened this Aug 21, 2018
@alandtse
Copy link
Owner

Should have commented earlier. I agree the checks did not handle the double dictionary reference. I just haven't had a chance to work on this.

@alandtse
Copy link
Owner

Collecting other instances we need to guard against:

File “/config/custom_components/media_player/alexa.py”, line 291, in refresh
self._media_is_muted = self._session[‘volume’][‘muted’]
TypeError: ‘NoneType’ object is not subscriptable

@alandtse
Copy link
Owner

@kwdavidson mind testing the fix? I can't recreate this error on my systems.

@mihalski
Copy link

Running 0.9.1 and still getting:


2018-08-25 15:05:34 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/media_player/alexa.py", line 167, in <lambda>
    track_utc_time_change(hass, lambda now: update_devices(), second=30)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/media_player/alexa.py", line 189, in update_devices
    update_devices, url)
  File "/config/custom_components/media_player/alexa.py", line 253, in __init__
    self.refresh(device)
  File "/config/custom_components/media_player/alexa.py", line 295, in refresh
    if 'muted' in self._session['volume']
TypeError: argument of type 'NoneType' is not iterable

@alandtse
Copy link
Owner

@mihalski are you using the version from my repo? It's the subject of PR #29 and listed as version 0.9.2.

@mihalski
Copy link

You're absolutely right. It works now! :)
Except for TTS (I tried via the web UI) for which I've attached the error I heard.

I didn't realise I had so many Alexa devices (all my Sonos devices are duplicated as Sonos is linked with Alexa).. Might a future feature be to allow specifying which devices to use (or ignore) ?

Alexa TTS.m4a.zip

@alandtse
Copy link
Owner

@mihalski The TTS issue is a known limitation because of the way the media_player works in HA. You can still call tts through the media_player.alexa_tts service. Check the community thread for instructions.
As for filtering which is requested as #26 , #30 has a partial fix to only show online devices. I didn't realize Sonos would duplicate so would need to review the json from https://alexa.amazon.com/api/devices-v2/device to figure out if there's an attribute filter.

@kwdavidson
Copy link
Author

kwdavidson commented Aug 25, 2018

@alandtse The code in the PR works perfectly for me. 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

Successfully merging a pull request may close this issue.

4 participants