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

KeyError: 'devices' in notify.py line 102 in targets #328

Closed
alandtse opened this issue Sep 2, 2019 · 0 comments · Fixed by #335
Closed

KeyError: 'devices' in notify.py line 102 in targets #328

alandtse opened this issue Sep 2, 2019 · 0 comments · Fixed by #335

Comments

@alandtse
Copy link
Owner

alandtse commented Sep 2, 2019

Describe the bug
If notify runs before media_player is initialized, it reports a key error.

To Reproduce
Steps to reproduce the behavior:
Restart with notify loading first:

2019-09-02 08:58:31 INFO (MainThread) [custom_components.alexa_media] Loaded alexapy==1.0.1,
2019-09-02 08:58:34 INFO (MainThread) [homeassistant.setup] Setting up alexa,
2019-09-02 08:58:34 INFO (MainThread) [homeassistant.setup] Setup of domain alexa took 0.0 seconds.,
2019-09-02 08:58:41 WARNING (MainThread) [homeassistant.setup] Setup of alexa_media is taking over 10 seconds.,
2019-09-02 08:58:43 INFO (MainThread) [homeassistant.setup] Setup of domain alexa_media took 12.0 seconds.,
2019-09-02 08:58:43 INFO (MainThread) [homeassistant.components.notify] Setting up notify.alexa_media,
  File "/config/custom_components/alexa_media/notify.py", line 102, in targets,
2019-09-02 08:59:29 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.alexa_media,
2019-09-02 08:59:29 INFO (MainThread) [homeassistant.components.notify] Setting up notify.alexa_media,
2019-09-02 08:59:29 INFO (MainThread) [homeassistant.components.alarm_control_panel] Setting up alarm_control_panel.alexa_media,
2019-09-02 08:59:29 INFO (MainThread) [homeassistant.components.switch] Setting up switch.alexa_media
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/notify/__init__.py", line 122, in async_setup_platform
    if hasattr(notify_service, "targets"):
  File "/config/custom_components/alexa_media/notify.py", line 102, in targets
    ['devices']['media_player'].items()):
KeyError: 'devices'

Expected behavior
No key error.

Screenshots
If applicable, add screenshots to help explain your problem.

System details

  • Home-assistant (version):
  • Hassio (Yes/No): (Please note you may have to restart hassio 2-3 times to load the latest version of alexapy after an update. This looks like a HA bug).
  • alexa_media (version from const.py or HA startup):
  • alexapy (version from pip show alexapy or HA startup):

Additional context
https://community.home-assistant.io/t/echo-devices-alexa-as-media-player-testers-needed/58639/3139

alandtse added a commit that referenced this issue Sep 3, 2019
fix(notify): add key check for targets
@alandtse alandtse mentioned this issue Sep 3, 2019
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.

1 participant