Skip to content

UI Scripts

Todd Lucas edited this page Dec 28, 2024 · 3 revisions

The following scripts have been created for various user requests, so I thought I would post them here in case anyone else finds them useful.

Index

Play First Context of Category Playlists

Gets the Spotify Jazz Category Playlists and plays the context returned from the first returned result.

Example
Change the following script details for your environment:

  • YOUR_SPOTIFYPLUS_ENTITY - your SpotifyPlus entity_id.
  • YOUR_DEVICE_NAME - your Spotify Connect device name.
alias: SpotifyPlus Play First Context of Category Playlists
description: >-
  Gets the Spotify Jazz Category Playlists and plays the context returned from
  the first returned result.
sequence:
  - service: spotifyplus.get_category_playlists
    data:
      entity_id: media_player.YOUR_SPOTIFYPLUS_ENTITY
      category_id: jazz
      limit: 1
    response_variable: search_result
  - service: spotifyplus.player_media_play_context
    data:
      entity_id: media_player.YOUR_SPOTIFYPLUS_ENTITY
      context_uri: "{{ search_result.result[\"items\"][0].uri }}"
      device_id: YOUR_DEVICE_NAME

Search Spotify Tracks and Play First Match

Searches Spotify for the given track, and plays the first result returned in the list.

Example
Change the following script details for your environment:

  • YOUR_SPOTIFYPLUS_ENTITY - your SpotifyPlus entity_id.
  • YOUR_DEVICE_NAME - your Spotify Connect device name.
alias: SpotifyPlus Search Spotify Tracks and Play First Match
description: >-
  Searches Spotify for the given track, and plays the first result returned in
  the list.
sequence:
  - action: spotifyplus.search_tracks
    data:
      entity_id: media_player.YOUR_SPOTIFYPLUS_ENTITY
      criteria: "journey don't stop believing"
      limit_total: 5
    response_variable: search_result
  - action: spotifyplus.player_media_play_tracks
    data:
      entity_id: media_player.YOUR_SPOTIFYPLUS_ENTITY
      uris: "{{ search_result.result[\"items\"][0].uri }}"
      device_id: YOUR_DEVICE_NAME