Cannot play Jellyfin audio in HA Media menu?

Hello

I have Jellyfin and Home Automation set up. I can select an audio device in Home assistant, click Browse media, and play a Jellyfin album, all good. But if i open the Media menu in Home Assistant, select Jellyfin, select an album, then choose an audio device (or group), and press play, it never works. Pretty much nothing happens. It does not matter what album I choose, or what device I choose.

Is there something I need to do to get that to work? Home Assistant is the latest version, running on HASIO on a Raspberry Pi.

Thanks

I think I understand what is going on. The Home Automation integration with Jellyfin is not actually using Jellyfin features, it seems to be just using Jellyfin as an MP3 source. Most of my albums are not in a format that can be played directly on the devices, and Jellyfin handles this. But initiating the play action from Home Assistant Jellyfin integration does not request jellyfin to play it on the device, with transcoding. It is a pitty, I would like to have Home Automation triggers to play Jellyfin media on the audio devices.

I maybe having same issue.
Did you figure out how to make jellyfin play music through HA ?

Sort of. It is not easy. I manually copied the Stream URL for each song. I put the long random Song ID value from the URL for each song into an array in a Node Red Function Node, put the api_key in a safe space in Node Red, then used the function node to create an array of those songs’ full stream URL.

Then I created Node Red workflow to have a bluetooth button, when I push it, then a random song is played from that array. It watches for the speaker to go idle, and then starts another random stream. Pressing the bluetooth button again stops the play. Not pretty but it works. I limited it only to some coding music for my study. That option is not workable for a large number of songs on a large number of speakers.

Likely I could write some code to pull song IDs from the database for a specific album, but I have not spent the time.

1 Like

I’m having a similar issue. I can reproduce it on a development version of HA, but I’m having trouble figuring out where any improvements could be made.

Interestingly, if I ask it to play a movie in my library it will do it, but playing an audio file does not seem to work. It just hangs there forever.

There are a few movies where it doesn’t work, but most seem to. I have not found an audio file where it works correctly.

What is very strange to me is that I put a ton of logging debug statements all over the integration, but none of them seem to trigger when I’m browsing the media library through HA or clicking play regardless of if I hit something that works or doesn’t. Either I setup logging wrong, or I’m looking in the incorrect place for the relevant code.

EDIT: Apparently I didn’t put enough logging statements in. I (with the help of deep seek) wrote a script that uses libCST to add a decorator to every function call in the jellyfin integration:

from functools import wraps
import logging
import sys

def debug_decorator(func):
    modname = func.__module__
    funcname = func.__qualname__
    qualname = f'{modname}.{func.__qualname__}'
    double_log(f'Decorating {qualname}')

    @wraps(func)
    def wrapper(*args, **kwargs):
        module = sys.modules[modname]
        logger = logging.getLogger(module.__name__)
        logger.info(f'Call {funcname}')
        try:
            result = func(*args, **kwargs)
        except Exception as ex:
            logger.error(f'Error: {ex}')
        logger.debug(f'Return from {funcname}')
        return result

    return wrapper

This decorator will log a statement before and after each call.

I pressed the “play” button, this is what I saw:

2025-03-03 01:26:28.578 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from JellyfinSource.async_resolve_media
2025-03-03 01:26:28.589 INFO (MainThread) [homeassistant.components.jellyfin.media_source] Call JellyfinSource._get_stream_url
2025-03-03 01:26:28.589 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from JellyfinSource._get_stream_url
2025-03-03 01:26:28.589 INFO (MainThread) [homeassistant.components.jellyfin.media_source] Call _media_mime_type
2025-03-03 01:26:28.589 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from _media_mime_type
2025-03-03 01:26:31.076 INFO (MainThread) [homeassistant.components.jellyfin.media_source] Call JellyfinSource.async_resolve_media
2025-03-03 01:26:31.076 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from JellyfinSource.async_resolve_media
2025-03-03 01:26:31.083 INFO (MainThread) [homeassistant.components.jellyfin.media_source] Call JellyfinSource._get_stream_url
2025-03-03 01:26:31.083 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from JellyfinSource._get_stream_url
2025-03-03 01:26:31.083 INFO (MainThread) [homeassistant.components.jellyfin.media_source] Call _media_mime_type
2025-03-03 01:26:31.083 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from _media_mime_type

So, now some of the statements about getting Stream URLs makes more sense. Next step will be to see if there is anything we can do on the HA or jellyfin Python client side to resolve the issue.

EDIT EDIT: I wrote code to dump the values of the args and returns, and saw the streaming url looks something like this:

http://{HOST}:{JELLY_PORT}/Audio/{AUDIO_ID}/universal?UserId={USER_ID}&DeviceId={DEVICE_ID}&MaxStreamingBitrate={BIT_RATE:=140000000}&AudioCodec={CODEC:aac}&api_key={api_key}

And entering that URL gives an error “Error processing request.”, so I assume this is something that either requires better info about metadata such as codec and bitrate, or there is something we can do on the jellyfin side to fix this issue.