Play media

Use this action to play media on a Music Assistant player. It gives you more control than the standard Play media action: you can queue multiple items at once, point at a specific track or album, and turn on radio mode to fill the queue with similar tracks.

Using this action from the user interface

If you prefer building automations and scripts visually, Home Assistant walks you through this action step by step. You pick what to target, tweak a few options, and save. No YAML knowledge required.

To play media from an automation or a script:

  1. Go to Settings > Automations & scenes.
  2. Open an existing automation or script, or select Create automation > Create new automation.
  3. If you’re setting up a new automation, add a trigger in the When section. Scripts don’t need a trigger. They run when something else calls them.
  4. In the Then do section, select Add action.
  5. Select what you want to control. Under By target (see Targets), select the Music Assistant media player you want to play media on.
  6. From the actions shown for that target, select Play media.
  7. Fill in the options you want to use.
  8. Select Save.

Options in the UI

Media ID(s)

The URI or name of the item you want to play. Specify a list to play or enqueue multiple items.

Media type

The type of content to play, such as artist, album, track, or playlist. Determined automatically when omitted.

Artist name

When specifying a track or album by name in the Media ID field, you can optionally restrict results by this artist name.

Album name

When specifying a track by name in the Media ID field, you can optionally restrict results by this album name.

Enqueue

Whether the content should be played now or added to the queue.

Enable radio mode

Turns on radio mode to auto-generate a playlist based on the selection.

Using this action in YAML

If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.

In YAML, refer to this action as music_assistant.play_media. A basic example looks like this:

ActionActions are used in several places in Home Assistant. As part of a script or automation, actions define what is going to happen once a trigger is activated. In scripts, an action is called *sequence*. [Learn more]
action: music_assistant.play_media
target:
  entity_id: media_player.kitchen_speaker
data:
  media_id: spotify://playlist/aabbccddeeff

Options in YAML

media_id string | list Required

The URI or name of the item you want to play. Specify a list to play or enqueue multiple items.

media_type string

The type of content to play. One of: artist, album, audiobook, folder, playlist, podcast, track, or radio. Determined automatically when omitted.

artist string

When specifying a track or album by name in the media_id field, you can optionally restrict results by this artist name.

album string

When specifying a track by name in the media_id field, you can optionally restrict results by this album name.

enqueue string

Whether the content should be played now or added to the queue. One of: play, replace, next, replace_next, or add.

radio_mode boolean

Turns on radio mode to auto-generate a playlist based on the selection.

Targets of the action

This action requires a target. The target is the object of the action. You can point the action at a single entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more], a device, an area, a floor, or a label, and Home Assistant will run the action on every matching media_player entity behind that target.

  • Entity: one specific media_player entity, such as media_player.living_room.
  • Device: every media_player entity that belongs to a device.
  • Area: every media_player entity in a room or area.
  • Floor: every media_player entity on a floor.
  • Label: every media_player entity that shares a label.

You can also select different target types in one action. For example, you can add a specific entity and an area as targets in the same action to run the action on both of them at once.

Good to know

  • The media_id can be a track, artist, or album name (for example, Queen), a name combined with an artist (for example, Queen - Innuendo), a streaming provider URI (for example, spotify://artist/12345), or a streaming provider URL.

Try it yourself

Ready to test this? Open Developer tools > Actions, search for this action, fill in the fields, and select Perform action. You see what happens on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] without writing a line of YAML.

Still stuck?

The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the action you’re calling and what you expected to happen, or share on our subreddit /r/homeassistant.

Tip

AI assistants like ChatGPT or Claude can also explain actions or suggest the right one when you describe what you want in plain language.

Related actions

These actions work well alongside this one:

  • Play announcement: Plays an announcement on a Music Assistant player with fine-grained control options.

  • Transfer queue: Transfers a player’s queue to another Music Assistant player.