Skip to content

Spotify integration can't start playing music because "No active playback device found" #69306

Description

@kompre

The problem

Hi,

I've set up an automation that will select an echo device as source (media_player.select_source) and play a spotify playlist (media_player.play_media).

This automation has worked as intended during the testing phase, but fails in "production", to be precise it failed at the step of playing the playlist when the automation got triggered by the time condition (alarm clock).

The trace will show the error message mentioned in the title No active playback device found

I've tested a little and found out that the automation worked during initial phase of testing because I've opened the spotify app on my phone to check if the source had been correctly switched to the echo device, therefore I already had an active session started. But when the automation is supposed to trigger, before the alarm clock, there is no active session, spotify has been dormant, like me, for awhile.

I can reproduce the issue quit easily, I just need to manually run the automation (or call the service via developer tools) without opening the spotify app or playing any spotify media for awhile, and it will fail every time with the same error message.

How can I cold start a spotify session automatically, without me needing to open the app or start playing music? Or is it the intended use?

I am trying to correct a dumb behavior of my echo alarm clock that, even if I choose what particular playlist to play as alarm clock, the echo will not play such playlist, but instead start playing the last song/playlist I was listening to the day before.

What version of Home Assistant Core has the issue?

core-2022.3.8

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

spotify

Link to integration documentation on our website

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

Diagnostics information

I'll attach the trace timeline of the last failed run

Triggered manually at 4 April 2022, 22:21:45
Call service media_player.select_source on entities media_player.spotify_kompre
turn_on Echo camera shuffle switch
Call service media_player.volume_mute on entities media_player.echo_camera
Delay for {"hours":0,"minutes":0,"seconds":15,"milliseconds":0}
15 seconds later
Play MORNING VIBES ☕️ on Spotify kompre
Stopped because an error was encountered at 4 April 2022, 22:22:00 (runtime: 15.47 seconds)

No active playback device found

Example YAML snippet

(edited to cut unnecessary step of the automation)
id: '1648040302430'
alias: Reset morning song
description: ''
trigger:
  - platform: time
    at: sensor.pre_sveglia
condition: []
action:
  - service: media_player.select_source
    data:
      source: Echo camera
    target:
      entity_id: media_player.spotify_kompre
  - service: media_player.play_media
    target:
      entity_id: media_player.spotify_kompre
    data:
      media_content_id: spotify:playlist:0BP6NWUDH0BAuH6OrqEfRv
      media_content_type: spotify://playlist
    metadata:
      title: MORNING VIBES ☕️
      thumbnail: https://i.scdn.co/image/ab67706c0000bebb514f45fe52c77027574db797
      media_class: playlist
      children_media_class: track
      navigateIds:
        - {}
        - media_content_type: spotify://current_user_playlists
          media_content_id: current_user_playlists
        - media_content_type: spotify://playlist
          media_content_id: spotify:playlist:0BP6NWUDH0BAuH6OrqEfRv

Anything in the logs that might be useful for us?

Logger: homeassistant.components.automation.reset_morning_song
Source: components/automation/__init__.py:514
Integration: Automation (documentation, issues)
First occurred: 22:22:00 (1 occurrences)
Last logged: 22:22:00

Error while executing automation automation.reset_morning_song: No active playback device found

Additional information

No response

Metadata

Metadata

Assignees

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions