Media player

Interacts with media players on your network.

Note

Building block integration

This media player is a building block integration that cannot be added to your Home Assistant directly but is used and provided by other integrations.

A building block integration differs from the typical integration that connects to a device or service. Instead, other integrations that do integrate a device or service into Home Assistant use this media player building block to provide entities, services, and other functionality that you can use in your automations or dashboards.

If one of your integrations features this building block, this page documents the functionality the media player building block offers.

Media player states

A media player can have the following states. Each item shows the label you see in the Home Assistant interface, followed by the state as Home Assistant stores it. If you write templates or edit automations in YAML, use the stored state.

  • Off (off): The media player is turned off and is not accepting commands until turned on.
  • On (on): The media player is turned on, but no details on its state are currently known.
  • Idle (idle): The media player is turned on and accepting commands, but not playing any media. For example, it might show a home screen.
  • Playing (playing): The media player is currently playing media.
  • Paused (paused): The media player has media loaded and is paused.
  • Buffering (buffering): The media player is preparing to start playback of media.
  • Unavailable (unavailable): The entity is currently unavailable.
  • Unknown (unknown): The state is not yet known.

List of triggers

The Media player integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] provides the following triggers. Each link below opens a dedicated page with examples, fields, and a step-by-step UI walkthrough.

For an overview of every trigger across all integrations, see the triggers reference.

List of conditions

The Media player integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] provides the following conditions. Each link below opens a dedicated page with examples, fields, and a step-by-step UI walkthrough.

For an overview of every condition across all integrations, see the conditions reference.

List of actions

The Media player integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] provides the following actions. Each link below opens a dedicated page with examples, parameters, and a step-by-step UI walkthrough.

For an overview of every action across all integrations, see the actions reference.

Media player automation examples

Here are a few examples of how you can use Media player triggers and conditions in automations.

Tip

You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.

Automation: dim the room when a movie starts

When the living room TV starts playing, dim the lights so the room is ready for watching.

  • Trigger: Media player started playing
    • Target: Living room TV
  • Action: Turn on light
    • Target: Living room lights
YAML example for dimming the room when a movie starts
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Dim the room when the TV starts playing"
triggers:
  - trigger: media_player.started_playing
    target:
      entity_id: media_player.living_room_tv
actions:
  - action: light.turn_on
    target:
      entity_id: light.living_room_lights
    data:
      brightness_pct: 25

Automation: send a bedtime reminder if audio is still playing

At bedtime, check whether the bedroom speaker is still playing, and send a notification if it is.

  • Trigger: Time: 23:00
  • Condition: Media player is playing
    • Target: Bedroom speaker
  • Action: Send a notification message
    • Target: My Device (notify.my_device)
YAML example for a bedtime playback reminder
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Remind me when audio is still playing at bedtime"
triggers:
  - trigger: time
    at: "23:00:00"
conditions:
  - condition: media_player.is_playing
    target:
      entity_id: media_player.bedroom_speaker
actions:
  - action: notify.send_message
    target:
      entity_id: notify.my_device
    data:
      message: >
        Bedroom audio is still playing.

Device class

The device class tells Home Assistant what kind of media player an entity is, such as a TV or a speaker. Home Assistant uses the device class to choose the icon. Google Assistant, Alexa, and Apple Home use the device class to decide what kind of device to show.

The integration that provides the media player sets the device class.

Device classes in automations and templates

  • Automations: The device class doesn’t change how a media player works in automations.
  • Templates: The device class is the device_class attribute of the entity. Use the stored value, such as tv. For example, you can find entities by device class.

List of available device classes

A media player without a device class is a generic media player and shows by default.

Each item shows the name you see in the Home Assistant interface, followed by the device class as Home Assistant stores it.

  • TV (tv): A television.
  • Speaker (speaker): A speaker.
  • Receiver (receiver): A device that takes audio and video input and outputs it to speakers and displays.
  • Projector (projector): A projector.