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

Transferring playback error #506

Closed
xmow49 opened this issue Dec 31, 2024 · 9 comments
Closed

Transferring playback error #506

xmow49 opened this issue Dec 31, 2024 · 9 comments
Assignees
Labels
beta Related to the beta program bug Something isn't working

Comments

@xmow49
Copy link

xmow49 commented Dec 31, 2024

The problem

Hello,
Thanks for the work on spotcast v5.

Sometimes, when I use spotcast.transfer_playback I have an error (see Anything in the logs that might be useful for us?)

This error occur only rarely; do you have any information why ? and how to avoid it ?

Thanks

System Health details

System Information

version core-2024.12.5
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.13.0
os_name Linux
os_version 6.6.62-haos-raspi
arch aarch64
timezone Europe/Paris
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
HACS Data ok
GitHub API Calls Remaining 5000
Installed Version 2.0.1
Stage running
Available Repositories 1498
Downloaded Repositories 41
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 14.1
update_channel stable
supervisor_version supervisor-2024.12.0
agent_version 1.6.0
docker_version 27.2.0
disk_total 117.3 GB
disk_used 33.7 GB
healthy true
supported true
host_connectivity true
supervisor_connectivity true
ntp_synchronized true
virtualization
board yellow
supervisor_api ok
version_api ok
installed_addons Samba share (12.3.2), Mosquitto broker (6.4.1), Studio Code Server (5.18.0), Advanced SSH & Web Terminal (19.0.0), MariaDB (2.7.1), ESPHome Device Builder (2024.12.2), Network UPS Tools (0.14.0), Samba Backup (5.2.0), phpMyAdmin (0.11.0), OVH DynDNS (1.0.0), Keepalived (1.14), SomfyProtect2MQTT (2024.9.0), Portainer (dev), Silicon Labs Multiprotocol (2.4.5), ESPresense Companion (1.0.14), MQTT Explorer (browser-1.0.3), Cloudflared (5.2.4), Matter Server (6.6.1)
Dashboards
dashboards 11
resources 27
views 19
mode storage
Recorder
oldest_recorder_run 20 décembre 2024 à 18:52
current_recorder_run 29 décembre 2024 à 17:53
estimated_db_size 1349.47 MiB
database_engine mysql
database_version 10.11.6
Spotcast
Version 5.0.0-b19
Oasz8tke------nzu4pqgipg68 Is Default true
Oasz8tke------nzu4pqgipg68 Public Endpoint ok
Oasz8tke------nzu4pqgipg68 Public Token healthy
Oasz8tke------nzu4pqgipg68 Private Endpoint ok
Oasz8tke------nzu4pqgipg68 Private Token healthy
Oasz8tke------nzu4pqgipg68 Product premium
Spotify
api_endpoint_reachable ok

What type of installation are you running?

Home Assistant OS

Diagnostics information

home-assistant_spotcast_2024-12-31T10-45-45.450Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 743, in async_trigger
    return await self.action_script.async_run(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        variables, trigger_context, started_action
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1801, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 528, in _async_step
    self._handle_exception(
    ~~~~~~~~~~~~~~~~~~~~~~^
        ex, continue_on_error, self._log_exceptions or log_exceptions
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 558, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/spotcast/services/service_handler.py", line 59, in async_relay_service_call
    await handler(self.hass, call)
  File "/config/custom_components/spotcast/services/transfer_playback.py", line 63, in async_transfer_playback
    call_data = await async_rebuild_playback(call_data, account)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/spotcast/services/transfer_playback.py", line 87, in async_rebuild_playback
    context_uri: str = last_playback_state["context"]["uri"]
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Additional information

No response

@xmow49 xmow49 added beta Related to the beta program bug Something isn't working pending-triage The issue is awaiting a review from a maintainer labels Dec 31, 2024
@fcusson
Copy link
Collaborator

fcusson commented Dec 31, 2024

@xmow49 seems to be an edge case for when your last known active playback was context less (meaning you have no currently active playback and the last known playback cannot be resumed automatically). I'll check to push a fix, shouldn't be too complex.

The default in this specific case should be to play your liked songs, since their is no context to resume from.

@fcusson fcusson removed the pending-triage The issue is awaiting a review from a maintainer label Dec 31, 2024
@fcusson
Copy link
Collaborator

fcusson commented Dec 31, 2024

@xmow49 should be fixed in build 20

@xmow49
Copy link
Author

xmow49 commented Jan 1, 2025

Hello @fcusson
Many thanks for this quick fix.
For now, it's working, I will let you know if any other error occurs.

Thanks again and happy new year.

@fcusson fcusson closed this as completed Jan 1, 2025
@fcusson
Copy link
Collaborator

fcusson commented Jan 1, 2025

@xmow49 glad to here it.

Happy new year to you too

@xmow49
Copy link
Author

xmow49 commented Jan 4, 2025

Hi,
Today I have received this error:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/spotcast/services/service_handler.py", line 59, in async_relay_service_call
    await handler(self.hass, call)
  File "/config/custom_components/spotcast/services/transfer_playback.py", line 56, in async_transfer_playback
    "context", {}).get("uri")
                   ^^^
AttributeError: 'NoneType' object has no attribute 'get'

I think is also an empty playback list.
@fcusson Do you know the timeout of an active playback on Spotify?
Can it be related to a certain amount of time of non playing music?

Thanks

@fcusson fcusson reopened this Jan 4, 2025
@fcusson
Copy link
Collaborator

fcusson commented Jan 4, 2025

@xmow49 that's my bad, I wrongly made the assumption that the key context was missing from the playback state but in reality, the key exist, but return null. That's a quick fix.

Can it be related to a certain amount of time of non playing music?

I'm already taking into account the expiration of the playback context, that's actually while trying to rebuild the context from the last known state that you are getting this error. Just tweaked the function a bit, should work better now. I also modified the tests to better account for the real format of a context less playback state.

fcusson added a commit that referenced this issue Jan 4, 2025
@fcusson
Copy link
Collaborator

fcusson commented Jan 4, 2025

just pushed build 21, should be working fine now

@xmow49
Copy link
Author

xmow49 commented Jan 4, 2025

Thanks again for your responsiveness.
I'll keep you informed of any further errors.

@fcusson fcusson added the more info needed Maintainers will be unable to work on the issue until more information is provided label Jan 9, 2025
@fcusson
Copy link
Collaborator

fcusson commented Jan 24, 2025

Issue inactive for 3 weeks. I'll close it for the moment. Please reopen if needed

@fcusson fcusson closed this as completed Jan 24, 2025
@fcusson fcusson removed the more info needed Maintainers will be unable to work on the issue until more information is provided label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Related to the beta program bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants