Media browser, Spotify, select output device?

Didn’t get this working, the friendly name wasn’t rewritten correctly to the entity-id as I use space in my names. And Spotcast was asking for the device_name. Ended up with this, which is even easier anyway:

Script:

# Spotify Start Playback
spotify_start:
  alias: 'Spotify: afspelen'
  sequence:
    - service: spotcast.start
      data:
        device_name: "{{ states('input_select.speakers') }}"
        force_playback: true
  mode: single
  icon: mdi:spotify

And automation:

# Muziek
- id: spotify_device_selected
  alias: 'Spotify: Device Selected'
  description: 'Starts music playing on the selected Chromecast Audio device'
  trigger:
  - platform: state
    entity_id: input_select.speakers
  condition: []
  action:
  - service: script.turn_on
    entity_id: script.spotify_start
  mode: single

Instead of having the script in the Lovelace GUI, I have playlists + radio available in a input_select, with a button to play the selected music to the selected speaker.

1 Like