Updated: Nov 3, 20232 min read

How to integrate Youtube Music into Home Assistant

Written by: Fixt

Updated simpler version of this tutorial is available here

YT Music Player Integration

First, install it from HACS

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

You can use this button to be redirected to the download page. It will open the repository's page in HACS.

then you can use this button to start the setup process:

Open your Home Assistant and show de integration menu

You can use this button to start the setup process. It will open the integration page in Home Assistant.

  1. YT Music Player Documentation
  2. Mini Media Player Documentation

Automation Example

config/automations.yaml

alias: yt music automation
description: ""
trigger:
  - platform: calendar
    event: end
    offset: "0:5:0"
    entity_id: calendar.fixt
action:
  - service: media_player.select_source
    data:
      source: kitchen
    target:
      entity_id: media_player.ytube_music_player
  - service: media_player.play_media
    data:
      media_content_id: RDCLAK5uy_mplKe9BIYCO3ZuNWSHZr48bm9DUDzbWnE
      media_content_type: playlist
    target:
      entity_id: media_player.ytube_music_player
mode: single

Get List of Media Players

Jinja2 Template

{{ expand(states.media_player) 
   | rejectattr('state', 'eq', 'unavailable')
   | rejectattr('entity_id', 'eq', 'media_player.ytube_music_player')   
   | map(attribute='entity_id')    
   | list  
   | replace('media_player.', '') 
}}

Mini media player card

Custom Card

type: custom:mini-media-player
entity: media_player.ytube_music_player
artwork: cover
hide:
 shuffle: false
 icon_state: false
shortcuts:
 columns: 3
 buttons:
   - name: Living Room
     type: source
     id: living_room
   - name: Kitchen
     type: source
     id: kitchen
   - name: Bedroom
     type: source
     id: bedroom
   - name: My Likes
     type: playlist
     id: RDCLAK5uy_mplKe9BIYCO3ZuNWSHZr48bm9DUDzbWnE
   - name: Playlist 2
     type: playlist
     id: RDCLAK5uy_n0_d5SZbBxft3QDuk3gjp2BO1Q4H6tclU

I would love to hear your comments, or suggestions on this post.


Avatar of Fixt

Fixt is a Software Engineer passionate about making the world a better place through technology and automation.