Roon module for Home Assistant

Can you turn up the logging level, and see if there is anything useful in the logs when you can’t change the volume. Start with ‘info’ but you could also try ‘debug’.

You can do this by adding the following to your configuration.yaml.

logger:
  default: warning
  logs:
    homeassistant.components.roon: info
    roonapi: info

I recall someone mentioning something similar before, and I think I added some debugging information in case it happened again….

Is there anything in common with the zones that do this?

Thanks Greg,

I have actually rebooted my server this afternoon and the problem hasnt reappeared yet, but I’ve had it on a few occasions now so it “should” come back. I’ll enable the logging, but I’m about to travel for a week so I won’t ont be able to give a meaningful update for a while.

In terms of commonality, all of my roon endpoints are ropieee, one with a USB DAC and one with a DAC/AMP hat.

Interesting.

Roon sends information about the volume attributes of each endpoint to the HA integration.

Because you can reconfigure this in roon at anytime, the information is updated during use, not just when HA starts.

So it sounds like things are OK when HA starts, but go wrong at some point later. It would be very interesting to know when this happens.

I suspect the log messages you will see when the volume change fails are either set_volume_level failed for entity followed by some debugging information or This endpoint has fixed volume.

Hi,

I’m not sure if this is the right place to report an issue with Roon integration in Home Assistant, but here I go.
When I browse the library from Home Assistant and switch directly from Artists to Albums I receive an error:


If I return to “Explore” and re-enter the Library I don’t get the error.

Logger: homeassistant.components.websocket_api.http.connection
Source: components/roon/media_browser.py:117
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 05:56:03 (7 occurrences)
Last logged: 08:28:37
[139893182064192] Error handling message: Unknown error (unknown_error) Dennis from 127.0.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0)
[139893356248768] Error handling message: Unknown error (unknown_error) Admin from 127.0.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1310, in websocket_browse_media
    payload = await player.async_browse_media(media_content_type, media_content_id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/roon/media_player.py", line 529, in async_browse_media
    return await self.hass.async_add_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/roon/media_browser.py", line 41, in browse_media
    return library_payload(roon_server, zone_id, media_content_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/roon/media_browser.py", line 117, in library_payload
    header = result_header["list"]
             ~~~~~~~~~~~~~^^^^^^^^
TypeError: string indices must be integers, not 'str'

Logger: roonapi
Source: components/roon/media_player.py:429
First occurred: February 28, 2024 at 18:53:21 (3 occurrences)
Last logged: 08:27:08

Could not play id:3:12, result: MOO/1 COMPLETE InvalidItemKey
Playback requested but item is a list, not a playable action or action_list id: 45:0

Thanks for the report.

The way the roon browser api works is quite different from how Home Assistant works.

The current code was my first draft, and there are some things that don’t work properly (I think any attempt to go back up the hierarchy fails with the error you highlight).

Home assistant also expects tracks to have a unique id - which the roon api doesn’t provide - so that also brings many limitations.

Browsing also doesn’t work if you try and do it from multiple HA devices at the same time.

There have been very few error reports - which I guess means that the browser isn’t used widely. I expect because the roon apps themselves are fantastic for searching and browsing.

How are you using the browser, and is this causing you a problem?

Well, I’m in the proces from migrating my previous home automation setup to Home Assistant. I discovered the Roon integration and was testing it. I was impressed by the library browser. However in real life I will use the Roon app for browsing the library most of the time. I think the Roon library functionality from Home assistant will probably be limited to playlists and live radio. (+ start/stop/pause/skip forward/skip backwards)

Thank you for the Roon integration in Home Assistant!

2 Likes

Glad it’s useful.

I think most people’s use is similar.

The play media calls are pretty useful for playing radio stations / playlists from buttons and remote controls.

But even if I made the browser work better (which is hard - but probably possible), it’s still not a patch on roon.

FWIW I think quite a few people also use the automations to turn on and off amplifiers etc

I also use the group / ungroup to play the radio in multiple zones without annoying out of sync bleeding!

1 Like

Maybe “Music Assistant” could make Roon library management in Home Assistant less difficult? I’m no software developer, so have no idea if it’s usefull or not. :wink:
GitHub - music-assistant/hass-music-assistant: Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Music Assistant (music-assistant.io)
I haven’t found the group/ungroup option in Home Assistant, but maybe that’s because I’m using the Mushroom Cards?

I use the Home Assistant plugin heaps now, partly because the Roon remote app is terribly unstable but mostly because its much faster than the roon remote app for many uses.

I use a mixture of:

  • automation rules for power on/off of amps
  • automation rules for hue dimmer switch “remotes”
  • volume integration so roon volume changes push commands to HA to send the commands to the amp
  • a dashboard showing all endpoints and amp controls with colour coding based on active amp input
  • a dropdown for “source zone” and toggles for zone grouping… this is so much faster than achieving the same thing with the roon remote app

The thing I like most about using HA in the middle is I can have the same user experience with a bunch of quite disparate devices.

1 Like

You can use group / ungroup via the media player join / unjoin services:-

Or via the Mini Media Player Card (there is an option to fold or unfold these)

I think the main guy behind Music Assistant is the guy who originated the HA Roon integration. As I understand it he was switching from LMS, did a lot of work integrating with Roon - but then decided it didn’t hit the spot for him - and started to develop something of his own. He archived the roon HA library before integrating it into the HA core components.

He was kind enough to unarchive his library and hand it over to me to finish off and support.

2 Likes

You are a power user!

Great you’re using so much. Probably everything except the browser!.

So “Music Assistant” isn’t an easy way out.
Too bad. :wink:

I try :smiley:

Seriously though, it’s still a work in progress but I’m super happy with what I’ve achieved so far.

The dashboard is busy, but it’s so functional. Once I’ve chosen what I want to listen to I spend the rest of my time in HA if I want to pause, change volume, group players etc. My next step is to integrate a transfer feature so I can transfer my current listening straight to a specific room. Overview in the image below (the unavailable items are currently offline as I’m in the middle of moving houses)

1 Like

The latest Home Assistant has a bug fix in the Roon integration. The progress bar would sometimes just back to the start of a track (or the last place it was positioned every 30 seconds.

This is now fixed - and it should track smoothly.

3 Likes

Is there any way to start a daily mix using home assistant?

Not that I can see.

The roon API doesn’t seem to make the roon playlists available.

So you’d probably need to work round it by copying to a local playlist.

At some point I hope roon will update the API…

Is anyone else having issues with the lastest build of Roon? When Home Assistant is running I no Airplay endpoints show up anymore and the core loses its connection every couple minutes.

After shutting down HA, airplay2 endpoints can now be seen and the connection is uninterrupted for smooth playback to all endpoints again.

All worked in harmony before this latest roon update with Airplay2

I don’t use airplay for roon in my setup, but I checked and roon is still discovering the ones I have.

After upgrading I did have an endpoint that needed to be re-enabled in roon (it was ropieee with a HAT, but my other ropieee/HAT endpoints were fine).

This same endpoint was behaving oddly in HA, but restarting HA seemed to fix everything.

I’d be surprised if the Roon HA integration could affect roon airplay discovery, but it is possible there is something else in HA that is responding to Roon’s airplay discovery packets (and in your case confusing roon). Do you have anything that might do this in your HA config?

Appreciate the feedback. I’ve got it stable again after consolidating network interfaces and disabled ones not in use, though they were not even connected or assigned IPs. No idea what the causes this and why it only occured when HA is running. Everything had been running fine prior to this update, included airplay discovery.
It really is puzzling, but glad to have it working again.

1 Like

@James_Fitzell , this looks amazing. any chance you can share your workflow and how you got that in home assistant, including the color coding in the home assistant dashboard :smiley:

Z