The media_player Entity: TV, Speaker, Soundbar, Receiver, Tablet, and Player

Module 22 · Lesson 2

The media_player Entity: TV, Speaker, Soundbar, Receiver, Tablet, and Player

Every device that plays sound or video in HA becomes a media_player entity, but not every one of them can do the same things. Before you build anything, you need to know what your hardware actually supports.

Budget around 65 minutes. Example entities: media_player.living_room_speaker, media_player.living_room_tv, media_player.receiver.

A Real-Life Problem: An Automation That Tries to Change the TV's Volume With No Remote

You write an automation calling media_player.volume_set on your TV, but nothing happens: it turns out that specific TV's integration only supports turning it on, off, and switching source, with no volume control over the network, because the manufacturer doesn't expose that function through the protocol the integration is built on. Before you design an automation, check the real capabilities (attributes and supported_features) of the specific entity, don't assume "media_player" means full control.

How to Check an Entity's Real Capabilities

In Developer Tools → States, pick your media_player entity and look at its attributes. The key one is supported_features: a bit number representing the sum of supported functions (PLAY, PAUSE, VOLUME_SET, VOLUME_MUTE, SELECT_SOURCE, PLAY_MEDIA, GROUPING, and others). You don't have to decode the number by hand: the media-control card on an HA dashboard only shows the buttons a given entity actually supports, so a missing volume button on the card is a signal the integration doesn't expose it.

Device typeTypical supportCommon limitation
Smart speaker (Sonos, Google, Alexa)full control, groupingdependency on the manufacturer's cloud
Smart TVon/off, source, sometimes volumeno PLAY_MEDIA for arbitrary files
Soundbar/receiver (networked)volume, source, sometimes groupingintegration quality varies by model, sometimes incomplete
Tablet (HA app as a media_player)TTS, showing the dashboardno sensible system volume control from HA

Basic media_player Service Calls

script:
  speaker_set_volume_and_play:
    alias: "Test: set volume and play"
    mode: single
    sequence:
      - action: media_player.volume_set
        target:
          entity_id: media_player.kitchen_speaker
        data:
          volume_level: 0.4
      - action: media_player.media_play
        target:
          entity_id: media_player.kitchen_speaker

volume_level takes a value from 0.0 to 1.0, not a percent: a common beginner mistake is entering 40 instead of 0.4, which usually sets the volume to maximum (HA clamps the value to its valid range) instead of the intended 40%.

media_player Entity States

Typical states are playing, paused, idle, off, standby, unavailable. The TTS automations from Lesson 5 need to check state before an announcement: sending a TTS command to a speaker in the off state usually just won't wake it, depending on the integration.

"off" in one integration, "standby" in another
Different integrations map the same physical device state to an HA entity state differently. Don't assume what a state means based on its name: check the real state of your specific entity in Developer Tools instead of copying conditions from examples online without verifying them.

Grouping: Why It's Not One Single Function

"Play music in every room at once" requires a grouping (multiroom) function, which works differently depending on the ecosystem: Sonos has its own grouping protocol, Google/Nest has its own, and Music Assistant (Lesson 3) can unify grouping across different ecosystems, at the cost of some limitations. Not every combination of speakers from different brands can be grouped directly without Music Assistant acting as a go-between.

HDMI-CEC: Controlling a TV Without the Manufacturer's Integration

If your TV doesn't have a good cloud integration, or you don't want to create a manufacturer account, HDMI-CEC offers an alternative: it's a single signal wire in a standard HDMI cable (pin 13), through which connected devices send each other commands with no network configuration or pairing at all. The computer running Home Assistant needs CEC support and a physical HDMI connection to the TV: every Raspberry Pi supports CEC natively, on other hardware a USB-CEC adapter is sometimes needed.

The HDMI-CEC integration provides on, off, volume, and source selection as standard media_player controls, working right away in dashboards, automations, and voice commands. Before setting it up, it's worth running the CEC Scanner add-on from the HA add-on repository to detect connected devices and their addresses, but don't leave it running permanently at startup, since it conflicts with the integration itself.

Sony Bravia (2013+), Samsung, LG webOS: have dedicated HA integrations independent of CEC, usually richer than CEC alone.

HDMI-CEC: a universal fallback when there's no manufacturer integration, but limited to basic commands.

Naming in the configuration: you map HDMI ports to device names, like 'Living room TV' or 'Soundbar,' which creates a separate media_player entity for each.

Speaker Groups and Playback Synchronization

Beyond controlling a single player, the media_player entity supports the concept of groups: several physical speakers combined into one logical unit, playing the same audio in sync. The media_player.join service combines the given players into a group, and media_player.unjoin splits it apart. Synchronization between different manufacturers' speakers can be imperfect: speakers from the same ecosystem (say, all Sonos) sync almost perfectly, while combining different brands through Music Assistant can introduce a small but noticeable delay between rooms.

Debugging a media_player Entity Through Developer Tools

Before you start writing automations that use media_player, it's worth spending a few minutes exploring the Developer Tools States tab: pick your player's entity and look through the full list of attributes, not just the plain playing/paused/idle state. Attributes like volume_level, media_title, or supported_features vary significantly between manufacturers, and knowing the exact data structure of your specific device saves hours of debugging automations that should work in theory but, in practice, reference an attribute that doesn't exist.

Cross-Platform Grouping: Combining Sonos and Chromecast Together

The natural boundary of speaker grouping is the ecosystem: Sonos speakers group with each other very well, and so does Chromecast Audio, but combining both at once into one coherent group requires Music Assistant, covered in the next lesson, since the two platforms' native grouping mechanisms aren't compatible with each other. That's one of the main practical reasons this course recommends Music Assistant as a go-between layer rather than relying solely on each brand's native integration.

Track Metadata and Cover Art on the Dashboard

Beyond the playback state itself, media_player entity attributes often include media_title, media_artist, and entity_picture (the URL of album cover art), which the media-control card automatically uses to show a richer preview on the dashboard instead of plain text. It's worth checking in Developer Tools whether your specific player even provides this data: not every music source (a simple internet radio stream, for instance) passes along full metadata.

Integration With High-End Home Theater Systems

Advanced home theater systems, with a dedicated AV processor and multiple speaker channels, often have their own extensive APIs (manufacturer protocols like Denon, Marantz, or Yamaha), allowing much deeper integration than the basic media_player functions: selecting a specific sound mode (movie, music, night), controlling individual speaker channels, or accessing advanced room correction settings. Home theater enthusiasts should check whether their specific model has a dedicated community integration that goes beyond the standard protocol.

Documenting Your media_player Entity Mapping in the Smart Home Notebook

With several or a dozen players around the house, it's worth keeping a simple table in your smart-home notebook mapping each media_player entity to its physical location and device brand. This seemingly trivial habit saves a lot of time when writing the rest of this module's automations, when you need to quickly recall exactly which entity ID corresponds to the speaker in a specific room.

Documenting supported_features for Quick Reference

The supported_features attribute, visible in Developer Tools, is a numeric bitmap indicating which functions a given player supports (play, pause, volume_set, grouping, and others). It's worth noting down once, in your smart-home notebook, exactly which functions each of your players supports, instead of rediscovering it by trial and error every time you write another automation using that device.

How to Test This Lesson

1. Check the attributes of every media_player entity you have in Developer Tools.

2. Note which devices support volume_set and which only support on/off.

3. Test the volume-setting script on one speaker and confirm the 0.0-1.0 value.

Common Mistakes

Volume as a percent instead of 0.0-1.0: a sudden blast at full volume instead of a quiet announcement.

Assuming a function without checking supported_features: the automation silently does nothing.

Copying state conditions from the internet with no verification: "off" doesn't always mean the same thing.

Practical Task

☐ Make a list of every media_player in your house with its real supported functions.

☐ Test the volume-setting script on at least one speaker.

☐ Check the off/idle/standby states of your devices in Developer Tools.

Key Takeaways

Not every media_player supports the same functions: check supported_features.

volume_level is a 0.0-1.0 range, not a percent.

Multiroom grouping depends on the ecosystem: Music Assistant helps unify different brands.

What's Next

Next lesson: Music Assistant: A Hub for Music, Players, Libraries, Radio, and Multiroom. You'll learn the tool that unifies music control across different speaker brands.

Finished this lesson?