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

alexaapi.get_last_device_serial: AttributeError occurred. Arguments: ("'str' object has no attribute 'get'",) #1982

Closed
igreg opened this issue Jul 14, 2023 · 14 comments · Fixed by #2045
Labels
alexapy Issue relates to the API bug Something isn't working good first issue Good for newcomers

Comments

@igreg
Copy link

igreg commented Jul 14, 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

Alexa Media Player fails to find devices after a configuration is setup

To Reproduce

  1. Setup a new configuration
  2. Entered my configuration (email, password, region=amazon.co.uk, my built-in 2FA secret)
  3. Click Submit to validate config
  4. Verify 2FA code is valid / in-sync with 2FA app
  5. Login via amazon.co.uk / pass 2FA step
  6. Configuration is added to HA but fails to discover devices

Expected behavior

I would expect the custom component to find and list devices if has found, registered to my Alexa/Amazon account.

Screenshots

Screenshot 2023-07-14 at 23 49 04

System details

  • Home-assistant (version): 2023.7.1
  • alexa_media (version from const.py or HA startup): 4.6.5
  • alexapy (version from pip show alexapy or HA startup): 1.26.8
  • Amazon 2FA is enabled (y/n). <!---We will not debug login issues if unanswered--->: yes

Logs
Please provide logs.

I observe the following logs & errors in home-assistant.log

2023-07-14 23:36:45.490 DEBUG (MainThread) [alexapy.alexalogin] Logged in as g*****y@i*********k to amazon.co.uk with id: A1NTWF2GWBYCPB
2023-07-14 23:36:45.722 DEBUG (MainThread) [alexapy.alexalogin] Domain amazon.co.uk matches reported account domain: https://www.amazon.co.uk
2023-07-14 23:36:45.725 DEBUG (MainThread) [alexapy.alexalogin] Login confirmed for g*****y@i*********k - amazon.co.uk; saving cookie to /config/.storage/alexa_media.g*****y@i*********k.pickle
2023-07-14 23:36:45.728 DEBUG (MainThread) [custom_components.alexa_media] Testing login status: {'login_successful': True}
2023-07-14 23:36:45.729 DEBUG (MainThread) [custom_components.alexa_media] Setting up Alexa devices for g*****y@i*********k
2023-07-14 23:36:46.145 DEBUG (MainThread) [custom_components.alexa_media] g*****y@i*********k: Websocket created: <alexapy.alexawebsocket.WebsocketEchoClient object at 0x7f8ae04710>
2023-07-14 23:36:46.145 DEBUG (MainThread) [alexapy.alexawebsocket] Connecting to wss://dp-gw-na.amazon.co.uk/tcomm/ with {'Cookie': '...'}
2023-07-14 23:36:46.536 DEBUG (MainThread) [custom_components.alexa_media] g*****y@i*********k: Websocket successfully connected
2023-07-14 23:36:46.536 DEBUG (MainThread) [custom_components.alexa_media] g*****y@i*********k: Creating coordinator
2023-07-14 23:36:46.536 DEBUG (MainThread) [custom_components.alexa_media] g*****y@i*********k: Refreshing coordinator
2023-07-14 23:36:46.537 DEBUG (MainThread) [alexapy.alexawebsocket] Starting message parsing loop.
2023-07-14 23:36:46.567 DEBUG (MainThread) [alexapy.alexawebsocket] Received raw WebSocket: b'0x37a1b607 0x0000009c {"protocolName":"A:F","parameters":{"AlphaProtocolHandler.maxFragmentSize":"16000","AlphaProtocolHandler.receiveWindowSize":"16"}}TUNE'
2023-07-14 23:36:46.568 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding WebSocket Handshake MSG.
2023-07-14 23:36:46.568 DEBUG (MainThread) [alexapy.alexawebsocket] 0xfe88bc52 0x0000009c {"protocolName":"A:F","parameters":{"AlphaProtocolHandler.receiveWindowSize":"16","AlphaProtocolHandler.maxFragmentSize":"16000"}}TUNE
2023-07-14 23:36:46.573 DEBUG (MainThread) [alexapy.alexawebsocket] A:F Initialization Msg 2 sent: 307866653838626335322030783030303030303963207b2270726f746f636f6c4e616d65223a22413a46222c22706172616d6574657273223a7b22416c70686150726f746f636f6c48616e646c65722e7265636569766557696e646f7753697a65223a223136222c22416c70686150726f746f636f6c48616e646c65722e6d6178467261676d656e7453697a65223a223136303030227d7d54554e45
2023-07-14 23:36:46.644 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Register MSG.
2023-07-14 23:36:46.647 DEBUG (MainThread) [alexapy.alexawebsocket] bytearray(b'MSG\x00\x00\x03b\'\xd6\xa2\xc0f\x00\x00\x00\x01:\xa9\xe1\x97\x00\x00\x00\xe4GWM MSG 0x0000b479 0x0000003b urn:tcomm-endpoint:device:deviceType:0:deviceSerialNumber:0 0x00000041 urn:tcomm-endpoint:service:serviceName:DeeWebsiteMessagingService {"command":"REGISTER_CONNECTION"}FABE')
2023-07-14 23:36:46.648 DEBUG (MainThread) [alexapy.alexawebsocket] A:F Initialization Msg 3 (Register Connection) sent: 4d53470000036227d6a2c066000000013aa9e197000000e447574d204d5347203078303030306234373920307830303030303033622075726e3a74636f6d6d2d656e64706f696e743a6465766963653a646576696365547970653a303a64657669636553657269616c4e756d6265723a3020307830303030303034312075726e3a74636f6d6d2d656e64706f696e743a736572766963653a736572766963654e616d653a446565576562736974654d6573736167696e6753657276696365207b22636f6d6d616e64223a2252454749535445525f434f4e4e454354494f4e227d46414245
2023-07-14 23:36:46.699 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding PING.
2023-07-14 23:36:46.701 DEBUG (MainThread) [alexapy.alexawebsocket] bytearray(b"MSG\x00\x00\x00e\'\xd6\xa2\xc1f\x00\x00\x00\x01\xdd3\xb4f\x00\x00\x00=PIN\x00\x00\x00\x00\x00\x00\x01\x89V\x8c\xaa\xec\x00\x00\x00\x07\x00R\x00e\x00g\x00u\x00l\x00a\x00rFABE")
2023-07-14 23:36:46.703 DEBUG (MainThread) [alexapy.alexawebsocket] Send First Ping: 4d53470000006527d6a2c16600000001dd33b4660000003d50494e0000000000000189568caaec000000070052006500670075006c0061007246414245
2023-07-14 23:36:46.725 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/bootstrap returned 200:OK:application/json
2023-07-14 23:36:46.757 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/dnd/device-status-list returned 200:OK:application/json
2023-07-14 23:36:46.784 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/phoenix returned 200:OK:application/json
2023-07-14 23:36:46.789 DEBUG (MainThread) [alexapy.alexawebsocket] Received raw WebSocket: b'MSG\x00\x00\x00eA\x1b\xd0pf\x00\x00\x00\x01"gc\x80\x00\x00\x00=PON\x00\x00\x00\x00\x00\x00\x01\x89V\x8c\xaa\xec\x00\x00\x00\x07\x00R\x00e\x00g\x00u\x00l\x00a\x00rFABE'
2023-07-14 23:36:46.815 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: get_network_details response: ...
2023-07-14 23:36:46.878 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/bluetooth?cached=false returned 200:OK:application/json
2023-07-14 23:36:46.907 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/devices-v2/device returned 200:OK:application/json
2023-07-14 23:36:46.971 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/device-preferences returned 200:OK:application/json
2023-07-14 23:36:46.972 DEBUG (MainThread) [custom_components.alexa_media] Alexa entities have been loaded. Prepared for discovery.
2023-07-14 23:44:50.764 DEBUG (MainThread) [custom_components.alexa_media] Finished fetching alexa_media data in 5.280 seconds (success: False)
2023-07-14 23:44:50.765 DEBUG (MainThread) [alexapy.alexawebsocket] Received raw WebSocket: b'MSG\x00\x00\x03b?\xfd\x88\xadf\x00\x00\x00\x01/+>\xbf\x00\x00\x02)GWM MSG 0x0000b479 0x0000005c urn:tcomm-endpoint:service:serviceName:DeeWebsiteMessagingService:domain:prod:realm:USAmazon 0x00000080 urn:tcomm-endpoint:device:customerId:A1NTWF2GWBYCPB:deviceType:A2IVLV5VM2W81:deviceSerialNumber:7bd22686b234070361f8c9f0a146702b {"command":"PUSH_VOLUME_CHANGE","payload":"{\\"destinationUserId\\":\\"A1NTWF2GWBYCPB\\",\\"dopplerId\\":{\\"deviceType\\":\\"A2EZ3TS0L1S2KV\\",\\"deviceSerialNumber\\":\\"a151d0be95424228af89780239a7ebbd\\"},\\"volumeSetting\\":26,\\"isMuted\\":false}","timeStamp":1689374685431}FABE'
2023-07-14 23:44:50.765 DEBUG (MainThread) [custom_components.alexa_media] g*****y@i*********k: Received websocket command: PUSH_VOLUME_CHANGE : {'destinationUserId': 'A**********CPB', 'dopplerId': {'deviceType': 'A2EZ3TS0L1S2KV', 'deviceSerialNumber': 'a****************************bbd'}, 'volumeSetting': 26, 'isMuted': False}
2023-07-14 23:44:50.765 DEBUG (MainThread) [custom_components.alexa_media] Adding PUSH_VOLUME_CHANGE to seen_commands: {'PUSH_EQUALIZER_STATE_CHANGE': 1689374685.484014}
2023-07-14 23:44:50.766 DEBUG (MainThread) [custom_components.alexa_media] Discovered new media_player a151d0be95424228af89780239a7ebbd
2023-07-14 23:45:00.909 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/bootstrap returned 200:OK:application/json
2023-07-14 23:45:00.966 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/dnd/device-status-list returned 200:OK:application/json
2023-07-14 23:45:01.002 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/devices-v2/device returned 200:OK:application/json
2023-07-14 23:45:01.029 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/bluetooth?cached=false returned 200:OK:application/json
2023-07-14 23:45:01.134 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/device-preferences returned 200:OK:application/json
2023-07-14 23:45:01.135 DEBUG (MainThread) [custom_components.alexa_media] g*****y@i*********k: Found 9 devices, 9 bluetooth
2023-07-14 23:45:05.440 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/notifications returned 200:OK:application/json
2023-07-14 23:45:05.441 DEBUG (MainThread) [custom_components.alexa_media] g*****y@i*********k: Updated 2 notifications for 3 devices at 2023-07-14 23:45:05.441474+01:00
2023-07-14 23:45:05.613 DEBUG (MainThread) [alexapy.alexaapi] g*****y@i*********k: static GET: https://alexa.amazon.co.uk/api/activities?startTime=&size=10&offset=1 returned 200:OK:application/json
2023-07-14 23:45:05.614 WARNING (MainThread) [alexapy.helpers] alexaapi.get_last_device_serial((<alexapy.alexalogin.AlexaLogin object at 0x7f5e20b0d0>,), {}): An error occurred accessing AlexaAPI: An exception of type AttributeError occurred. Arguments:
("'str' object has no attribute 'get'",)
2023-07-14 23:45:05.616 DEBUG (MainThread) [custom_components.alexa_media] Finished fetching alexa_media data in 4.850 seconds (success: False)

Additional context

@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 Jul 19, 2023
@babanu5
Copy link

babanu5 commented Aug 20, 2023

Hi, can somebody answer this? I have the same issue and is has been bugging me for the past 2 weeks!

@github-actions github-actions bot removed the help wanted Extra attention is needed label Aug 21, 2023
@github-actions
Copy link

This bug report has been labelled as help wanted since there has been no activity in the last 3 weeks. It will not be closed automatically.

@github-actions github-actions bot added the help wanted Extra attention is needed label Sep 11, 2023
@ukgrant
Copy link

ukgrant commented Sep 15, 2023

Not sure if this will help someone, but I encountered a similar issue and resolved by manually creating the following directory:
config/www/alexa_tts

I then removed and re-added the integration.

@github-actions github-actions bot removed the help wanted Extra attention is needed label Sep 16, 2023
@tplas
Copy link

tplas commented Sep 17, 2023

Wow! That did indeed do the trick, to create that folder. Nice magic incantation there.

Even better, it found all my old devices & hooked them back up to my automations. I had resigned myself to needing to re-enter all of those after they had gotten lost on my AMP HACS integration version updatee.

Thank you!

@JaySpec1488
Copy link

Not sure if this will help someone, but I encountered a similar issue and resolved by manually creating the following directory: config/www/alexa_tts

I then removed and re-added the integration.

What do you mean with "creating a directory" where and how? 😅

@ukgrant
Copy link

ukgrant commented Sep 17, 2023

@JaySpec1488 There's a few ways you can do this and it will depend on your installation type. I am using home assistant OS, so used the addon store to install the "file editor". Using the file editor, create a folder called "www" (if it doesn't already exist) then inside that create a folder called "alexa_tts"

@JaySpec1488
Copy link

JaySpec1488 commented Sep 18, 2023

@JaySpec1488 There's a few ways you can do this and it will depend on your installation type. I am using home assistant OS, so used the addon store to install the "file editor". Using the file editor, create a folder called "www" (if it doesn't already exist) then inside that create a folder called "alexa_tts"

Mhh, seems like that i already have this folder... so i have another issue that the integration finds nothing. But my log says something about that... crazy... 🙃
But thank you.
Screenshot_20230918_080931_Home Assistant
@

@JaySpec1488
Copy link

@JaySpec1488 There's a few ways you can do this and it will depend on your installation type. I am using home assistant OS, so used the addon store to install the "file editor". Using the file editor, create a folder called "www" (if it doesn't already exist) then inside that create a folder called "alexa_tts"

Screenshot_20230918_082504_Home Assistant

@ukgrant
Copy link

ukgrant commented Sep 18, 2023

@JaySpec1488 You have created in the wrong place. config/config/www/alexa_tts should be config/www/alexa_tts.

Also I think the latest version just released v4.7.1 resolves this issue anyway, so can try updating or removing & reinstalling.

@zimpower
Copy link

Not sure if this will help someone, but I encountered a similar issue and resolved by manually creating the following directory: config/www/alexa_tts

I then removed and re-added the integration.

I am am v4.7.1 and still had the issue. This solution also worked for me. Thanks!

@Speedafix
Copy link

YEAAAAH it works with the Folder THANKS

@JaySpec1488
Copy link

Not sure if this will help someone, but I encountered a similar issue and resolved by manually creating the following directory: config/www/alexa_tts
I then removed and re-added the integration.

I am am v4.7.1 and still had the issue. This solution also worked for me. Thanks!

Nice. That worked for me too 👍👍👍👍😁😁😁

@JaySpec1488
Copy link

@JaySpec1488 You have created in the wrong place. config/config/www/alexa_tts should be config/www/alexa_tts.

Also I think the latest version just released v4.7.1 resolves this issue anyway, so can try updating or removing & reinstalling.

Yes. I changed it. Now it works. Thx 👍👍👍😁😁😁

@Mauley
Copy link

Mauley commented Sep 20, 2023

Not sure if this will help someone, but I encountered a similar issue and resolved by manually creating the following directory: config/www/alexa_tts
I then removed and re-added the integration.

What do you mean with "creating a directory" where and how? 😅

This is so strange, but helped.. Thanks a lot!

@alandtse alandtse changed the title Alexia Media Player installation fails to find devices alexaapi.get_last_device_serial: AttributeError occurred. Arguments: ("'str' object has no attribute 'get'",) Sep 22, 2023
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

Successfully merging a pull request may close this issue.

9 participants