How to play Jellyfin movies on Nvidia Shield via Home Assistant Voice?

I recently bought Home Assistant Voice Preview Edition, I installed Home Assistant and configured Jellyfin and Android Tv Remote (Nvidia Shield Pro) integrations.

I can use voice commands to turn on/off Shield.

I would like to use voice commands to :

  1. open Jellyfin app on Shield
  2. play a movie of choice by name

Is it doable these days ?

Did you ever figure this out? Making this work with Plex is impossible or a PITA, but I can’t find much information about this ability with Jellyfin

Nope, dont think its possible

So I found some interesting things. Some Jellyfin players support the Browse Media functionality in Home Asisstant, a web player in Firefox for example does.

Someone wrote a script that uses rest_command to query the API and obtain the media ID based on keyword searches.

One could use this in an automation to search for the media based on voice commands, and then send the play media event to the jellyfin player using the ID that was pulled via the API search.

I will need to see if the Shield player can do this.

Here’s the script that queries the API for the media ID

I had to add a line to the restful config that gets added to configuration.yaml:

rest_command:
  jellyfin_search:
    url: "http://{jellyfin_IP}:8096/Items?api_key={user_API_KEY}&searchTerm={{ search_string }}&Recursive=true&IncludeMedia=true&IncludeItemTypes={{ type }}"
    method: GET

I was able to make this work with the Shield Jellyfin app through adb

data:
  command: >-
    adb shell am start -c android.intent.category.LEANBACK_LAUNCHER -a
    android.intent.action.VIEW -d "{{jellyfin_media_id.media_id}}" -e source 30
    org.jellyfin.androidtv/.ui.startup.StartupActivity
target:
  entity_id: media_player.nvidia_shield
action: androidtv.adb_command

You need to run the script before calling this command to obtain the media_id from Jellyfin.

The adb command will pull up Jellyfin and put the media up on the screen, but it won’t play it automatically. Sending an adb play command will start playback

action: androidtv.adb_command
metadata: {}
data:
  command: input keyevent 85
target:
  entity_id: media_player.nvidia_shield

Keyevent 85 is the play/pause button. I have a BLE keyboard running on an ESP32 that can send keyboard keys, but I haven’t found the key that sends the Play/Pause event. ADB key commands are slow, but for this automation it’s not too bad.

Doing this is a lot easier and faster with a web player. For example I have a Firefox player where I open Jellyfin and the below command will play the media_id right away. I haven’t figured out how to send a command to force the web player to go into full screen yet.

action: media_player.play_media
metadata: {}
data:
  media_content_id: "{{jellyfin_media_id.media_id}}"
  media_content_type: Movie
target:
  entity_id: media_player.firefox_2
enabled: true