Roon module for Home Assistant

Totally, but I am trying to gather up all the playlists so that I can save them to a file so that I can use that file for my Rhasspy setup to listen for those items so I can play them via voice.

@GregD do you know if the data is exposed programmatically so that I can save them to a file?

Take a look at @Ronald_Record’s command line interface.

I’m not sure RoonCommandLine will do what @Eric_Gross wants. At least not yet. If I read this thread correctly, he wants to export Roon playlists to some file format that can be used to later import playlists to another system. The RoonCommandLine utilites can list the Roon playlists but that list does not contain the contents of the playlist. You can, in Roon, export a playlist to Soundiiz (very convenient) or Excel. That is a manual process and requires each playlist be exported one by one.

@GregD I’m not sure if the API even exposes playlist contents but if it does then perhaps I can create an automated way to export all playlists. That would be handy.

1 Like

I read that he just wanted all the names.

But if he needs the tracks - they are available via the browse api (I use this for the home assistant browser) but would clearly need some work in the command line wrapper…

@Ronald_Record I’m not after the track names myself. I totally get the value in being able to export playlists but I’m not currently barking up that tree. I think having each song title would be helpful if I wanted to be able to play Roon content by track, but I am content to choose content via album or playlist.

What I’m trying to do is combine two amazing pieces of tech: Rhasspy and Roon. I’m using Rhasspy to listen to my voice commands (without any cloud interaction) and send Home Assistant events that I can respond to.

In order to use this, I need two pieces of information for each playlist: the text I want to listen for to be spoken and also the value that the Home Assistant media player will be looking for.

The RoonCommandLine command roon -l playlist may work for your needs @Eric_Gross

Unfortunately, the recent update broke api calls as Roon Labs changed the Roon Core port range and many of us were assuming port 9100. Roon Labs points out that was a bad assumption on our part but they kinda yanked the rug out from under our feet with no warning. Anyway, I will have this fixed in a new release asap.

@GregD see Roon Api on Build 880: Connection refused error :(

1 Like

@Eric_Gross I’ve released an updated version of RoonCommandLine that works with the new port setting in the latest Roon update. Previous versions of RoonCommandLine will no longer work properly. If you want to try out RoonCommandLine, use version 2.0.2 release 1 or later. It’s available in the Releases section of the repository on Gitlab:

After the initial installation of this package you should be able to execute the following command in a terminal window on the system where it is installed:

roon -l playlist

and get a list of playlist names returned from your Roon Core. I don’t know anything about your setup or Home Assistant or Rhasspy but I would be happy to followup if you run into any difficulty. Let me know how it goes if you try it out.

1 Like

I’ve been using this plugin for over a year, very happy with it! Unfortunately the latest Roon update has caused it to stop working, unless I disable UFW firewall on my Ubuntu host (hosting both Home Assistant through docker and Roon Server). Any idea which port needs to be opened to get the plug-in working again with UFW enabled?

If you want to play and depend on discovery perhaps 9100-9400.

Thx, tried that but doesn’t work yet. I have a fixed configuration, so I guess I don’t need discovery. anything special I need to do then, apart from just enabling the integration in home assistant (which also only works with firewall disabled currently)?

Ah I thought you had it working with the old port.

Roon also needs 9003 (fixed typo it isn’t 9103!) for discovery.

The home assistant integration allows you to specify an IP address if discovery doesn’t work - although I expect I need to revise that code because it uses an old port number…

Discovery is a more stable/ more future proof option if you can live without the firewall - or open the ports needed.

I’m away for a few days - but I have discovery working over my VPN - so can double check the ports if needed when I’m back.

1 Like

Thx. No rush. I opened the 9100:9400 TCP range, but still no luck. As temporary solution I opened all ports for LAN traffic, with that all is working. Would be nice to limit it to the right port range in the future though.

Sorry there was a typo in my message - discovery is on 9003. So give that a try.

(I’ll fix the old message).

1 Like

Got it! :partying_face:

Solution: open 9100:9400 (TCP) and 9003 (UDP) on Roon Server / Home Assistant host PC, for entire LAN network. Will play around a bit to make the firewall rule stricter to only certain IPs.

1 Like

I really like the Roon integration, it is working very well.

Would it be possible to implement a snapshot / restore function similar to sonos service: Sonos - Home Assistant (home-assistant.io)?

I would like to use my speakers to chime when someone is at the door but I would also like that when the door chime has been played , the music resumes.

@Tom_den_Heijer great to hear you’re finding it useful.

I’m afraid the Roon api doesn’t make what you suggest easy since as far as I can see it doesn’t provide a call to snapshot or restore the current state / playlist.

So I don’t think it’s possible….

what a pity…such an awesome idea!

wonder if you could do something like a scene snapshot in HA of the media_player just before you do the tts call (assuming you do the tts announcement for the doorbell in an automation)

I quickly tried it but restoring the scene does not seem to set all the fields to get Roon going again.

1 Like

I’m afraid without support from the Roon API the HA scene snapshot restore won’t work very well.

Hi folks,

Firstly – just to say thank you for your work on this module. My wife and I use it every day and it really is one of the best things about Roon.

I was wondering if anyone is using it to load a playlist and then play it in a random order (i.e. shuffle) it?

My script is pretty straightforward:

alias: Master bedroom - Roon Test
sequence:
  - service: media_player.shuffle_set
    data:
      shuffle: true
    target:
      entity_id: media_player.master_bedroom
  - service: media_player.play_media
    data:
      media_content_type: music
      media_content_id: Playlists/Bed
    target:
      entity_id: media_player.master_bedroom
mode: single
icon: mdi:sleep

This used to work previously, but since a recent update I’ve found that loading the playlist resets the state of the shuffle (so the playlist just plays through). Moving the shuffle AFTER the load playlist almost works, but it always plays the first song before shuffling.

Maybe if there is a way to load the playlist, then shuffle, then start playing then that would do it; the only possible way I found to do that was the autoplay key on play_media but that seems to be ignored.

Any advice warmly received. Thanks!

Hi @Joe_C - and glad you find the Home Assistant integration useful.

I checked just using the roon client this morning - and it looks like shuffle is now set to off when playing something. I’m not much of a shuffle user myself - so I don’t know if this has changed - but from your experience I’d guess it has. This has changed in Roon - not in the home assistant integration.

I’m afraid there isn’t a way of loading a playlist without starting it playing in the roon api. And I also checked that you can’t specify a shuffle state when you give the play command.

You can, of course, pause playing, and go back to the beginning of the track - but when I tried this in roon it still always plays the first track.

All I can think of is to include a short blank track at the start of each playlist which you skip after you turn on shuffle.