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

Media controls do not appear to work and return a 400 error #1928

Closed
SGXander opened this issue May 5, 2023 · 20 comments
Closed

Media controls do not appear to work and return a 400 error #1928

SGXander opened this issue May 5, 2023 · 20 comments
Labels
alexapy Issue relates to the API bug Something isn't working good first issue Good for newcomers

Comments

@SGXander
Copy link

SGXander commented May 5, 2023

IMPORTANT: Please search the issues, including closed issues, and the FAQ before opening a new issue. The template is mandatory; failure to use it will result in issue closure.

Describe the bug

As of latest HA version 2023.05.0-2 Media controls no longer work. Volume still works

To Reproduce

Attempt to play/pause/turn off echo

Expected behavior

Device should respond to actions

Screenshots

N/A

System details

  • Home-assistant (version): 2023.05.0-2
  • alexa_media (version from const.py or HA startup): 4.6.2
  • alexapy (version from pip show alexapy or HA startup):
  • Amazon 2FA is enabled (y/n). yes

Logs

2023-05-06 00:18:06.808 DEBUG (MainThread) [alexapy.alexaapi] ********************: POST: https://alexa.amazon.co.uk/api/np/command returned 400:Bad Request:application/json
2023-05-06 00:18:06.808 DEBUG (MainThread) [alexapy.alexaapi] Returning None due to status: 400

Additional context

@alandtse
Copy link
Owner

alandtse commented May 6, 2023

Looks like Amazon may have changed their API at least in the UK.

@alandtse alandtse added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers alexapy Issue relates to the API labels May 6, 2023
@SGXander
Copy link
Author

SGXander commented May 6, 2023

Looks like Amazon may have changed their API at least in the UK.

Ah apologies for blaming the HA update then. I take it they don't version their API so you can define it in the path? (may be talking gibberish but some rest APIs I work with have a schema like /rest/v2/ that you can always call back on if the version changes.

@alandtse
Copy link
Owner

alandtse commented May 6, 2023

Do other portions of the component work? A 400 error means the server rejected the command. If you're seeing it for all requests, you may have an authentication issue.

@alandtse alandtse changed the title As of HA 2023.05.x, media controls do not appear to work Media controls do not appear to work and return a 400 error May 6, 2023
@alandtse
Copy link
Owner

alandtse commented May 6, 2023

Actually, I just confirmed it on the US servers too.

@alandtse
Copy link
Owner

alandtse commented May 6, 2023

Looks like they're deprecating the old webplayer.

Latest working command:
https://alexa.amazon.com/api/np/command?deviceSerialNumber=SNIP&deviceType=SNIP

Play

{"type":"PlayCommand","contentFocusClientId":null}

Pause

{"type":"PauseCommand","contentFocusClientId":null}

Next

{"type":"NextCommand","contentFocusClientId":null}

Thumbs
https://alexa.amazon.com/api/media/thumbs-up

{"deviceType":"SNIP","deviceSerialNumber":"SNIP","referenceId":"7e357edb-f6f3-4656-9743-cbb49b93340e:10","mediaOwnerCustomerId":"SNIP3EG"}

@SGXander
Copy link
Author

SGXander commented May 6, 2023

Do other portions of the component work? A 400 error means the server rejected the command. If you're seeing it for all requests, you may have an authentication issue.

yes volume still works ok as does the notification of what is playing currently

@Angelos59
Copy link

I upgraded to 5.2 the media controls for music don't work. Volume works but pause and skip do not. I circumvented with a script but it should be fixed or remove the controls from the media player. Tis worked in 4.x and not 5.0, 5.1 0r 5.2. Thanks, you guys do great work and things are complex. The media controls are very useful. When I go back to 4.x they work.

@alandtse
Copy link
Owner

alandtse commented May 7, 2023

I upgraded to 5.2 the media controls for music don't work. Volume works but pause and skip do not. I circumvented with a script but it should be fixed or remove the controls from the media player. Tis worked in 4.x and not 5.0, 5.1 0r 5.2. Thanks, you guys do great work and things are complex. The media controls are very useful. When I go back to 4.x they work.

Those version numbers don't match any versions of this component. What version of alexa_media are you talking about where a rollback works?

@github-actions github-actions bot removed the help wanted Extra attention is needed label May 7, 2023
@Angelos59
Copy link

Angelos59 commented May 7, 2023 via email

@WhimsySpoon
Copy link

I think 4.x and 5.x refer to the version of HA Core, specifically 2023.5.x and 2023.4.x.

It does seem that this issue was introduced at around the time that I upgraded HA Core to 2023.5.0, but I haven't done a rollback to confirm.

Given that you've identified a change to the Alexa API, it seems this may just be a coincidence.

@eeqgit
Copy link

eeqgit commented May 7, 2023

I think 4.x and 5.x refer to the version of HA Core, specifically 2023.5.x and 2023.4.x.

It does seem that this issue was introduced at around the time that I upgraded HA Core to 2023.5.0, but I haven't done a rollback to confirm.

Given that you've identified a change to the Alexa API, it seems this may just be a coincidence.

Controls work fine after reverting back to HA Core 2023.4.6. First noticed the issue when I was already at 2023.5.2, so I don't know what version exactly after 4.6 broke it.

@SGXander
Copy link
Author

SGXander commented May 7, 2023

Tried the updated version and get this upon setup, both from cold-start and reload:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/alexa_media/init.py", line 326, in async_setup_entry
await login.login(cookies=await login.load_cookie())
File "/usr/local/lib/python3.10/site-packages/alexapy/alexalogin.py", line 347, in load_cookie
return_cookies = self._get_cookies_from_session()
File "/usr/local/lib/python3.10/site-packages/alexapy/alexalogin.py", line 554, in _get_cookies_from_session
cookies = cookie_jar.filter_cookies(URL(f"https://{site}"))
File "/usr/local/lib/python3.10/site-packages/aiohttp/cookiejar.py", line 239, in filter_cookies
self._do_expiration()
File "/usr/local/lib/python3.10/site-packages/aiohttp/cookiejar.py", line 150, in _do_expiration
self.clear(lambda x: False)
File "/usr/local/lib/python3.10/site-packages/aiohttp/cookiejar.py", line 115, in clear
for (domain, path), cookie in self._cookies.items():
ValueError: not enough values to unpack (expected 2, got 0)

@WhimsySpoon
Copy link

WhimsySpoon commented May 8, 2023

Something similar. Just installed 4.6.4, restarted HA Core and was prompted to reauthenticate. Did so, but now, the component fails to load but without anything in the logs. Just shows "Failed to Load" on the integrations screen.

I've rolled back to 4.6.3 which starts up fine and solves the issue raised here.

@KHOne23
Copy link

KHOne23 commented May 8, 2023

works fine for me Home Assistant 2023.5.2 and 4.6.4

@Angelos59
Copy link

Angelos59 commented May 8, 2023 via email

@KHOne23
Copy link

KHOne23 commented May 8, 2023

Yes all fine here, had the Problem before that in Automations the Pause Order is not working. Now everything works like before

Do the Alexa media player music  pause and skip controls work? Do text scripts imitating voice work? They all stopped working for me. Wonder why. Angelos Spetseris508 769 7093On May 8, 2023, at 2:34 AM, KHOne23 @.> wrote: works fine for me Home Assistant 2023.5.2 and 4.6.4 —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.>

@Angelos59
Copy link

Angelos59 commented May 8, 2023 via email

@SGXander
Copy link
Author

SGXander commented May 8, 2023

confirmed mine also fine with 4.6.4 now. Thank you!

@WhimsySpoon
Copy link

Have just tried another update to 4.6.4 and it now works fine; the error no longer appears. Must have been something on Amazon's end.

@Angelos59
Copy link

Angelos59 commented May 9, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alexapy Issue relates to the API bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants