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.36k stars 263 forks source link

last_called_summary does not update #2275

Open Mis1ify opened 1 month ago

Mis1ify commented 1 month ago

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 The 'last_called_summary' does not really update, or updates slowly.

This is an important state argument to me as I use it for automations. The problem started very long time ago. This happens only for 'last_called_summary'. For example, when I say 'volume up' the 'volume_up' argument raises, but 'last_called_summary' remains the same for a good one hour? Sometimes it will update within one minutes, but sometimes won't.

To Reproduce

  1. Speak something to Alexa.
  2. Check dev options of echo dot.
  3. 'last_called_summary' was not updated.

Expected behavior last_called_summary should update with max delay of 10-20 seconds.

Screenshots image

System details

Logs Please provide logs.

2024-06-04 10:45:24.308 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-06-04 10:45:24.315 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration alexa_media which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-06-04 10:45:34.456 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.components.frontend. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from frontend directly at custom_components/hacs/frontend.py, line 68: hass.components.frontend.async_register_built_in_panel(, please create a bug report at https://github.com/hacs/integration/issues 2024-06-04 10:45:54.802 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.helpers.event. This is deprecated and will stop working in Home Assistant 2024.11, it should be updated to import functions used from event directly at custom_components/hacs/base.py, line 630: self.hass.helpers.event.async_track_time_interval(, please create a bug report at https://github.com/hacs/integration/issues 2024-06-04 10:46:38.037 DEBUG (MainThread) [alexapy.alexahttp2] Received raw message: Content-Type: application/json {"directive":{"header":{"namespace":"Alexa.Mobile.Push","name":"RenderUpdate","messageId":"X"},"payload":{"renderingUpdates":[{"route":"EventBus:tcomm::message","resourceId":"PUSH_VOLUME_CHANGE","resourceMetadata":"{\"command\":\"PUSH_VOLUME_CHANGE\",\"timeStamp\":1717490797924,\"payload\":\"{\\"dopplerId\\":{\\"deviceSerialNumber\\":\\"X\\",\\"deviceType\\":\\"A1RABVCI4QCIKC\\"},\\"volumeSetting\\":100,\\"isMuted\\":false,\\"destinationUserId\\":\\"X\\"}\"}"}]}}} --------abcde123 2024-06-04 10:46:38.040 DEBUG (MainThread) [custom_components.alexa_media] f**i@g*m: Received http2push command: PUSH_VOLUME_CHANGE : {'dopplerId': {'deviceSerialNumber': 'G****B0V', 'deviceType': 'A1RABVCI4QCIKC'}, 'volumeSetting': 100, 'isMuted': False, 'destinationUserId': 'A**IPS'} 2024-06-04 10:46:38.040 DEBUG (MainThread) [custom_components.alexa_media] Adding PUSH_VOLUME_CHANGE to seen_commands: {} 2024-06-04 10:46:38.041 DEBUG (MainThread) [custom_components.alexa_media] Updating media_player volume: {'dopplerId': {'deviceSerialNumber': 'G****B0V', 'deviceType': 'A1RABVCI4QCIKC'}, 'volumeSetting': 100, 'isMuted': False, 'destinationUserId': 'A**IPS'} 2024-06-04 10:46:38.042 DEBUG (MainThread) [custom_components.alexa_media.media_player] f**i@g*m: Fabian's Echo Dot volume updated: 100 2024-06-04 10:46:38.053 DEBUG (MainThread) [alexapy.alexahttp2] Received raw message: Content-Type: application/json {"directive":{"header":{"namespace":"Alexa.Mobile.Push","name":"RenderUpdate","messageId":"X"},"payload":{"renderingUpdates":[{"route":"EventBus:tcomm::message","resourceId":"PUSH_EQUALIZER_STATE_CHANGE","resourceMetadata":"{\"command\":\"PUSH_EQUALIZER_STATE_CHANGE\",\"timeStamp\":1717490797920,\"payload\":\"{\\"dopplerId\\":{\\"deviceSerialNumber\\":\\"X\\",\\"deviceType\\":\\"A1RABVCI4QCIKC\\"},\\"bass\\":1,\\"midrange\\":-1,\\"treble\\":1,\\"destinationUserId\\":\\"X\\"}\"}"}]}}} --------abcde123 2024-06-04 10:46:38.056 DEBUG (MainThread) [custom_components.alexa_media] f**i@g*m: Received http2push command: PUSH_EQUALIZER_STATE_CHANGE : {'dopplerId': {'deviceSerialNumber': 'G****B0V', 'deviceType': 'A1RABVCI4QCIKC'}, 'bass': 1, 'midrange': -1, 'treble': 1, 'destinationUserId': 'A**IPS'} 2024-06-04 10:46:38.057 DEBUG (MainThread) [custom_components.alexa_media] Adding PUSH_EQUALIZER_STATE_CHANGE to seen_commands: {'PUSH_VOLUME_CHANGE': 1717490798.040848} 2024-06-04 10:46:38.057 DEBUG (MainThread) [custom_components.alexa_media] Updating media_player availability {'dopplerId': {'deviceSerialNumber': 'G****B0V', 'deviceType': 'A1RABVCI4QCIKC'}, 'bass': 1, 'midrange': -1, 'treble': 1, 'destinationUserId': 'A**IPS'} 2024-06-04 10:46:41.187 DEBUG (MainThread) [alexapy.alexahttp2] Received raw message: Content-Type: application/json {"directive":{"header":{"namespace":"Alexa.Mobile.Push","name":"RenderUpdate","messageId":"X"},"payload":{"renderingUpdates":[{"route":"EventBus:tcomm::message","resourceId":"PUSH_VOLUME_CHANGE","resourceMetadata":"{\"command\":\"PUSH_VOLUME_CHANGE\",\"timeStamp\":1717490801078,\"payload\":\"{\\"dopplerId\\":{\\"deviceSerialNumber\\":\\"X\\",\\"deviceType\\":\\"X\\"},\\"volumeSetting\\":90,\\"isMuted\\":false,\\"destinationUserId\\":\\"X\\"}\"}"}]}}} --------abcde123 2024-06-04 10:46:41.189 DEBUG (MainThread) [custom_components.alexa_media] f**i@g*m: Received http2push command: PUSH_VOLUME_CHANGE : {'dopplerId': {'deviceSerialNumber': 'G****B0V', 'deviceType': 'A1RABVCI4QCIKC'}, 'volumeSetting': 90, 'isMuted': False, 'destinationUserId': 'A**IPS'} 2024-06-04 10:46:41.190 DEBUG (MainThread) [custom_components.alexa_media] Updating media_player volume: {'dopplerId': {'deviceSerialNumber': 'G****B0V', 'deviceType': 'A1RABVCI4QCIKC'}, 'volumeSetting': 90, 'isMuted': False, 'destinationUserId': 'A**IPS'} 2024-06-04 10:46:41.191 DEBUG (MainThread) [custom_components.alexa_media.media_player] f**i@g***m: Fabian's Echo Dot volume updated: 90

Additional context Calling service 'alexa_media.update_last_called' updates the argument correctly, and i've even set up automation to run this every 10 seconds, but after some time it shows an error in logs TooManyRequests.

I understand that it may be a Alexa API limitation, but then why volume_level updates perfectly?

alandtse commented 2 weeks ago

Http2 streaming is not considered a separate request so is unaffected by 429 errors assuming it's allowed to connect. Your logs don't seem to show any use of last_called. But if the issue is that you're seeing 429s when trying to update, then you're out of luck since that's Amazon not responding so obviously we can't really figure out what was last called.

Mis1ify commented 2 weeks ago

The problem is I'm not seeing anything. The other settings are working correctly, and, as shown on logs, the volume level updated almost immediately, but before that I told something to Alexa, which is not apparently in the logs, so last_update was not updated.

alandtse commented 2 weeks ago

If you interacted with Alexa and it's not showing in the logs, it's possible Alexa removed the notification from http2 and now the function is broken permanently.

Mis1ify commented 2 weeks ago

It is working, after a good couple of minutes, instead of immediately. I've set up script to update last called every 10 seconds, and it works but the logs are filled of error with API: TooManyRequests.

danielbrunt57 commented 2 days ago

It is working, after a good couple of minutes, instead of immediately. I've set up script to update last called every 10 seconds, and it works but the logs are filled of error with API: To

That is an Amazon restriction! AMP has to poll Amazon to determine Last Alexa as Amazon pushes nothing to HA.

I installed my integration with polling every 3600 seconds.
The default 60 seconds gives me Too many requests.
600 still gave me Too many requests. 3600 seems to be okay so far but it's far too long.
So all of my automations/scripts update Last Alexa on an as needed basis before she speaks to the last Alexa spoken too. I'll share my scripts if you like...

Mis1ify commented 2 days ago

That's what I thought, amazon restriction. It really sucks. Please, share your scripts if you may.