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.52k stars 290 forks source link

Authentication needs to be repeated after every HA restart - DO NOT USE 4.13.8! Solution: Revert to 4.13.7 #2687

Open ThiloAm opened 2 days ago

ThiloAm commented 2 days ago

Describe the bug

After restarting Home Assistant, authentication needs to be performed again and remains valid only until the next restart.

To Reproduce

Every restart of Homeassistant causes the error.

Expected behavior

One-time Login

Screenshots

System details

Debug Logs (alexa_media & alexapy) debug button not available - Extract from the general log.

Logger: homeassistant.components.media_player
Quelle: helpers/entity_platform.py:365
Integration: Mediaplayer (Dokumentation, Probleme)
Erstmals aufgetreten: 12:56:07 (1 Vorkommnisse)
Zuletzt protokolliert: 12:56:07

Error while setting up jellyfin platform for media_player
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 365, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/usr/src/homeassistant/homeassistant/components/jellyfin/media_player.py", line 46, in async_setup_entry
    handle_coordinator_update()
  File "/usr/src/homeassistant/homeassistant/components/jellyfin/media_player.py", line 40, in handle_coordinator_update
    entity: MediaPlayerEntity = JellyfinMediaPlayer(coordinator, session_id)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/jellyfin/media_player.py", line 60, in __init__
    super().__init__(coordinator, session_id)
  File "/usr/src/homeassistant/homeassistant/components/jellyfin/entity.py", line 47, in __init__
    self.device_name: str = self.session_data["DeviceName"]
                            ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'DeviceName'

Additional context

danielbrunt57 commented 2 days ago

I'm thinking the error you posted is a result of the re-auth required after restart rather than the cause of it...

ThiloAm commented 1 day ago

Thank you for your response. Is it normal behavior for a re-authentication to be required after restarting Home Assistant?
If so, is there an "easy" way to perform the re-authentication?

The error message is not that I should log in again. Instead, a configuration error is displayed. image

danielbrunt57 commented 17 hours ago

Thank you for your response. Is it normal behavior for a re-authentication to be required after restarting Home Assistant?

No. For the periods when I'm not developing and breaking things, if I restart HA, it restarts just fine without reauth. Reauth occurs when token sign in fails then it tries using stored cookie login, then it tries stored credentials and fails, and that should not occur. Are you using OTP? Are you using legacy YAML config? I just noticed now you indicated you're using 4.13.8. That's a bad version and a PR has been merged into Dev to undo it. Until there's a new version released, use 4.13.7.

ThiloAm commented 2 hours ago

I went back to version 4.13.7. Now it works again.

Thank you for your help.