Selora Homes Selora Homes

Automate Amazon Music on Wiim/Linkplay with Home Assistant

Learn how to automate specific song playback from Amazon Music on Wiim and other Linkplay-enabled devices using Home Assistant, leveraging the Alexa Media Player custom component.

Music Amazon-Music Wiim Linkplay Automation Alexa-Media-Player Home-Assistant

Automating specific song playback from Amazon Music on Wiim and other Linkplay-enabled devices in Home Assistant isn’t straightforward with native integrations. This guide explains the limitations of current tools and provides a reliable workaround using the Alexa Media Player custom component.

The Challenge: No Direct Integration

As of late 2024, there is no direct way to tell a Wiim device to play a specific song from Amazon Music using Home Assistant’s built-in tools or popular music management integrations.

  • Linkplay Integration: The official Home Assistant Linkplay integration can only play pre-configured presets (e.g., a specific radio station or playlist you’ve saved in the Wiim Home app). It cannot accept a URL or song title.
  • Music Assistant (MA): While powerful, Music Assistant does not have a music provider for Amazon Music. It cannot browse or stream content from the service.

The Solution: Alexa Media Player

The most effective method is to leverage the unofficial Alexa Media Player custom component. This integration communicates with the Alexa API, allowing you to control any Alexa-compatible device, including Wiim players that have been linked to your Amazon account.

The core idea is to ask Alexa to play a song once, capture the unique media identifier for that song, and then use that identifier in your automations.

Prerequisites

  1. HACS: You need the Home Assistant Community Store (HACS) installed.
  2. Alexa Media Player: Install this custom component via HACS and follow its configuration steps to link your Amazon account.
  3. Amazon Music Subscription: You need an active Amazon Prime or Amazon Music Unlimited subscription.
  4. Wiim Linked to Alexa: Ensure your Wiim device is discoverable and controllable as a speaker within your Amazon Alexa app.

Step-by-Step Guide

Step 1: Capture the Media ID

First, you need to get the unique ID for the song or playlist you want to automate.

  1. Play the Media: Ask the corresponding Echo device or your Wiim (if it has Alexa built-in) to play your desired media.

    “Alexa, play ‘Blinding Lights’ by The Weeknd on Amazon Music.”

  2. Open Developer Tools: In Home Assistant, go to Developer Tools > States.
  3. Find Your Player: Locate the media player entity for your Alexa device (e.g., media_player.living_room_echo).
  4. Copy the Attributes: In the attributes list, find and copy the values for media_content_id and media_content_type. They will look something like this:
    • media_content_id: amzn_music:song:B08424V334
    • media_content_type: AMAZON_MUSIC_TRACK

Step 2: Create the Automation

Now, use the captured information in a media_player.play_media service call within a script or automation.

# Example Script to play a specific song on an Echo device
alias: Play Blinding Lights on Demand
sequence:
  - service: media_player.play_media
    target:
      entity_id: media_player.living_room_echo
    data:
      media_content_type: AMAZON_MUSIC_TRACK
      media_content_id: amzn_music:song:B08424V334
mode: single

Example: Automating a Morning Playlist

You can use the same method for playlists. Ask Alexa to play your “Morning Motivation” playlist, capture the media_content_id (which will be different from a single track ID) and media_content_type (likely AMAZON_MUSIC_PLAYLIST), and use it in your wake-up automation.

# Part of a wake-up automation
- service: media_player.play_media
  target:
    entity_id: media_player.bedroom_echo
  data:
    media_content_type: AMAZON_MUSIC_PLAYLIST
    media_content_id: amzn_music:playlist:PL-Sg8h9sJzNHs...

Limitations

  • Unofficial API: The Alexa Media Player integration relies on an unofficial API that could change or break without notice.
  • Manual ID Capture: You must manually capture the ID for every song, album, or playlist you wish to automate. These IDs are generally persistent.
  • Requires Alexa Ecosystem: This method is entirely dependent on your devices being part of the Alexa ecosystem.

Conclusion

While direct control is lacking, the Alexa Media Player component provides a robust and reliable workaround for automating specific Amazon Music content on your Wiim and Linkplay devices. By capturing media IDs, you can integrate your favorite songs and playlists into any Home Assistant automation, from morning routines to party scenes.