home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.68k stars 30.81k forks source link

Login attempt or request with invalid authentication from HEOS-HomeCinema #69489

Closed leon-volt closed 1 year ago

leon-volt commented 2 years ago

The problem

I'm getting the following error when I try playing music to my heos soundbar HEOSHCBKE2 via the media browser. I've tried re adding the integration but no luck.

Login attempt or request with invalid authentication from HEOS-HomeCinema (192.168.1.72). (AvegaMediaServer/2.0 Linux/2.6)

What version of Home Assistant Core has the issue?

core-2022.4.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Integration, heos

Link to integration documentation on our website

https://www.home-assistant.io/integrations/heos

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.http.ban
Source: components/http/ban.py:125
Integration: HTTP (documentation, issues)
First occurred: 22:48:52 (7 occurrences)
Last logged: 22:52:10

Login attempt or request with invalid authentication from HEOS-HomeCinema (192.168.1.72). (AvegaMediaServer/2.0 Linux/2.6)

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

heos documentation heos source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @andrewsayre, mind taking a look at this issue as it has been labeled with an integration (heos) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

ianfretwell commented 2 years ago

Have you actually used the heos.sign_in service to log it into your Heos account? It'll not work until you do.

leon-volt commented 2 years ago

Have you actually used the heos.sign_in service to log it into your Heos account? It'll not work until you do.

Yes I've done that. Favorites are working and everything. But the error still occurs. I will try it tomorrow with a clean Hass vm to confirm that there's nothing else in my setup causing it.

frankvollebregt commented 2 years ago

Since this issue also occurs when playing through the media browser, I feel like it might be the same issue that was reported here. Do you have a similar message in your own logs @ianfretwell ?

ianfretwell commented 2 years ago

@frankvollebregt No errors at all for me - it just doesn't do anything so I'm pretty sure it's different.

frankvollebregt commented 2 years ago

After enabling the logs as per the documentation, I can view the URL that is sent to the Heos to be played. It looks a bit like this (some parts obscured for obvious reasons):

http://192.168.1.xxx:8123/media/local/Firstname%2520Lastname%2520-%2520Album/02%2520-%2520Firstname%2520Lastname%2520-%2520Songtitle.mp3?authSig%3DeyREST_OF_TOKEN

Sure enough, running this URL in Postman returned the same 401 (unauthorized) error. And I thought, hey, this looks strange. As it turns out, is it encoded twice. When I decode this URL (just using some random online URL decoder), I get a URL that looks much more like a 'normal' encoded URL:

http://192.168.1.xxx:8123/media/local/Firstname%20Lastname%20-%20Album/02%20-%20Firstname%20Lastname%20-%20Songtitle.mp3?authSig=eyREST_OF_TOKEN

When I put this URL in my browser's address bar, it plays as expected.

In conclusion, I suspect that the URL is encoded twice: Once in pyheos, and once in the HA component.

I'm not very experienced with how HA works, so I hope I may have saved someone some time figuring things out :)

Edit

Never mind the above, since it's a URL inside a URL, of course the inner part would have to be encoded twice (otherwise it might break the outer URL...)

I see there have been some changes on the dev channel to the media_player.py file, maybe this somehow helps resolve the issue here?

https://github.com/home-assistant/core/commit/999e2f3bf0dbc7714192fe425a01df00e5421de6

frankvollebregt commented 2 years ago

To supplement to the original issue, here is a part of the debug logs I get:

2022-04-07 15:38:32 DEBUG (MainThread) [pyheos.connection] Command executed 'heos://browse/play_stream?sequence=16&pid=xxx&url=URL_WITH_TOKEN': '{'command': 'browse/play_stream', 'result': 'success', 'message': 'sequence=16&pid=xxx&url=URL_WITH_TOKEN'}'
2022-04-07 15:38:33 DEBUG (MainThread) [pyheos.connection] Event received for player {HEOS HomeCinema (HEOS HomeCinema)}: {'command': 'event/player_queue_changed', 'message': 'pid=xxx'}
2022-04-07 15:38:33 DEBUG (MainThread) [pyheos.connection] Command executed 'heos://player/get_now_playing_media?sequence=17&pid=xxx': '{'command': 'player/get_now_playing_media', 'result': 'success', 'message': 'sequence=17&pid=xxx'}'
2022-04-07 15:38:33 DEBUG (MainThread) [pyheos.connection] Event received for player {HEOS HomeCinema (HEOS HomeCinema)}: {'command': 'event/player_now_playing_changed', 'message': 'pid=xxx'}
2022-04-07 15:38:34 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from HEOS-HomeCinema (192.168.1.72). (AvegaMediaServer/2.0 Linux/2.6)
2022-04-07 15:38:34 DEBUG (MainThread) [pyheos.connection] Event received for player {HEOS HomeCinema (HEOS HomeCinema)}: {'command': 'event/player_state_changed', 'message': 'pid=xxx&state=stop'}
2022-04-07 15:38:34 DEBUG (MainThread) [pyheos.connection] Event received for player {HEOS HomeCinema (HEOS HomeCinema)}: {'command': 'event/player_playback_error', 'message': 'pid=xxx&error=Unable to play media. Please try again later.'}
2022-04-07 15:38:34 DEBUG (MainThread) [pyheos.connection] Command executed 'heos://player/get_now_playing_media?sequence=18&pid=xxx': '{'command': 'player/get_now_playing_media', 'result': 'success', 'message': 'sequence=18&pid=xxx'}'
ianfretwell commented 2 years ago

And yet I'm not having ANY problem playing to my Heos Homecinema through the media browser.

Just for clarity I'm selecting music from a DLNA server.

My original issue still stands that it won't play an album, only individual tracks. Playing an album just causes the previous Heos instigated queue to play instead - as per here.

haivala commented 2 years ago

I have Marantz amp and when I try to play media through the hass media player I get the same login error and I cannot play any local media from the media browser when I select the HEOS output. It just jumps to play one of the working HEOS playlists.

Seems like the url that is given from hass to the HEOS and which it is trying to play inside the amp is not reachable from the hass instance and hass gives HEOS the login prompt in which it does not have creds. Am I right?

I'm running: Home Assistant 2022.4.3

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

WebSpider commented 2 years ago

bump

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.