GStreamer

The gstreamer integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] allows you to play audio via a gstreamer pipeline. Practically, this means you can play audio directly on the computer running Home Assistant. It is particularly suited for playing TTS. Advanced users can specify a pipeline to transform the audio stream and/or redirect it elsewhere.

To add a gstreamer media player to your installation, add the following to your configuration.yamlThe configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more] file. After changing the configuration.yamlThe configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more] file, restart Home Assistant to apply the changes. The integration is now shown on the integrations page under Settings > Devices & services. Its entities are listed on the integration card itself and on the Entities tab.

# Example configuration.yaml entry
media_player:
  - platform: gstreamer

Configuration Variables

name string (Optional)

Name of the media player.

pipeline string (Optional)

A gst pipeline description.

Only the music media type is supported.

Setup

And then install the following system dependencies:

Debian/Ubuntu/Rasbian:

sudo apt-get install python3-gst-1.0 \
    gir1.2-gstreamer-1.0 gir1.2-gst-plugins-base-1.0 \
    gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly \
    gstreamer1.0-tools

Red Hat/Centos/Fedora:

sudo yum install -y python-gstreamer1 gstreamer1-plugins-good \
    gstreamer1-plugins-ugly

For Fedora replace yum with dnf.

If you’re running Home Assistant in a virtual environment, you’ll need to symlink the system Python’s gi module into your virtual environment:

ln -s /path/to/your/installation/of/gi /path/to/your/venv/lib/python3.4/site-packages

On a Raspberry Pi, you may need to add the Home Assistant user to the audio group:

sudo usermod -a -G audio <ha_user>

Example usage

Using with TTS

To play TTS on your local computer (for example, if you have speakers attached to your Raspberry Pi:

media_player:
  - platform: gstreamer

script:
  tts:
    sequence:
      - action: tts.google_say # or amazon_polly, voicerss, etc
        target:
          entity_id: media_player.gstreamer
        data:
          message: "example text-to-speech message"

Using with Snapcast

To play to a named pipe for consumption by Snapcast:

media_player:
  - platform: gstreamer
    pipeline: "audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! filesink location=/tmp/snapcast_gstreamer"